PerfInsights: AI-Powered Performance Optimization for Go Services

uber · Tech · 2025 · source Agentic: yes · promotional bias: high · source-backed · extracted with prompt 0.5.6 (schema v2)

Generated from extraction.json — do not edit by hand. Every claim cites verbatim source evidence; stated means the quote directly asserts the claim, implied means it supports it indirectly.

Problem

Domain: Performance optimization for large-scale Go services

Uber needed to reduce expensive compute usage in Go backend services, but traditional profiling and optimization required specialized Go/runtime expertise and too much manual effort to scale across teams.

Constraints:

Architecture

PerfInsights combines deterministic production profiling with GenAI static analysis. Uber's daily fleet-wide profiler identifies hot Go functions during peak traffic, static filters remove open-source and runtime code, an antipattern catalog guides an LLM detector over full source code, and two validation layers - LLM juries plus rule-based LLMCheck validators - reduce hallucinations. Validated findings produce confidence-scored optimization suggestions that flow into Optix, dashboards, CI/CD, manual review, and continuous code optimization workflows.

Diagram confidence: explicit (topology described by the source).

flowchart LR
  Fleet_wide_profiler["Fleet-wide profiler"] --> Hotpath_function_filter["Hotpath function filter"]
  Hotpath_function_filter --> Static_ownership_filter["Static ownership filter"]
  Static_ownership_filter --> Antipattern_catalog["Antipattern catalog"]
  Static_ownership_filter --> LLM_detector["LLM detector"]
  Antipattern_catalog --> LLM_detector
  LLM_detector --> LLM_jury["LLM jury"]
  LLM_detector --> LLMCheck_validators["LLMCheck validators"]
  LLM_jury --> LLMCheck_validators
  LLMCheck_validators --> Metrics_dashboard["Metrics dashboard"]
  LLMCheck_validators --> Optix_integration["Optix integration"]
  Metrics_dashboard --> Developer_review["Developer review"]
  Optix_integration --> Developer_review
  Optix_integration --> CI_CD_workflow["CI/CD workflow"]
  Developer_review --> CI_CD_workflow
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

Components

Component Role Interacts with
Fleet-wide profiler Collects production CPU and memory profiles during peak traffic across Go services. Hotpath function filter
Hotpath function filter Selects the top 30 flat-CPU functions and triggers memory analysis when runtime.mallocgc exceeds the threshold. Static ownership filter
Static ownership filter Removes open-source dependencies and internal runtime functions so downstream analysis focuses on service-owned code. Antipattern catalog, LLM detector
Antipattern catalog Encodes Go performance patterns from the Go Foundations team and style guide. LLM detector
LLM detector Analyzes full source code and antipattern definitions to detect optimization opportunities and recommend fixes. LLM jury, LLMCheck validators
LLM jury Uses multiple language models to independently assess whether an antipattern and suggested optimization are valid. LLMCheck validators
LLMCheck validators Runs domain-specific rule-based checks, tracks accuracy and failures, and signals model drift. Metrics dashboard, Optix integration
Metrics dashboard Shows detection accuracy, false-positive reasons, model regressions, error patterns, and antipattern frequency. Developer review
Optix integration Receives validated suggestions for automated downstream code transformation and continuous optimization. Developer review, CI/CD workflow
Developer review Lets engineers inspect recommendations, generated diffs, dashboards, and confidence scores before or during adoption. CI/CD workflow
CI/CD workflow Surfaces optimization opportunities regularly in day-to-day engineering workflows. —

Data flow

Production CPU and memory profiles identify the top flat-CPU functions and allocation-heavy services; static filters keep only service-owned candidate code; the LLM receives full source code plus antipattern definitions; LLM juries independently validate detections; LLMCheck applies domain-specific validators and logs accuracy/drift metrics; accepted suggestions and confidence scores feed downstream code transformation or developer review through Optix and CI/CD.

3 supporting quotes
“PerfInsights leverages CPU and memory profiles from production services using Uber’s daily fleet-wide profiler during peak traffic periods.”article, stated
“PerfInsights passes their full source codes and a list of antipatterns to a large language model (LLM) for analysis.”article, stated
“PerfInsights layers two forms of validation: LLM juries and LLMCheck.”article, stated

