AI-Powered Performance Optimization System for Go Code

uber · Tech · 2024 · source Agentic: no · promotional bias: low · source-backed · extracted with prompt 0.5.4 (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: Go service performance optimization

Uber needed to make Go performance tuning repeatable across high-cost services without requiring scarce compiler/runtime experts to manually profile, benchmark, and inspect code for every optimization opportunity.

Constraints:

Architecture

PerfInsights combines Uber's production profiling with constrained GenAI code analysis. A daily fleet-wide profiler captures CPU and memory profiles during peak traffic. Static filtering selects the top 30 expensive service-owned functions by flat CPU, triggers memory analysis when runtime.mallocgc exceeds 15% of CPU time, and excludes open-source dependencies and internal runtime functions. The GenAI stage passes full hotpath source code plus a curated Go antipattern catalog to LLMs. LLM juries and LLMCheck rule validators reduce hallucinations and false positives, while dashboards track detection accuracy, failure reasons, antipattern frequency, and model drift. The system integrates optimization opportunities into CI/CD and developer workflows.

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

flowchart LR
  fleet-wide-profiler[fleet-wide-profiler] --> hotpath-filter[hotpath-filter]
  hotpath-filter --> antipattern-catalog[antipattern-catalog]
  antipattern-catalog --> llm-antipattern-detector[llm-antipattern-detector]
  llm-antipattern-detector --> llm-jury-validation[llm-jury-validation]
  llm-jury-validation --> llmcheck-validators[llmcheck-validators]
  llmcheck-validators --> llmcheck-dashboards[llmcheck-dashboards]
  llmcheck-dashboards --> developer-workflows[developer-workflows]
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 CPU and memory profiles from production Go services during peak traffic. hotpath-filter
hotpath-filter Selects top CPU functions, triggers memory analysis, and removes noisy dependencies/runtime code. fleet-wide-profiler, antipattern-catalog
antipattern-catalog Go Foundations knowledge base of common performance antipatterns and idioms. hotpath-filter, llm-antipattern-detector
llm-antipattern-detector Analyzes full hotpath source code and recommends optimizations. antipattern-catalog, llm-jury-validation
llm-jury-validation Uses multiple LLM judgments to reduce hallucinations and increase confidence. llm-antipattern-detector, llmcheck-validators
llmcheck-validators Domain-specific rule validators that catch false positives and log accuracy metrics. llm-jury-validation, llmcheck-dashboards
llmcheck-dashboards Tracks detection accuracy, failure reasons, antipattern frequency, and regressions. llmcheck-validators, developer-workflows
developer-workflows CI/CD and day-to-day engineering surfaces where optimization opportunities and diffs land. llmcheck-dashboards

Data flow

Production services emit CPU and memory profiles through Uber's fleet-wide profiler. PerfInsights selects hotpath functions, filters candidates to service-owned code, and attaches a curated catalog of Go performance antipatterns. The LLM analyzes the full source code for those hotpaths, flags likely inefficient constructs, and proposes more performant alternatives. LLM juries and LLMCheck validators review the finding, dashboards record accuracy and drift metrics, and accepted opportunities become diffs or workflow items in Uber's Go monorepo and CI/CD process.

4 supporting quotes
“PerfInsights’ optimization pipeline consists of two main stages: profiling-based function filtering and GenAI-driven antipattern detection.”article, stated
“PerfInsights leverages CPU and memory profiles from production services using Uber’s daily fleet-wide profiler during peak traffic periods.”article, stated
“Once hotpath functions are identified, PerfInsights passes their full source codes and a list of antipatterns to a large language model”article, stated
“PerfInsights layers two forms of validation: LLM juries and LLMCheck.  LLMCheck is a framework designed to catch false positives by running through several domain-specific rule-based validators.”article, stated

Why this architecture

PerfInsights narrows LLM work to expensive, service-owned hotpaths because unconstrained code analysis is noisy and costly. The antipattern catalog injects institutional Go performance expertise, while juries and LLMCheck make the suggestions trustworthy enough for developers. This hybrid of profiling, static filtering, prompt engineering, and validation turns performance work from expert-led manual analysis into a repeatable workflow.

3 supporting quotes
“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
“At the core of PerfInsights’ detection engine is a curated catalog of performance antipatterns, informed by the Go Foundations team’s past optimization work.”article, stated
“Validation Pipelines Build Trust To move beyond demos, we needed to give developers confidence in PerfInsights’ recommendations.”article, stated

Models used: large language models · LLM juries · LLMCheck

Scale

Alternatives considered (roads not taken)

manual performance tuning by Go experts

Rejected because: Profiling, benchmarking, and code analysis could take days or weeks and require specialized expertise.

“Traditionally, optimizing Go services has required deep expertise and significant manual effort.”article, stated
“Profiling, benchmarking, and analyzing code could take days or even weeks.”article, stated

single-shot LLM antipattern detection

Rejected because: Early single-shot attempts were inconsistent, hallucinated, and sometimes generated non-runnable code.

“a single-shot LLM-based antipattern detection produced inconsistent and unreliable results—responses varied between runs, included hallucinations”article, stated

unfiltered whole-codebase LLM analysis

Rejected because: Static filtering keeps the analysis focused on service-owned hotpaths rather than dependencies and runtime internals.

“PerfInsights applies a static filter that excludes open-source dependencies and internal runtime functions.”article, stated
“This pre-processing transformed what could have been a brittle AI prototype into a focused optimization assistant”article, stated

Patterns

batch-offline-processing (operations)

PerfInsights runs a profiling and analysis pipeline over production services rather than waiting for developers to manually inspect every function.

“PerfInsights’ optimization pipeline consists of two main stages: profiling-based function filtering and GenAI-driven antipattern detection.”article, stated

llm-as-judge (evaluation)

LLM juries validate optimization findings to reduce hallucinations and improve confidence.

“PerfInsights validates them using large language model (LLM) juries to reduce hallucinations and increase confidence in its suggestions.”article, stated

guardrails-io-filtering (safety)

Static filtering and LLMCheck validators restrict analysis to relevant code and catch false positives.

“PerfInsights applies a static filter that excludes open-source dependencies and internal runtime functions.”article, stated
“LLMCheck is a framework designed to catch false positives by running through several domain-specific rule-based validators.”article, stated

prompt-versioning (model-operations)

Prompt strategies were iterated with few-shot examples, contextual cues, and explicit antipattern definitions to improve detection precision.

“We then introduced several targeted prompt strategies to enhance accuracy.”article, stated
“By encoding explicit antipattern definitions and Go-specific idioms into the prompts, we improved detection precision”article, stated

observability-tracing (operations)

LLMCheck dashboards track detection accuracy, false positives, failure reasons, and model regressions.

“With LLMCheck dashboards tracking detection accuracy, false positive reasons, and model regressions”article, stated

Tradeoffs

Constrain analysis to profiled hotpaths.

Chose top CPU and allocation candidates from production profiles over broad LLM codebase analysis.

Rationale: Profiling identifies expensive functions and limits the model's search space to high-impact code.

“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

Validate LLM findings with both juries and rule-based checks.

Chose LLM juries plus LLMCheck over trusting a single model's recommendation.

Rationale: The dual validation strategy reduces hallucinations and false positives enough to earn developer trust.

“This dual-validation strategy has dramatically improved precision, reducing false positives from over 80% to the low teens.”article, stated

Encode institutional Go performance knowledge into prompts.

Chose curated antipattern catalog and Go-specific prompt cues over relying only on pretrained model knowledge.

Rationale: The source says explicit definitions, examples, and idioms improved detection precision.

“At the core of PerfInsights’ detection engine is a curated catalog of performance antipatterns, informed by the Go Foundations team’s past optimization work.”article, stated
“By encoding explicit antipattern definitions and Go-specific idioms into the prompts, we improved detection precision”article, stated

Gotchas (what bit them)

Unconstrained GenAI code analysis creates too much noise.

Root cause: Early single-shot detection varied between runs, hallucinated, and produced non-runnable code.

Resolution: Score only detected antipatterns, add targeted prompt strategies, and validate with juries plus LLMCheck.

“responses varied between runs, included hallucinations, and often generated non-runnable code.”article, stated
“we first improved reliability by scoring only based on detected antipatterns.”article, stated

Large Go functions can be truncated if the model context is too small.

Root cause: Hotpath source code needs to be passed into the prompt for useful analysis.

Resolution: Use high input token limits and prompt phrasing that includes Go-specific idioms and antipattern definitions.

“high input token limits were critical for passing large Go functions without truncation.”article, stated
“small adjustments in prompt phrasing and contextual cues dramatically influenced accuracy.”article, stated

Developer adoption depends on trust, not novelty.

Root cause: Performance recommendations can waste engineering time if false positives and hallucinations are not visible and controlled.

Resolution: Use validation dashboards, track failure reasons, and surface clear wins before broad adoption.

“Validation Pipelines Build Trust To move beyond demos, we needed to give developers confidence in PerfInsights’ recommendations.”article, stated
“Landing the first 5 digits saving diff was a breakthrough moment. Engineers saw that this wasn’t theoretical—it worked!”article, stated

Candidate selection matters before any model call.

Root cause: Sending non-service code, dependencies, and irrelevant runtime functions into the model increases noise.

Resolution: Filter on production CPU and allocation profiles, top functions, and service boundaries before invoking GenAI.

“Before any GenAI magic happens, PerfInsights performs aggressive static filtering using CPU and allocation profiles.”article, stated
“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

Evaluation

Uber evaluates PerfInsights with false-positive reduction, hallucination reduction, engineering time saved, merged diffs, LLMCheck dashboards, detection accuracy, failure patterns, and model-regression signals.

Metrics: false positives from over 80% to low teens · 93.10% time savings · 14.5 hours to almost 1 hour tool runtime · approximately 3,800 expert hours avoided · hallucination rates cut by more than 80% · hundreds of generated and merged diffs

3 supporting quotes
“reducing false positives from over 80% to the low teens.”article, implied
“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 of tool runtime—a 93.10% time savings.The impact goes beyond dollars saved.”article, implied
“Dashboards powered by LLMCheck provide teams with visibility into detection accuracy, error patterns, and antipattern frequency.”article, implied

Outcomes

The source gives strong production context: top 10 Go services with multi-million-dollar compute spend, top-30 hotpath selection per service, a 15% memory threshold, hundreds of diffs, 3,800 avoided expert hours, and 93.10% time savings.

3 supporting quotes
“With hundreds of diffs already generated and merged into Uber’s Go monorepo”article, stated
“This transparency has helped cut hallucination rates by more than 80%, boosting trust in AI-assisted tooling.”article, stated
“What was once an expert-led, reactive task is now a proactive loop embedded across Uber’s engineering life cycle.”article, stated