18 Comments
User's avatar
Garv Arora's avatar

The line about developers hesitating to touch a service that already works is the organisational problem hiding in here. A PR that saves 8.8% CPU still asks the owning team to take on the risk of a change, while the savings usually land in a shared infrastructure bill. Shifting left helps partly because it removes that trade. It's much easier to accept a fix before the code has ever carried production traffic.

mengzhu's avatar

One thing I'd love more detail on: the article says the reactive path profiles production services "on a recurring schedule or on demand", but doesn't say how the profiling overhead itself is budgeted. CPU sampling at 100 Hz is cheap (JFR targets ~1% out of the box), but allocation/lock/native-memory modes are not - async-profiler's own docs advise against running --all continuously in production - and dynamic attach also costs a short safepoint pause. So: what's the sampling mode and window per service, how many instances are profiled at once, and is the trigger a fixed schedule or driven by anomaly detection? That choice matters a lot for whether this can be always-on across the fleet or only on a canary pair.

mengzhu's avatar

To add some context to my question above: back in November 2025, we asked the newly released Gemini 3 Pro Preview to analyze profiles and stack traces for a bug we had been chasing for months. It helped us find the root cause. There was no crash: CPU usage crept up over weeks until it was pegged at 100%, and the profiles pointed at framework internals (Akka's scheduler, ForkJoinPool.scan) rather than application code. The culprit was a stream stage using groupedWithin(1, 1.millis). With the limit set to 1, each element is emitted immediately as its own group, so the time window never comes into play. The stage just creates and cancels a scheduler timer for every element. Model capability was never our blocker; what held us back was operational risk.

We never implemented automated collection in production. Our main concern was the overhead and risk of collecting this data, especially around the attach path: there are known cases where attach/JVMTI handling has left a JVM in a much worse state (https://github.com/zulu-openjdk/zulu-openjdk/issues/350). I agree with the article's overall direction, but it leaves out the operational part I'm asking about. How do you make collection cheap and safe enough to run unattended across a fleet, rather than limiting it to a canary and a baseline instance and relying on someone to turn it on manually?

Rohan's avatar

using agents to catch the perf bugs ai-written code sneaks in is clever. do the patches ship automatically or get reviewed?

Arslan Ahmad's avatar

The Pattern Catalog is the most transferable idea here. Plain Markdown in a Git repo instead of a vector database, and it works because the problem is not retrieval at scale, it is a few hundred reviewable rules injected into a prompt. Teams keep reaching for embeddings when a grep-able wiki would do.

Also worth noting the trust design: the LLM proposes, the canary and telemetry judge. No AI in the verification loop. That separation, probabilistic generation with deterministic verification, is what makes agents deployable in production at all.

Early Signal's avatar

I love the check that's false before and true after, with the canary judged by hard metrics against a baseline instead of another model. Engineering is objective, and guardrails like that make AI's output better; without them, you don't know it's doing the right thing.

NIA's avatar

My favourite bit of this genre: AI writes the code faster than ever, the code ships subtle performance problems, and now we need AI agents to go find them. Beautiful little ouroboros. The part worth reading is the safety and verification section — an agent that edits code based on a flame graph is either very useful or a very fast way to make the graph worse.

Raghav Mehta's avatar

The metrics.counter lookup eating 66% of CPU while the business logic used 0.3% is a striking ratio. It also shows the pattern-matching approach works best on repeated library misuse. One thing I'm curious about is the canary stage. With CPU wins this large the signal is obvious, but how does the pipeline decide when a smaller gain is real rather than noise from traffic variance between the canary and baseline?

Theodoros Zavos's avatar

What I'd copy first: no AI model judges the canary. Hard metrics against an identical baseline, then a PR with the flame graph and the report, and a person decides.

The Pattern Catalog as plain Markdown in Git makes sense to me too. That's how I keep my own agent rules, and a plain diff is enough to review them.

Ruben Dominguez's avatar

one missing gate is when to stop trying. If a patch saves a little CPU but worsens p99, how many alternatives can the agent test before it hands the case back? I'd put a cost cap and a no-progress exit beside the canary checks, and keep rejected attempts with their measurements so the next run doesn't repeat them

We covered those explicit exits in this loop-engineering guide: success, budget, stalled progress and escalation need different endings https://www.the-ai-corner.com/p/loop-engineering-masterclass-self-improving-ai-systems-2026

Jordan Vale's avatar

The Pattern Catalog idea is the part I would steal first, plain Markdown that people and models can both read. Do you think it stays useful once a team has hundreds of patterns, or does it need stricter curation then?

Komal Mishra's avatar

Just added memory to my own news agent this week, so the Pattern Catalog part clicked. A stateless LLM plus a simple shared memory is so practical. No vector database needed.

Daniel Vos's avatar

The Pattern Catalog is the part I'd copy well beyond performance work. Plain Markdown that both people and the model can read, with a person still making the final call on each PR, turns one fix into a rule every later run starts from.

Abhishek Pan's avatar

The counter caching fix has a trap when the name comes with tags that vary per call, like status or region: cache one reference at class init and every request lands on the same series. Unit tests and a CPU canary both pass that, so it's worth diffing the metric series count between canary and baseline too.

Nan Deng's avatar

The check I would not hand back to the model is the canary. The pipeline already requires the branch to pass unit, integration, and contract tests, then runs the change beside a baseline on a slice of production traffic, and the post says no AI model scores that canary. I would keep the decision inputs as the relative CPU, median and P99 latency, allocation rate, and error rate over that window, attached to the PR with the flame graph. A 22x faster character lookup is not a ship if the error rate moved, and a human still has to accept the PR.

Nothing Is Accidental's avatar

Telling the agent to stay inside the app's own packages is the interesting part. Handed a full raw stack trace, it spends its reasoning on JVM garbage collection and kernel syscalls — real costs, but not ones the application team can change. The fence doesn't make the model smarter; it puts the model's attention where somebody can actually act on it.

Travis Wright's avatar

The irony is that AI writes slow code faster than any human ever could, so Netflix is basically hiring a second AI to clean up after the first one. The safety and verification section is the real product, because a performance agent that can't prove its patch helped is just a very confident flame graph reader. I run 44 Grok Bots and the lesson holds: the agent that writes the change should never be the one grading it.