Why this architecture

PerfInsights constrains the LLM with production profiling, service ownership filters, and a Go-specific antipattern catalog because raw single-shot LLM analysis was unreliable. The architecture layers ensemble and deterministic validation because developer trust and low false positives are prerequisites for code-optimization adoption.

3 supporting quotes
“This pre-processing transformed what could have been a brittle AI prototype into a focused optimization assistant”article, stated
“a single-shot LLM-based antipattern detection produced inconsistent and unreliable results—responses varied between runs, included hallucinations, and often generated non-runnable code”article, stated
“To move beyond demos, we needed to give developers confidence in PerfInsights’ recommendations.”article, stated

Models used: Large language model · LLM juries · LLMCheck · Optix

Scale

Alternatives considered (roads not taken)

Analyze whole codebases with LLMs directly

Rejected because: PerfInsights first uses production profiles and static filters to reduce noise and focus LLM analysis on service-owned hotpath functions.

“This step trims noise from the candidate set, ensuring ‌downstream analysis focuses only on service-owned code”article, stated
“By isolating just the top 30 flat% functions within service boundaries—and ignoring OSS or non-relevant runtime functions—we constrained the search space.”article, stated

Trust a single-shot LLM detection result

Rejected because: Early single-shot detection was inconsistent, hallucinated, and generated non-runnable code.

“single-shot LLM-based antipattern detection produced inconsistent and unreliable results”article, stated
“responses varied between runs, included hallucinations, and often generated non-runnable code”article, stated

Use one broad prompt for all antipatterns

Rejected because: The team found one prompt per antipattern preserved context and simplified tasks.

“Use one prompt per antipattern to conserve context and break down complex tasks into simpler ones”article, stated
“Separate prompts for detection and validation”article, stated

Use LLM juries without deterministic validators

Rejected because: Even juries can hallucinate, so LLMCheck adds domain-specific rule-based validators.

“Even with LLM juries, LLM may still hallucinate”article, stated
“PerfInsights employs a second layer of verification via LLMCheck by running through several domain-specific rule-based validators”article, stated

Keep optimization as reactive expert-led investigation

Rejected because: PerfInsights embeds optimization opportunities into CI/CD and developer workflows as a proactive loop.

“What was once an expert-led, reactive task is now a proactive loop embedded across Uber’s engineering life cycle.”article, stated
“Its integration into CI/CD pipelines and day-to-day developer workflows means optimization opportunities are surfaced regularly”article, stated

Patterns

observability-tracing (operations)

PerfInsights starts from production CPU/memory profiles and uses LLMCheck dashboards to track accuracy, error patterns, antipattern frequency, and model regressions.

“PerfInsights leverages CPU and memory profiles from production services using Uber’s daily fleet-wide profiler during peak traffic periods.”article, stated
“Dashboards powered by LLMCheck provide teams with visibility into detection accuracy, error patterns, and antipattern frequency.”article, stated

eval-driven-development (evaluation)

The system uses LLM juries, LLMCheck, confidence scores, prompt tuning metrics, and dashboards to validate LLM detections before developers act on them.

“Rather than trusting a single model’s judgment, PerfInsights leverages a jury of large language models to validate each detected antipattern.”article, stated
“* Standardized metrics: Tracks reductions in LLM response errors during prompt tuning.”article, stated

tool-use-orchestration (workflow)

Validated LLM findings flow into Optix, code transformation or manual review, CI/CD pipelines, and day-to-day developer workflows.

“These insights are fed into downstream tools for code transformation or manual review by developers. As a result, PerfInsights transforms static profiling data into actionable engineering outcomes within minutes.”article, stated
“PerfInsights seamlessly integrates with automated downstream tasks, with validated suggestions flowing directly into Optix”article, stated

human-in-the-loop-gate (review)

PerfInsights outputs actionable recommendations and diffs into workflows where developers can manually review suggestions and build trust from dashboards.

