InferLog: Accelerating LLM Inference for Online Log Parsing via ICL-oriented Prefix Caching

Yilun Wang, Pengfei Chen, Haiyu Huang, Zilong He, Gou Tan, Chuanfu Zhang, Jingkai He, Zibin ZhengarXiv 2025 · DOI

Overview

Log parsing—the process of converting semi-structured system logs into structured templates and variables—is a foundational task for modern DevOps operations, including anomaly detection and root cause analysis. While Large Language Models (LLMs) have achieved state-of-the-art accuracy in log parsing, their deployment in production environments is often hindered by high latency and computational costs.

InferLog is a novel inference optimization framework designed to bridge this gap. By intelligently refining In-Context Learning (ICL) prompts to maximize prefix cache hits and utilizing meta-learning for rapid configuration tuning, InferLog reduces p95 latency by over 43% and achieves up to a 4.02× throughput improvement without sacrificing parsing accuracy.

The Bottlenecks of LLM-based Log Parsing

The authors identify three primary bottlenecks that limit the efficiency of LLMs in online log parsing environments:

  1. The Prefill Bottleneck: Log parsing prompts are typically long, containing detailed instructions and multiple examples, while the generated output is concise. This results in the "prefill" phase (processing input tokens) accounting for approximately 85% of total latency.
  2. Cache Inefficiency: Standard prefix caching, which saves intermediate Key-Value (KV) states to avoid recomputation, often fails in ICL scenarios. Because examples are dynamically selected and reordered for each query, cache misses are frequent.
  3. Suboptimal Configurations: Default settings for LLM serving engines are rarely optimized for the specific token distributions and workload patterns characteristic of log data.
The end-to-end pipeline of LLM-based log parsing for downstream DevOps tasks.

Methodology: The InferLog Approach

InferLog introduces two synergistic components to address these challenges: Prefix-aware ICL Refinement (PAIR) and Fast Configuration Tuning.

1. Prefix-aware ICL Refinement (PAIR)

Instead of treating the prompt as a static entity, PAIR dynamically refines it to maximize KV cache reuse. It operates through three key steps:

  • Matching: It searches a history table to identify previous example sets with the highest potential for cache reuse.
  • Modifying: If a current example shares a template with a cached one but has different variable values, PAIR swaps it with the cached version. Since LLMs prioritize structural patterns in log parsing, this modification does not impact accuracy.
  • Reordering: It rearranges examples to ensure the longest possible sequence matches the existing cache prefix.
Comparison of prefix caching strategies, highlighting InferLog's efficiency in KV cache reuse.

2. Fast Configuration Tuning via AttMAML

To optimize inference parameters such as max-num-batched-tokens, InferLog employs AttMAML (Attention-based Model-Agnostic Meta-Learning). This approach allows the system to learn from historical tuning data across diverse log types. When a new workload arrives, AttMAML can recommend an optimal configuration in just 15 iterations, significantly faster than traditional optimization methods.

Experimental Evaluation

The researchers evaluated InferLog using the Loghub-2k benchmark, which contains 2,000 logs from 16 diverse systems, including HDFS, Spark, and Android. The framework was tested across several models, including Qwen2.5-14B, LLaMA3-8B, and Mixtral-7B.

Key Results

  • Performance: Compared to standard vLLM setups, InferLog reduced p95 latency by 71.9% and achieved a 4.02× speedup in throughput.
  • Accuracy: Across all 16 datasets, parsing accuracy remained virtually identical to standard LLM parsers, proving that prompt modification for caching is highly effective.
  • Generalizability: The system showed consistent performance gains across different model architectures and varying levels of request concurrency.

Conclusion

InferLog demonstrates that by aligning prompt engineering with the underlying mechanics of LLM inference engines, it is possible to achieve production-grade performance for complex log parsing tasks. The combination of prefix-aware refinement and meta-learning-based tuning provides a robust path for deploying LLMs in real-time DevOps pipelines.

Summary updated

Abstract

Modern software systems generate massive volumes of runtime logs, necessitating efficient and accurate log parsing to enable critical downstream tasks such as anomaly detection and root cause analysis. Recently, large language models (LLMs) have achieved advanced accuracy on log parsing, but their deployment in production environments faces two major limitations: (1) the privacy risks associated with commercial LLMs, driving the adoption of local deployment, and (2) the stringent latency and throughput requirements imposed by high-volume log streams, which existing LLM-based parsers fail to meet. Although recent efforts have reduced the number of LLM queries, they overlook the high latency of the LLM invocations, where concurrent log parsing requests can cause serve performance degradation of LLM inference system. In this study, we present InferLog, the first LLM inference optimization method for online log parsing. Our key insight is that the inference efficiency emerges as the vital bottleneck in LLM-based online log parsing, rather than parsing accuracy. InferLog accelerates inference by designing (1) A Prefix-aware ICL Refinement policy to refine the examples and permutation of in-context learning to improve the prefix caching efficiency. (2) A rapid and task-specific configuration tuning pipeline based on meta-learning to find the optimal LLM scheduling-related configuration for dynamic log parsing workloads. The experimental results based on Loghub dataset and vLLM demonstrate that InferLog significantly outperforms existing inference optimization methods and markedly accelerates the state-of-the-art LLM-based log parser without compromising parsing accuracy.
BibTeX
@misc{wang2025inferlog,
  author = {Yilun Wang and Pengfei Chen and Haiyu Huang and Zilong He and Gou Tan and Chuanfu Zhang and Jingkai He and Zibin Zheng},
  title = {{InferLog: Accelerating LLM Inference for Online Log Parsing via ICL-oriented Prefix Caching}},
  year = {2025},
  eprint = {2507.08523},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2507.08523},
}
Figure