arXiv:2609.40247cs.OSSep 2026

Manuscript Offprint

arXiv:2609.40247

Herschel: Continuous Optimization of Production LLM Inference through On-Demand Profiling

Luping Wang, Weigao Chen, Yifei Wu, Yonghe Zhang, Rui Zhang, Wenchao Wu, Jiyu Luo, Haoran Geng, Xin Yang, Chen Cao, Yuemin Wu, Cheng Huang, Guodong Yang, Liping Zhang

Abstract

Model-as-a-service platforms call for continuous optimization as complex serving conditions expose inefficiencies missed before deployment. Detailed always-on profiling can incur substantial overhead, while lightweight collection omits information needed for diagnosis. We present Herschel, a continuous optimization system for production large language model (LLM) inference. Our key insight is that adaptive, on-demand profiling can provide rich full-stack evidence without continuous collection. Herschel safely attaches to and detaches from selected running processes without engine changes or restarts, and adapts coverage as investigations reveal missing evidence. Herschel reconstructs operator executions and cross-process dependencies to identify inefficiency mechanisms and suggest solutions using applicable reference fixes. AI agents implement and test engine and kernel changes under controlled conditions that preserve the triggering workload and dependencies, with expert review before deployment. Controlled tests show active-collection overhead below 0.5% for time to first token and 7% for time per output token. Bounded windows, typically 30 s, avoid the continuous cost of always-on tracing. Over six months, Herschel collected ~17,000 traces across over 120 model variants and more than 10 accelerator types, identifying inefficiency patterns in 23% of the traces. Representative findings guide widely deployed optimizations, including restructured synchronization, removal of unused computation, and improved operator implementations.

1 Introduction

Model-as-a-service (MaaS) platforms pursue day-one availability, offering new models on their release day [6,35]. Pre-deployment tuning covers selected workloads and can leave performance inefficiencies unaddressed. Figure 1a shows performance improvements across five of our flagship models over up to eight weeks after release. These post-release gains are achieved through repeated cycles of analysis, improvement, and validation—continuous optimization.

Continuous optimization is challenging under complex serving conditions. MaaS spans many combinations of models and deployment configurations, each with varying workloads.

Model-I Model-II Model-III

Model-IV Model-V

Figure

Figure

0-32K 32-176K 176-512K 512K+

Figure

Mean input length (tokens)

(a) Flagship model performance: 8 (b) Complexity in serving configurations of post-release optimization.

Figure 1: Continuous optimization under complex serving conditions on MaaS platforms.

Figure 1b illustrates this diversity. Locating avoidable waits, missed communication–computation overlap, redundant state preparation, and unused computation can require examining dependencies among engine components. Operator efficiency also depends on matching data layouts and parallelism to input shapes and target GPU architectures. Moreover, the same inefficiency can be prominent in one workload yet negligible in another.

Identifying these inefficiencies and assessing their significance requires full-stack online profiling, which remains challenging with existing approaches. Anomaly-driven diagnosis may overlook persistent inefficiencies that do not deviate from historical baselines [79]. For always-on profiling, retaining rich full-stack detail conflicts with limiting sustained collection overhead. Detailed tracing in PyTorch Profiler and Nsight Systems can incur substantial overhead [46, 50], while lightweight collection restricts the calls and runtime state available for investigation. A cloud provider must also decouple collection from engine releases: remote triggering alone can still require launch-time support [34].

To address these constraints, our first insight is that full-stack profiling can be adaptive without being always on. Runtime attachment enables on-demand profiling of running services without engine changes or restarts. Detailed recording

∗^{*}Corresponding author: Luping Wang, chamu.wlp@alibaba-inc.com.

is limited to bounded windows, retaining rich full-stack evidence while avoiding the continuous cost of always-on tracing. Collection need not wait for anomalies; recording coverage can be adjusted in later windows to fill evidence gaps.

Furthermore, turning profiling observations into deployable optimizations still requires substantial expert effort, both to pinpoint root causes across different serving conditions and to develop effective fixes. Our second insight is that inefficiency mechanisms and optimization strategies recur across serving conditions. These mechanisms guide root-cause identification, while reference fixes give AI agents a starting point for implementation and testing. Current evidence helps assess applicability and identify correctness constraints to validate.

We present Herschel, a system for continuous optimization of production LLM inference with three components:

• Hprof uses runtime-attached probes for on-demand profiling within bounded windows. On supported runtimes, it captures Python calls and supported object fields, accelerator API calls, and device activity from running services without application source-code changes or restarts. A fleet control plane selects processes and recording windows for serving conditions; investigations can adapt coverage as evidence needs change ( §5§5).

• Analyzer then reconstructs operator executions and cross-process dependencies from these records and checks the conditions of recurring engine and operator inefficiency patterns. It uses confirmed mechanisms and applicable reference fixes to produce optimization opportunities with supporting evidence and suggested solutions. When evidence is insufficient to confirm a mechanism, Analyzer requests expert-approved supplementary profiling ( §6§6).

• Optimizer uses these opportunities to guide engine and kernel agents in implementing and validating candidate changes. Experiments use controlled deployment scales while retaining the workload conditions and dependencies that expose the problem. Correctness and performance feedback guide successive revisions; expert review determines which changes proceed to canary validation and staged rollout ( §7§7).

We evaluate Herschel in controlled tests, where Hprof's active-collection overhead stays below 0.5% for TTFT and below 7% for TPOT across the tested model sizes and workloads. Bounded windows, typically 30 s, avoid the continuous cost of always-on tracing, with safe attachment and detachment. Our six-month production study spans over 120 model variants and more than 10 accelerator types, identifying inefficiency patterns in 23% of approximately 17,000 traces. Findings include unused computation, repeated state preparation, and operator inefficiencies at small input shapes. These findings guided optimizations that are now widely deployed after expert review and canary validation.

References (33)