“These insights are fed into downstream tools for code transformation or manual review by developers.”article, stated
“To move beyond demos, we needed to give developers confidence in PerfInsights’ recommendations. With LLMCheck dashboards tracking detection accuracy, false positive reasons, and model regressions, we could quantify improvement and respond to feedback with evidence.”article, stated

prompt-versioning (prompt-operations)

The team iteratively tuned prompts with few-shot examples, Go-expert role framing, output-quality instructions, confidence scoring, and separate detection/validation prompts.

“More importantly, small adjustments in prompt phrasing and contextual cues dramatically influenced accuracy.”article, stated
“* Separate prompts for detection and validation”article, stated

cost-aware-routing (optimization)

The system targets high-cost service hotpaths first, using CPU allocation profiles to focus LLM work on code that can reduce compute spend.

“At Uber, back-end service efficiency directly influences operational costs and user experience. In March 2024 alone, the top 10 Go services accounted for more than multi-million dollars in compute spend alone —an unsustainable amount that underscored the need for systematic performance tuning.”article, stated
“By using our streamlined tool, we reduced the engineering time required to detect and fix an issue from 14.5 hours to almost 1 hour”article, stated

Tradeoffs

Pre-filter with production profiles before LLM inference.

Chose Deterministic hotpath and ownership filtering over LLM analysis of broad code surfaces.

Rationale: Profiling focuses LLM cost and attention on high-impact functions and prevents noisy suggestions on code teams do not own.

“Before any GenAI magic happens, PerfInsights performs aggressive static filtering using CPU and allocation profiles.”article, stated
“This pre-processing transformed what could have been a brittle AI prototype into a focused optimization assistant”article, stated

Use LLM juries plus rule validators.

Chose Hybrid ensemble and deterministic validation over Single-model judgment or LLM-only validation.

Rationale: The system needs LLM flexibility to reason about code but deterministic validators to catch known false-positive classes.

“These models independently assess whether an antipattern is present and whether the suggested optimization is valid.”article, stated
“PerfInsights employs a second layer of verification via LLMCheck by running through several domain-specific rule-based validators to evaluate LLM responses. There are several benefits:”article, stated

Spend more inference on one prompt per antipattern.

Chose Focused prompts over One broad multi-antipattern prompt.

Rationale: Focused prompts simplify the task and conserve useful context, trading more calls for better precision.

“* Use one prompt per antipattern to conserve context and break down complex tasks into simpler ones”article, stated
“* Use very specific, positive instructions for improved reliability (avoid using “don’t” in instructions)”article, stated

Integrate with Optix and CI/CD rather than ship a standalone dashboard-only tool.

Chose Embedded continuous optimization workflow over Manual one-off performance investigation.

Rationale: Embedding suggestions in existing code transformation and developer workflows makes performance tuning proactive and repeatable.

“PerfInsights seamlessly integrates with automated downstream tasks, with validated suggestions flowing directly into Optix, Uber’s continuous code optimization tool.”article, stated
“Its integration into CI/CD pipelines and day-to-day developer workflows means optimization opportunities are surfaced regularly, not just when something breaks.”article, stated

Ask the model for confidence scores.

Chose Confidence-scored recommendations over Unqualified optimization claims.

Rationale: Confidence requests encourage more thoughtful LLM responses and help downstream review triage.

“Asking for confidence levels in the LLM’s response for each prompt makes the model think more.”article, stated
“The final output includes a confidence score of the function’s optimisability and suggested improvements. These insights are fed into downstream tools for code transformation or manual review by developers.”article, stated

Gotchas (what bit them)

Single-shot LLM detection was unreliable.

Root cause: The model varied between runs, hallucinated antipatterns, and produced non-runnable code when asked to detect issues directly.

Resolution: Improve prompts, score only detected antipatterns, split detection and validation, use few-shot examples, and add LLM juries plus LLMCheck.

“single-shot LLM-based antipattern detection produced inconsistent and unreliable results—responses varied between runs”article, stated
“In our initial attempts, a single-shot LLM-based antipattern detection produced inconsistent and unreliable results—responses varied between runs, included hallucinations, and often generated non-runnable code.”article, stated

The LLM falsely detected case-insensitive string comparison antipatterns.

Root cause: The prompt lacked examples clarifying when the EqualFold antipattern did and did not apply.

