Overview

7 Vibe performance engineering: when assumptions mislead

In this chapter, the author shows how performance work can fail when it is driven by guesswork instead of evidence. Two recurring mistakes are highlighted: optimizing code too early without knowing traffic or latency requirements, and ignoring the hot-path, the part of the system that accounts for most real work. The chapter argues that LLM-assisted development does not automatically protect engineers from these mistakes; in fact, if prompted badly, it can amplify them by confidently generating over-engineered solutions and hidden complexity.

Using an account lookup example, the text compares a human-style optimization attempt with an LLM-generated one. Both initially assume that multithreading will help, but benchmarks show that parallel execution adds overhead without improving performance for the realistic workload. When the prompt is revised to include the expected data size, the model switches to a better algorithmic solution: a map-based lookup that is much faster than the thread-heavy variants. The lesson is that LLMs can produce strong results, but only when given concrete constraints about traffic, scale, and acceptable trade-offs.

The chapter then moves to hot-path analysis in a word service, where load testing and internal metrics reveal that the most frequently executed endpoint dominates overall system cost even if it is not the slowest in absolute terms. The human approach uses targeted metrics and a cache to improve the word-exists path while keeping tracing lightweight and focused. The LLM approach also identifies the bottleneck, but it tends to add too much custom instrumentation, blur the diagnostic signal, and make implicit assumptions about memory, startup time, and caching strategy. Overall, the chapter concludes that LLMs are useful performance helpers, but they work best when engineers supply traffic expectations, measure actual behavior, and keep the optimization scope tightly aligned with the hot-path.

AccountFinder JMH Plot.
AccountFinder JMH Plot with HashMap is much faster than the other approaches.
Endpoints with different request frequencies.
The 80/20 rule, as presented by the Pareto principle.
The architecture of a word service with two functionalities.
Viewing the word-of-the-day initial performance results that looks good enough.
Viewing the word-exists initial performance results - higher percentiles looks problematic.
Eager initialization and computation.
The word-exists performance results after applied optimization.
The LLM-caching solution is faster than the human-based solution, but at the cost of increased memory consumption.

Summary

  • LLMs are also prone to mistakes in optimizing code based on a lack of or false assumptions. Providing sufficient context allows LLMs to implement solutions that match those created by experienced performance engineers.
  • Knowing the expected SLA and traffic for your system is even more critical in the context of Vibe Performance Engineering, as it can help you guide the LLM towards more efficient solutions.
  • The trade-off between tracing and measuring too much vs too little is essential in the context of hot-path detection. Measuring too much increases the cognitive load; measuring too little doesn’t allow you to detect the hot-path at a proper granularity level.
  • Be careful when using the LLM to generate performance improvement code, as it may shift the performance problems from one place (runtime) to another (application startup with eager init). Again, providing the boundaries (RAM needed, write vs read requests per second, etc) guides LLM into the proper direction and reduces the risk of introducing bottlenecks in different places

FAQ

What are the two most common performance-engineering mistakes discussed in this chapter?The chapter highlights two predictable mistakes: optimizing based on false assumptions, and failing to optimize the hot-path. Both can add complexity and maintenance burden without improving real production performance.
Why is premature optimization considered risky in vibe performance engineering?Because without traffic data or SLA requirements, it is hard to know which code paths truly matter. Optimizing too early can make code more complex while delivering little or no benefit.
What is the hot-path, and why does it matter?The hot-path is the part of the system that handles most requests and does most of the work. Optimizing it usually gives the biggest performance return because it affects the majority of user traffic.
How did the human solution over-optimize the account lookup example?It replaced a simple single-threaded stream search with a parallel stream approach, adding multithreading overhead and complexity. Benchmarking showed the parallel version was not meaningfully faster, so the added complexity was not justified.
What mistake did the LLM make when asked to improve AccountFinder performance?The LLM blindly followed the request to move away from single-threaded execution and over-engineered the solution. It generated multiple concurrent strategies and assumed large-scale traffic without first asking for expected data size or performance requirements.
Why was the custom benchmark generated by the LLM considered unreliable?It used ad hoc benchmarking instead of JMH, which makes results less trustworthy due to missing proper warmup, JIT effects, and other JVM concerns. The benchmark also baked in questionable assumptions about data size and parallelism.
How did providing traffic expectations change the LLM’s recommendation?When told the system would search one account among at most 10,000 accounts, the LLM stopped recommending multithreading and instead suggested a map-based lookup. That shift focused on algorithmic improvement rather than parallel execution.
What is the main lesson from the word-service hot-path example?Optimize the code path that handles most requests, not necessarily the slowest-looking endpoint. In the example, the word-exists path dominated total workload, so it was the right place to focus optimization efforts.
Why did the chapter use both Gatling and code-level metrics?Gatling provided end-to-end, black-box performance data, while code-level metrics identified which internal operations were responsible for the slowdown. Together, they helped pinpoint the hot-path and the exact bottleneck inside it.
What trade-off did the LLM-based caching solution introduce?It improved lookup speed significantly, but it did so by eagerly loading and retaining all words in memory, increasing startup time and memory usage. The chapter stresses that performance gains must be weighed against hidden costs like maintainability, resource use, and scalability.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Vibe Engineering ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Vibe Engineering ebook for free