liveBook · Manning

Performance

As explained in Vibe Engineering

Performance is a measure of a software system's resource efficiency and responsiveness under defined operating conditions.

Performance measures how efficiently and responsively software operates under defined conditions. Code can pass functional tests at staging scale yet fail under production load: N+1 queries, poor algorithmic complexity, and excessive resource use may remain hidden until traffic grows. section 1.6

When expected traffic, throughput, and maximum latency are unknown, start with maintainable code rather than assuming a particular optimization will help. An optimization can add code, maintenance, or system complexity without improving the main workflow. Define the workload and measure the affected path before accepting that tradeoff. section 7.1

A parallel account search

An account finder filters a list by ID. Its sequential stream evaluates lazily and can stop when it finds a match. Replacing it with parallelStream() uses work-stealing to distribute tasks, but also introduces concurrency: processing should be stateless, and thread-pool utilization needs monitoring. Without knowing list size and workload, more threads are not evidence of a faster search. section 7.1.1

Listing 7.2 Initial filtering logic
private List<Account> accounts; #A
public AccountFinder(List<Account> accounts) {
        this.accounts = accounts;
}
 
public Optional<Account> account(Integer id) {
        return accounts.stream().filter(v -> v.getId().equals(id)).findAny();
}

The baseline uses a sequential stream and findAny() to search the account list. section 7.1.1

Listing 7.5 Viewing the performance benchmark output
CH05.premature.AccountsFinderPerformanceBenchmark.baseline avgt 10 0.027 ± 0.002 ms/op
CH05.premature.AccountsFinderPerformanceBenchmark.parallel avgt 10 0.030 ± 0.002 ms/op
 

In this benchmark, the baseline averaged 0.027 ms/op and the parallel version 0.030 ms/op. The result describes the measured workload, not every possible account search. section 7.1.1

AI-generated optimization deserves the same scrutiny. A request to make the account finder multithreaded produced several concurrent approaches and claims of performance gains. In a custom test with 10,000 accounts and 1,000 searches, the single-threaded approach took 25 ms, versus 63 ms for the parallel stream and substantially longer for the other concurrent approaches. Treat generated performance claims and tests as proposals to verify, not proof. section 7.1.2

Listing 7.7 The custom benchmark results
Single-threaded time: 25 ms
Parallel stream time: 63 ms
Concurrent time: 30398 ms
Optimized time: 406 ms

The custom test reports elapsed times for the single-threaded, parallel, concurrent, and optimized approaches. section 7.1.2

Use performance tests to validate service-level objectives under relevant operating conditions. Keep an optimization when measured benefits justify its complexity, and revisit the test as workload assumptions change. section 1.6 section 7.1

How Vibe Engineering covers it

How deep it goes
Compares sequential and concurrent implementations with benchmark results, while identifying workload uncertainty and production-scale risks.
Examples
Uses an account-by-ID search and an AI-generated multithreaded alternative to compare benchmark results.
What you can do after
Evaluate performance optimizations against measured workloads and their complexity costs.
How it connects
Connects performance to scalability, algorithmic complexity, concurrency, and service-level objectives.

Also explained in

Compare how 55 books explain performance →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Vibe Engineering. The section links point to the parts of the book it draws on.