Resolution: Add few-shot examples, including cases that resolve the confusion.

“Issue: No case-insensitive string comparison was present in the code but was detected.”article, stated
“Fix: Add few-shot prompting.”article, stated

LLMs can still hallucinate after an ensemble check.

Root cause: LLM juries reduce but do not eliminate errors such as nonexistent antipatterns, map/slice confusion, and loop-invariant mistakes.

Resolution: Run LLMCheck domain-specific validators after the jury.

“Even with LLM juries, LLM may still hallucinate, such as:”article, stated
“PerfInsights employs a second layer of verification via LLMCheck by running through several domain-specific rule-based validators to evaluate LLM responses. There are several benefits:”article, stated

Unfiltered code analysis overwhelms developers with noise.

Root cause: LLMs would otherwise inspect irrelevant dependencies, runtime internals, or cold code that teams cannot or should not optimize.

Resolution: Use production profiles and static filters to isolate hot service-owned code before LLM inference.

“To focus the analysis, PerfInsights applies a static filter that excludes open-source dependencies and internal runtime functions. This step trims noise from the candidate set, ensuring ‌downstream analysis focuses only on service-owned code that’s most likely to benefit from optimization.”article, stated
“To focus the analysis, PerfInsights applies a static filter that excludes open-source dependencies and internal runtime functions. This step trims noise from the candidate set, ensuring ‌downstream analysis focuses only on service-owned code that’s most likely to benefit from optimization.”article, stated

Developer trust is hard without measurable validation.

Root cause: Engineers need evidence that AI recommendations are accurate and improving, especially for code optimization.

Resolution: Expose detection accuracy, false-positive reasons, model regressions, and antipattern frequency through LLMCheck dashboards.

“With LLMCheck dashboards tracking detection accuracy, false positive reasons, and model regressions, we could quantify improvement and respond to feedback with evidence.”article, stated
“As a result, PerfInsights became not just usable, but dependable.”article, stated

Evaluation

PerfInsights evaluates both code and model behavior: production profiling selects candidates, LLM juries validate antipattern existence and suggested fixes, LLMCheck rule validators catch false positives, confidence scores rank suggestions, dashboards track detection accuracy and regressions, and downstream Optix/CI/CD workflows validate code improvements.

Metrics: Flat CPU usage · runtime.mallocgc CPU share · Validated detections · False positive rate · Detection accuracy · Failure rates · Model drift · Confidence score · Antipattern frequency · Merged diffs · Engineering time saved · Hallucination rate · Compute cost savings

4 supporting quotes
“LLMCheck also logs metrics on detection accuracy, tracking failure rates and signaling potential model drift. This dual-validation strategy has dramatically improved precision, reducing false positives from over 80% to the low teens.”article, stated
“The final output includes a confidence score of the function’s optimisability and suggested improvements. These insights are fed into downstream tools for code transformation or manual review by developers.”article, stated
“Dashboards powered by LLMCheck provide teams with visibility into detection accuracy, error patterns, and antipattern frequency.”article, stated
“With hundreds of diffs already generated and merged into Uber’s Go monorepo, PerfInsights has turned optimization from a specialist endeavor into a scalable, repeatable practice.”article, stated

Outcomes

Uber reports multi-million-dollar monthly compute spend for the top 10 Go services, daily fleet-wide profiling at peak traffic, top-30-function filtering, >15% runtime.mallocgc memory-analysis trigger, hundreds of merged diffs, and projected thousands of annual engineering hours saved.

4 supporting quotes
“The results have been transformative. Tasks that once required days now take hours. Engineers can now deliver high-impact performance improvements without needing specialized knowledge of compilers or runtimes.”article, stated
“This dual-validation strategy has dramatically improved precision, reducing false positives from over 80% to the low teens.”article, stated
“This transparency has helped cut hallucination rates by more than 80%, boosting trust in AI-assisted tooling.”article, stated
“Most importantly, PerfInsights has redefined performance tuning as a continuous, data-driven discipline. Its integration into CI/CD pipelines and day-to-day developer workflows means optimization opportunities are surfaced regularly, not just when something breaks.”article, stated