liveBook · Manning

Work elimination

As explained in Latency

A technique that avoids unnecessary computation, data movement, or other processing to reduce execution effort and delay.

Work elimination avoids unnecessary computation, data movement, and processing to reduce latency. The fastest code is code that does not execute, but hidden work from language runtimes and operating systems must also be considered. section 7.0

Apply work elimination across the layers that contribute most to execution time:

  • Choose algorithms and data structures with low algorithmic complexity; quadratic time can become costly as input grows, while linear or better complexity is often preferable. section 7.8
  • Reduce serialization and deserialization, especially repeated JSON conversion; Protocol Buffers and FlatBuffers can lower CPU and memory overhead. section 7.8
  • Limit memory-management work through static allocation or object pooling, while accounting for allocation, garbage collection, virtual memory, and physical memory effects. section 7.1 section 7.8
  • Mitigate operating-system overhead from scheduling, context switches, background tasks, and network-stack management; some systems allocate resources or bypass the OS. section 7.8
  • Precompute results before they are needed, using materialized database views when the added storage cost is acceptable. section 7.8

Measure before removing work

Iteratively benchmark and profile the application, identify bottlenecks in application logic, serialization, or deserialization, and then optimize the measured source of latency. Avoid introducing redundant work while writing new code. section 7.1 section 7.8

How Latency covers it

How deep it goes
Explains optimization categories, measurement workflow, and trade-offs, but does not provide detailed implementation procedures for each technique.
Examples
Uses JSON, Protocol Buffers, FlatBuffers, object pooling, static allocation, materialized views, profiling, and benchmarks as concrete examples.
What it assumes
Assumes application code and performance measurement, while requiring awareness of runtime, memory, and operating-system work.
What you can do after
Diagnose/debug with it by measuring latency, locating redundant work, and selecting lower-cost algorithms, representations, allocations, or execution paths.
How it connects
Connects algorithmic complexity, serialization, memory management, garbage collection, virtual memory, operating-system overhead, precomputation, and materialized views.

Related concepts

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