liveBook · Manning

Throughput

As explained in JavaScript in Depth

The amount of useful data or work a system completes per unit of time.

Throughput measures how much useful work a system completes per unit of time. A pipeline can allocate fewer promises yet still require wall-clock measurement: allocation counts are structural, while throughput depends on the workload and runtime. section 10.6.3

Compare models under identical conditions: move the same 4 KB chunks through equivalent transforms and sinks, then report the ratio measured on one machine rather than an absolute expectation. Node.js streams, async iterables, and Web Streams differ in per-chunk allocation and buffering, which can affect performance under load. section 10.6.3 section 10.6.4

Interpret throughput together with the costs that can constrain it:

  • Measure wall-clock throughput separately from promise allocation; a 4 KB chunk allocates zero promises in the tested synchronous Node.js stream, eight through an async iterable, and twenty-seven through the tested Web Stream pipeline. section 10.6.3
  • Honor backpressure: keeping about one chunk in flight holds memory flat, while ignoring it lets queues grow and memory climb. section 10.6.3
  • Avoid repeated model conversion in hot paths; the measured throughput difference was roughly ten to fifteen percent, while extra allocations create garbage-collection pressure. section 10.6.4

A misleading performance signal

A pipeline can appear efficient because its allocation pattern is stable, yet perform poorly when conversion boundaries add buffers and backpressure propagation points. Diagnose the complete pattern—throughput, latency, memory, and garbage-collection behavior—rather than treating one metric as the explanation. section 10.6.4 section 11.0

Figure 10.8 Promises allocated per 4 KB chunk on Node.js v24. Node.js streams allocate none, paying their per-chunk cost in event dispatch instead; async iterables allocate eight; a Web Stream pipeline allocates twenty-seven. Exact counts vary by runtime, but the ordering holds.

Use the allocation comparison to contrast the per-chunk costs of Node.js streams, async iterables, and Web Stream pipelines. section 10.6.3

How JavaScript in Depth covers it

How deep it goes
Explains controlled measurement, allocation costs, backpressure, buffering, and conversion overhead without deriving a general performance model.
Examples
Compares 4 KB chunks across stream models and examines fast-producer, slow-consumer memory behavior and repeated stream conversion.
What it assumes
Assumes familiarity with streams and runtime behavior while distinguishing wall-clock measurements from structural allocation counts.
What you can do after
Diagnose performance bottlenecks by measuring comparable workloads and interpreting throughput with allocation, memory, latency, and garbage-collection signals.
How it connects
Connects throughput with backpressure, promises, async iterables, Web Streams, Node.js streams, buffering, garbage collection, and event loop utilization.

Also explained in

Compare how 32 books explain throughput →

Related concepts

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