Skip to content

mibz2 · Research blog

The decoder's true floor and the limits of a pooled scan

Zero-copy stand-ins drop mibz2's plumbing floor to 5 milliseconds and uncover hidden spelling and cache costs, while pooling the scan pays off only from slack.

mibz2 already decompresses at 4.31 GB/s on our eight-worker Wikidata benchmark, and almost none of the remaining cost is in the pipeline's plumbing. Queues, synchronisation and hand-offs account for only about 3% of the current 194.6 ms wall time when we isolate them with zero-copy stand-ins. Main-memory bandwidth is not yet the limiting factor on this machine, although L3 cache capacity matters. The implication is that the next substantial speedups must come primarily from making the algorithms themselves cheaper, rather than rearranging how they are coordinated.

This is the practical payoff of our hybrid-systems model and its design levers: distinguish the work done between events from the rules that move work between threads. Pooling the scan redistributes computation without eliminating it. The experiments instead expose a previously underestimated cost in spelling dictionary words into bytes, alongside opportunities to fuse construction and reduce cache traffic. The next milestone is to demonstrate a path towards 6 GB/s (about 140 ms for the same 838.8 MB of output, or 39% higher throughput). Supplying both scan and construction with idealised answers has already produced 135.3 ms, equivalent to 6.20 GB/s, but that is a diagnostic measurement, not a production speed or a promise that the target is attainable. The task now is to turn that measured headroom into real algorithmic gains.

In Complementary bottlenecks, we replaced each stage of mibz2's bzip2 decoder with a pre-recorded stand-in called an oracle. That factorial experiment showed where new algorithms could still speed up decoding. Its technical companion, From bottlenecks to better algorithms, turned those measurements into four candidate designs, including a pooled scan. Together, those two posts left two empirical questions open before any large redesign could start. First, how much of the earlier all-ideal floor belonged to mibz2's pipeline rather than to oracle copying? Second, would moving the serial Huffman scan into the worker pool unlock the 36% gain measured when scanning and construction improve together?

A short recap grounds both questions for a reader arriving cold. Decoding a bzip2 file moves each compressed block through six stages. One serial thread decodes Huffman symbols (S). A pool of parallel workers then undoes move-to-front coding and zero-run encoding (M) and builds the interval-exchange structures (C). Each worker walks those structures and expands their words into bytes (E, called emission in Open Returns), then finishes run-length expansion and checksums (R). Finally, an in-order reader copies completed blocks to the caller (D). As shown in The decoder as a queueing network, adding workers speeds decoding up until the bottleneck knee near 7.7 workers on earlier code. Below the knee, workers set the pace. At eight workers, where mibz2 ships on our 10-core Intel i9-10900K machine, the serial scanner and the workers are almost evenly matched.

Both open questions now have direct measurements on the same four-stream Wikidata file. That workload holds 47.4 MB compressed and expands to 838.8 MB uncompressed. Removing oracle copying and emission's leftover word expansion drops mibz2's all-ideal floor to roughly 5 ms at every worker count. It also refutes the suspected DRAM-bandwidth bottleneck between 8 and 10 workers, while revealing that 20 MiB L3 cache capacity does bind there. At the same time, it uncovers two large costs the first matrix could not see. Emission's word spelling is measured at 298 ms at 1 worker (an upper bound inflated by cold oracle reads; roughly 230 to 245 ms in situ). Real serial delivery starts near 29 ms on warm blocks, then climbs to 44–78 ms at 10 workers as unread blocks crowd the L3 cache. Testing the pooled scan behind ideal construction then ends in a narrow kill under its pre-registered gate. Pooling fails to remove scanning CPU; it merely moves that work onto workers that are already busy below nine threads.

This post reports both experiments and their consequences. Section 1 separates pipeline plumbing from oracle copying and settles the DRAM-bandwidth versus L3-capacity question. Section 2 measures each stage alone real and quantifies the newly exposed spelling, delivery and RLE1/CRC costs. Section 3 explains the prototype and why we tested it behind ideal construction. Section 4 presents every gate from the kill-test run. Section 5 derives the queueing arithmetic behind the 10-worker crossover and diagnoses cold-store bias in the paired-oracle test. Section 6 explains why the frozen verdict stands and sets out what we build next.

Takeaways

  • Pipeline plumbing is negligible. With zero-copy stand-ins replacing every stage and word spelling removed too, decoding takes 5.2 to 5.7 ms across every worker count. That is 2.7% of the shipped 194.6 ms wall at 8 workers. Queues, locks and hand-offs need no work.
  • DRAM bandwidth did not bind from 8 to 10 workers, though 20 MiB L3 capacity does. Removing 4.9 GB of oracle copying flattened the all-ideal wall with spelling kept to 42.4 ms at 8 workers and 40.5 ms at 10. Live memory traffic stayed at 13 to 17 GB/s. The earlier rise from 112 to 142 ms was a copying artifact; however, L3 capacity still binds at 8 to 10 workers for delivery and RLE1/CRC.
  • The serial scan caps worker-only gains at 8% at 8 workers, and two hidden costs scale in opposite directions beneath it. Keeping only the scan real takes 179.1 ms at 8 workers, or 92% of the shipped wall. Beneath it sits emission's parallel word spelling, measured at 298.2 ms at 1 worker (a cold-store upper bound; roughly 230 to 245 ms in situ) and shrinking to 37.2 ms at 8. Delivery's real serial copy-out goes the other way: traced at 29.1 ms at 1 worker and 34.0 ms at 8, it climbs to 43.7–77.9 ms at 10 workers as unread blocks evict L3.
  • The pooled scan missed its frozen gate narrowly, despite clean plumbing. All 10 exactness tests passed with zero dropped blocks and zero fallbacks. Peak memory stayed within 1.4% (passing K3), and the AVX2 marker finder took 4.82 ms at 9.84 GB/s (under half of K4's limit). Behind ideal construction, pooling captured 52% of the scan's room at 8 workers and 48% at 9. Its 95% confidence ceilings missed K1's half-capture bar by 0.009 and 0.042.
  • Pooling moves scanning CPU onto workers instead of removing it, so it wins only from slack. Pooled workers spent 173 to 193 ms scanning, matching the serial scanner's 171 to 190 ms. That extra load slowed standalone decoding below nine workers and broke even at 9 (1.000). Only at 10 workers, where shipped workers sat 20.2% idle, did pooling win (6.4% by geometric mean, P/none = 0.936; median wall fell 5.3% from 197.6 ms to 187.2 ms).

1. How much of the first matrix's floor was the decoder's?

In the first 44-arm matrix, making all six parts ideal left a steep residual wall. It took 391 ms at 1 worker and 94 ms at 6, then climbed from 112 ms at 8 to 142 ms at 10. Two artifacts contaminated those readings. First, the original oracles copied about 4.9 GB of pre-recorded answers into the decoder under global locks (Section 3 of the companion post). Second, the emission oracle skipped the graph walk yet left word-to-byte expansion running inside each worker. Because those costs were mixed together, the first matrix could not tell whether mibz2's pipeline plumbing was slow. It also could not tell whether main memory formed a third bottleneck above 8 workers.

To separate plumbing, copying and word spelling directly, we built zero-copy borrow oracles in PR #921. We then ran a 16-minute floor diagnostic, archived in PR #931 (the floor results). Instead of copying recorded buffers, each borrow oracle hands the next stage a borrowed slice. We also added a setting F (E_full) that skips word spelling alongside the graph walk.

The run executed 648 decodes on the i9-10900K at six worker counts (1 and 6 through 10). Each cell ran across 8 randomised blocks, with traces on the first 4 and the scanner pinned to CPU 6. Every validity check passed. Every decode produced byte-identical output, and the scanner pin held in all 216 pinned traces. Removed parts kept at most 0.15% of their real busy time, well under the 5% void threshold. No F arm called word spelling, and live memory-controller counters stayed active throughout.

Workers Residual A (SECMRD, spelling kept) Residual B (SFCMRD, plumbing alone) Spelling E_consume (A − B) Delivery on cold store (SFCMR − B)
1 303.9 [302.9, 305.0] ms 5.7 [5.5, 5.8] ms 298.2 [297.0, 299.4] ms 48.5 [46.8, 50.3] ms
6 54.0 [51.2, 56.7] ms 5.3 [5.3, 5.4] ms 48.7 [45.9, 51.4] ms 47.9 [47.1, 48.8] ms
7 46.7 [45.1, 48.2] ms 5.2 [4.9, 5.5] ms 41.5 [40.0, 43.0] ms 48.5 [47.7, 49.3] ms
8 42.4 [40.3, 44.4] ms 5.2 [5.0, 5.5] ms 37.2 [35.2, 39.1] ms 47.3 [46.4, 48.2] ms
9 42.9 [40.4, 45.3] ms 5.3 [5.1, 5.5] ms 37.6 [35.1, 40.1] ms 49.1 [48.0, 50.2] ms
10 40.5 [37.6, 43.5] ms 5.4 [5.3, 5.5] ms 35.2 [32.3, 38.0] ms 49.3 [46.8, 51.8] ms

Two results follow straight from that table. First, mibz2's pipeline plumbing is negligible. Arm SFCMRD leaves every stage free and skips word spelling, matching Residual B in the companion's accounting. Across all worker counts it takes just 5.2 to 5.7 ms. At 8 workers the block mean is 5.2 ms and the median is 5.3 ms. That is 2.7% of the shipped 194.6 ms wall. In SECMRD traces, worker handovers cost 0.96 ms per thread at 1 worker and 0.15 ms at 8. Both sit under half a percent of Residual A. The design analysis had forecast 14 to 19 ms at 1 worker. Measured at 5.7 ms, that prediction is scored a clean miss in the right direction, and plumbing is closed as a target.

Second, DRAM bandwidth did not bind between 8 and 10 workers, though 20 MiB L3 cache capacity does. Arm SECMRD removes oracle copying while keeping word spelling (Residual A). Its wall time falls from 54.0 ms at 6 workers to 46.7 ms at 7. From 8 to 10 workers it stays flat at 42.4 ms, 42.9 ms and 40.5 ms. Live hardware counters confirm why. Total memory traffic stays between 11.9 and 13.1 GB/s in SFCMRD. In SECMRD it stays between 15.2 and 16.6 GB/s across 8 to 10 workers. The shipped decoder draws 15.1 GB/s at 10 workers, far below DRAM saturation. The first matrix's climb from 112 to 142 ms was caused by the old copying oracles. Yet L3 capacity still tightens at 8 to 10 workers. When R (RLE1/CRC) runs real in SECMD, memory traffic climbs from 16.5 GB/s at 8 workers to 21.6 GB/s at 9 and 25.4 GB/s at 10. That extra traffic nudges SECMD's wall slightly upward (55.0 → 55.2 → 56.6 ms) while SECMRD stays flat (40.8, 42.4, 39.7 ms). That same L3 spill also slows real delivery copy-out, as Section 2 shows next.

Taring the scale: removing oracle copying exposes the 5 ms plumbing floor and each stage's isolated cost

A. Taring the 8-worker all-ideal floorRemoving 4.9 GB of oracle copies and word spelling (ms)050100150ms1st matrix all-idealcopying oracles + spellingFirst matrix all-ideal at 8 workers: 112 ms (includes ~4.9 GB oracle copying + word spelling)112 msZero-copy (SECMRD)Residual A, spelling keptResidual A (SECMRD, zero-copy) at 8 workers: 42.4 [40.3, 44.4] ms (15.2 GB/s)42.4 msWord spelling (A-B)E_consume (cold upper bound)Emission word spelling (E_consume = A - B) at 8 workers: 37.2 [35.2, 39.1] ms (88% of Residual A; cold-store upper bound)37.2 msPlumbing (SFCMRD)Residual B, all freeResidual B (SFCMRD, plumbing alone) at 8 workers: 5.2 [5.0, 5.5] ms (2.7% of shipped 194.6 ms)5.2 ms (2.7%)8 to 10 workers: the rising floor vanishedAll-ideal wall (ms); bars show 95% intervals0501001508W9W10WFirst matrix all-ideal at 8 workers: 112 ms (copying artifact)First matrix all-ideal at 10 workers: 142 ms (copying artifact)1st matrix112->142 msZero-copy SECMRD at 8 workers: 42.4 [40.3, 44.4] msZero-copy SECMRD at 9 workers: 42.9 [40.4, 45.3] msZero-copy SECMRD at 10 workers: 40.5 [37.6, 43.5] msZero-copy (A)42.4->40.5 ms15-17 GB/sZero-copy SFCMRD (plumbing) at 8 workers: 5.2 [5.0, 5.5] msZero-copy SFCMRD (plumbing) at 9 workers: 5.3 [5.1, 5.5] msZero-copy SFCMRD (plumbing) at 10 workers: 5.4 [5.3, 5.5] msPlumbing: 5.2-5.4B. One stage real, all else free (8 workers)Median wall time (ms) against shipped 194.6 ms050100150200msshipped 194.6 msScan (FCMRD)serial; 92% of wallScan alone real (FCMRD) at 8 workers: median 179.1 ms (92% of shipped 194.6 ms; caps worker-only gains at <=8%)179.1 msEmission (SCMRD)*walk + spelling; cold CEmission alone real (SCMRD, walk + spelling) at 8 workers: median 98.1 ms (overstated because walk A7 reads borrowed C store cold: 98.9 vs 72.4 ms/w)98.1 ms*Construction (SFMRD)parallel worker stageConstruction alone real (SFMRD) at 8 workers: median 83.6 ms (A7 is 0.0 ms here)83.6 msDelivery (D)†traced vs cold SFCMRDelivery real traced copy_out in none at 8 workers: 34.0 ms (dashed outline: 52.3 ms cold-store SFCMR wall artifact)Cold-store SFCMR wall at 8W: 52.3 ms (artifact of reading 209.7 MiB oracle store from DRAM)34.0 ms† (52.3 cold)MTF / RLE2 (SFCRD)parallel worker stageMTF/RLE2 alone real (SFCRD) at 8 workers: median 20.1 ms20.1 msRLE1 / CRC (wall diff)104 ms A9 worker CPURLE1/CRC at 8 workers: 14.2 ms wall difference (SECMD 55.0 minus SECMRD 40.8 ms), hiding 104.0 ms traced A9 worker CPU (7% of worker CPU)14.2 ms diffNothing (SFCMRD)plumbing alone (2.7%)All stages free (SFCMRD) at 8 workers: median 5.3 ms (mean 5.2 [5.0, 5.5] ms, 2.7% of shipped)5.3 ms*Walk (A7) reads borrowed C cold (98.9 vs 72.4 ms/w), overstating E.†Traced real copy_out is 34.0 ms at 8W; 52.3 ms is cold-store SFCMR.
Measured data (zero-copy floor run, i9-10900K, wikidata ×4; first-matrix baseline from the 44-arm run; traced delivery copy_out and A9 CPU from the pooled-scan traces). Visual analogy: taring a scale removes the shipping crates (4.9 GB of oracle copies and unremoved word spelling), revealing how light the tray itself is (5.2 ms) and how heavy each stage is alone. Where the analogy stops: pipeline stages overlap in time rather than summing like static weights (179 + 98 + 84 ms exceeds the 195 ms shipped wall), zero-copy borrowing leaves construction's store cache-cold for emission's walk, and traced delivery activity is not directly comparable to floor-arm wall differences.

2. What remains when one stage at a time is real?

Once the scale is tared down to 5.3 ms, enabling one real stage at a time exposes its isolated cost. The table below lists median wall times at 8 workers and 1 worker beside the shipped decoder. Where cold oracle stores or wall differences mask the live cost, traced real figures sit beside them.

Single real stage (all else free) Arm Median wall at 8 workers Median wall at 1 worker
Shipped decoder (all real) none 194.6 ms 1,342.7 ms
Scan FCMRD 179.1 ms (92% of wall) 169.7 ms
Emission (walk + spelling; cold-store caveat) SCMRD 98.1 ms 694.2 ms
Construction SFMRD 83.6 ms 609.5 ms
Delivery (cold oracle store) SFCMR 52.3 ms (34.0 ms traced) 54.7 ms (29.1 ms traced)
MTF / RLE2 SFCRD 20.1 ms 141.1 ms
RLE1 / CRC (wall difference) SECMD − SECMRD 14.2 ms (104.0 ms traced CPU) 65.8 ms
Nothing (plumbing alone) SFCMRD 5.3 ms (2.7% of wall) 5.8 ms

One caveat belongs right beside emission's row. Arm names list the ideal parts, so in construction's isolated arm (SFMRD), emission and its walk are free (A7 is 0.0 ms at every count). The cold reads happen in emission's isolated arm (SCMRD), where emission runs real against a zero-copy borrow of construction. In the shipped decoder, real construction warms its structures in the worker's caches right before emission walks them. In SCMRD, the walk (A7) reads construction's store cold from main memory. It takes 98.9 ms per worker at 8 workers against 72.4 ms as shipped, and 697.9 ms against 545.2 ms at 1 worker. Emission's isolated row (SCMRD) therefore overstates its standalone cost by roughly that warm-cache benefit. The serial scan's row (FCMRD) has no cross-stage cache distortion.

Four findings from this table and its companion traces reshape our priorities.

First, the serial scan imposes a hard ceiling at 8 workers. Running only the Huffman scan real (FCMRD) takes 179.1 ms at 8 workers. That is 92% of the shipped 194.6 ms wall. Even if every worker-side stage became free, 8-worker decoding could drop by at most 8% while scanning stays on one thread. This sharpens the first matrix's S × C result into a strict ordering rule. Worker-side optimisations cannot show their full gain at 8 workers until scanning leaves its serial station.

Second, emission's word spelling is a major hidden worker cost, though its oracle number is an upper bound. Subtracting Residual B from Residual A isolates E_consume, the loop that expands dictionary words into bytes. At 1 worker it measures 298.2 ms. It accounts for 98% of SECMRD at 1 worker and 87 to 90% from 6 workers up. The trace ledger matches directly at 299.7 ms for 1 worker and 39.8 ms per thread at 8 workers. Because workers run spelling in parallel, its wall time drops cleanly to 37.2 ms at 8 workers and 35.2 ms at 10. However, a cold-store check the same day (PR #952) showed that 298.2 ms is inflated by cold oracle reads. In SECMRD, workers spell from C's 120.6 MiB store and 425.1 MiB of recorded u32 codes. At 1 worker that reads 504.3 MiB from DRAM against 151.1 MiB for the entire shipped decode. In the first matrix's arm E, where construction is real and warm, consume_ns is already 41.5 ms lower (300.9 → 259.4 ms). Estimating across runs puts true in-situ spelling near 230 to 245 ms, or roughly 17 to 18% of the 1,342.7 ms 1-worker wall.

Third, delivery's real serial copy-out starts cheaper than the floor run suggested, then grows exactly as workers speed up. The floor run's flat 47.3 to 49.3 ms (SFCMR − SFCMRD) was a cold-store artifact corrected the same day (PR #952). There, the reader copied from the R oracle's 209.7 MiB store, over ten times the 20 MiB L3. Every worker count paid 5.1 million LLC load misses and 853.5 MiB of DRAM reads at roughly 17 GB/s. On real blocks in the pooled-scan bundle's traces (n = 3 per cell, ledgers on, medians), delivery behaves very differently. These are traced reader activity times rather than wall differences, so they are not directly comparable to the floor table's columns:

Workers Shipped none copy_out Fast workers PC / SC copy_out Ready-queue high-water (none / SC)
1 29.1 ms — 0.9 MiB / —
6 27.6 ms 29.8 / 29.0 ms 5.1 / 6.0 MiB
7 30.6 ms 33.7 / 32.5 ms 5.2 / 7.7 MiB
8 34.0 ms 40.0 / 39.5 ms 6.9 / 8.6 MiB
9 43.2 ms 51.5 / 54.9 ms 12.0 / 10.3 MiB
10 43.7 ms 67.4 / 77.9 ms 14.6 / 16.3 MiB

Delivery is cheap while workers are slow, and gets dearer precisely as they speed up. At 9 to 10 workers, the ready queue (READY_BYTES = 12 MiB) holds 12 to 16.3 MiB of unread blocks inside a 20 MiB L3. Those ready blocks spill to DRAM, where the single reader then competes with all ten workers.

Fourth, RLE1/CRC's modest wall difference hides a growing worker cost. Subtracting SECMRD from SECMD gives 14.2 ms at 8 workers and 65.8 ms at 1 worker as wall differences. In the pooled-scan traces, however, RLE1/CRC (A9) spends 104.0 ms of worker CPU at 8 workers in none, or 7% of worker CPU. At 10 workers that climbs to 133.0 ms in none, and to 191–216 ms in PC and SC. Whenever a block expands during run-length decoding, unrle_in_place runs four full-buffer passes, including two full writes. Under 8 to 10 workers, those writes spill dirty lines out of the 20 MiB L3 alongside ready blocks.

Word spelling drains with workers while real delivery copy-out climbs under L3 pressure

Word spelling drains with workers while delivery copy-out rises under L3 pressureFloor wall times (ms, 95% intervals) beside traced reader copy_out (pooled-scan medians) on wikidata x4050100150200250300ms1W6W7W8W9W10WWorker threads (break between 1 and 6 workers)Scan alone real (FCMRD) at 1W: median 169.7 msScan alone real (FCMRD) at 6W: median 177.0 msScan alone real (FCMRD) at 7W: median 177.8 msScan alone real (FCMRD) at 8W: median 179.1 msScan alone real (FCMRD) at 9W: median 177.6 msScan alone real (FCMRD) at 10W: median 178.7 ms169.7 ms179.1 msEmission word spelling (E_consume = A - B) at 1W: 298.2 [297.0, 299.4] ms (cold-store upper bound)Emission word spelling (E_consume = A - B) at 6W: 48.7 [45.9, 51.4] ms (cold-store upper bound)Emission word spelling (E_consume = A - B) at 7W: 41.5 [40.0, 43.0] ms (cold-store upper bound)Emission word spelling (E_consume = A - B) at 8W: 37.2 [35.2, 39.1] ms (cold-store upper bound)Emission word spelling (E_consume = A - B) at 9W: 37.6 [35.1, 40.1] ms (cold-store upper bound)Emission word spelling (E_consume = A - B) at 10W: 35.2 [32.3, 38.0] ms (cold-store upper bound)298.2 ms (cold upper bound; ~230-245 in situ)37.2 msTraced delivery copy_out in SC (fast workers) at 6W: median 29.0 ms (reader activity time)Traced delivery copy_out in SC (fast workers) at 7W: median 32.5 ms (reader activity time)Traced delivery copy_out in SC (fast workers) at 8W: median 39.5 ms (reader activity time)Traced delivery copy_out in SC (fast workers) at 9W: median 54.9 ms (reader activity time)Traced delivery copy_out in SC (fast workers) at 10W: median 77.9 ms (reader activity time)Traced delivery copy_out in none (shipped) at 1W: median 29.1 ms (reader activity time)Traced delivery copy_out in none (shipped) at 6W: median 27.6 ms (reader activity time)Traced delivery copy_out in none (shipped) at 7W: median 30.6 ms (reader activity time)Traced delivery copy_out in none (shipped) at 8W: median 34.0 ms (reader activity time)Traced delivery copy_out in none (shipped) at 9W: median 43.2 ms (reader activity time)Traced delivery copy_out in none (shipped) at 10W: median 43.7 ms (reader activity time)29.1 msPipeline plumbing (SFCMRD) at 1W: 5.7 [5.5, 5.8] msPipeline plumbing (SFCMRD) at 6W: 5.3 [5.3, 5.4] msPipeline plumbing (SFCMRD) at 7W: 5.2 [4.9, 5.5] msPipeline plumbing (SFCMRD) at 8W: 5.2 [5.0, 5.5] msPipeline plumbing (SFCMRD) at 9W: 5.3 [5.1, 5.5] msPipeline plumbing (SFCMRD) at 10W: 5.4 [5.3, 5.5] msSerial scan (FCMRD)170-179 ms (wall)Delivery copy_out (SC)29 -> 78 ms (traced)Delivery copy_out (none)29 -> 44 ms (traced)Word spelling (E_consume)298 -> 35 ms (wall diff)Plumbing: 5.2-5.7 msAt 8-10W, 20 MiB L3 eviction pushesreal delivery copy_out above spelling
Measured wall times and wall differences from the zero-copy floor run (FCMRD medians; 95% intervals on E_consume and plumbing) alongside traced Reader::copy_out activity times from the pooled-scan traces (n = 3 medians for none and SC; activity times are not directly comparable to wall differences). Visual analogy: adding workers drains the parallel word-spelling reservoir down past the 179 ms scan reef toward the 5 ms riverbed, while L3 cache eviction raises delivery's tide from below once 8 to 10 workers outpace the reader. Where the analogy stops: single-thread scan time rises slightly from 169.7 ms at 1 worker to 179.1 ms at 8, partly from lower all-core turbo (5.06 to 4.96 GHz) and the rest unmeasured, and delivery overlaps with worker execution until workers finish faster than the reader can copy out.

3. Designing a pooled scan and testing a masked stage

With the floor settled and the 179.1 ms serial scan confirmed at 8 workers, our first build target was clear. We set out to dissolve the serial scanner into the worker pool, as sketched in Section 9 of the companion post. Before writing code, we audited three earlier parallel-scan attempts recorded in the registration (§2). The first (bench-par-scan, 10 November) proved SIMD marker finding nearly free at 9.3 GB/s, or 0.19% of decode. On 10-worker level-9 Wikidata it stalled at 0.981 while workers were still slower than the scanner. The second (PR #741) beat shipped speed at 8 and 10 workers (0.935 and 0.883), yet slowed two to six workers (1.11–1.13). Its peak RSS also climbed to 1.28× at 10 workers and 1.99× at 20, probably from buffering the full input and holding \(4 \times \text{threads}\) blocks in flight. The third (PR #770) bounded memory with a lead scanner and two helpers, but serialised them behind one chain head. That nearly doubled scan CPU, slowed 8 to 20 workers by 54 to 61% (1.605× at 8 workers), and left workers roughly 40% idle.

Our new prototype (PR #932) avoided all three traps. As compressed chunks arrive, the feeder thread runs an AVX2 nibble filter to locate candidate block markers in bounded memory. No scanner thread, helper scanner or joiner thread exists. Each worker claims one candidate inside the shipped admission window and runs scan · M · C · E · R end to end. That eliminates the 190.6 MiB symbol queue between scanner and workers. The in-order reader accepts whichever ready block starts at the chain's exact next bit offset. On any false or missed marker, the reader falls back serially so exact bytes and exact errors always hold. At 1 worker, the prototype keeps the shipped path unchanged.

Testing this prototype fairly meant avoiding a measurement trap explained in Masked bottlenecks in a two-stage decoder. The design analysis had proposed killing any pooled scan that failed to beat shipped 8-worker decoding by 7% standalone. That test was impossible by construction. Even an ideal zero-cost scanner saves only 3.2% alone at 8 workers, because construction still limits the workers.

Instead, we froze a paired-oracle kill test in the registration before writing any code (also discussed in Dropping the coordinator). We paired the pooled scan P with construction's zero-copy oracle C, giving arm PC. We then compared PC/C against an ideal zero-copy scan behind C (SC/C). On a log scale, this asks whether pooling captures at least half of the multiplicative speedup that an ideal scan achieves once construction is free:

\[ \text{capture} = \frac{\ln(C / PC)}{\ln(C / SC)}, \qquad \text{K1 kills if } \text{UB}_{95\%}\!\left(\frac{PC}{C}\right) > \sqrt{\frac{SC}{C}}. \]

Three companion gates guarded against earlier failure modes:

  • K2 (standalone cost). Kill if the 95% confidence floor of P/none exceeds 1.03 at a judged count.
  • K3 (memory). Kill if median peak RSS of P/none exceeds 1.10 at any count from 6 to 10.
  • K4 (finder speed). Kill if the single-threaded finder takes over 10 ms on the 47.4 MB input.

Section 1's floor run automatically set two switches in the registration before any prototype code ran. Because Residual A stayed flat from 8 to 10 workers, both 8 and 9 became judged counts. Both had to pass K1 and K2. Because Residual B was 2.7% (under 10%), capture remained capped rather than treating plumbing removal as extra scan capture.

4. The kill test's verdict: KILL, narrowly, on K1

The kill test ran 480 decodes across 12 randomised blocks on the i9-10900K in 15 minutes (the pooled-scan results). The first 3 blocks were traced unpinned, and an 11-pass pinned benchmark timed the finder alone. Every validity check passed. All 10 exactness tests passed on the test machine. Every pooled decode at 2 or more workers was wholly pooled, with zero dropped blocks, zero fallbacks and zero degraded decodes.

Every resource and plumbing gate passed as well. Peak memory stayed within 1.4% of shipped across 6 to 10 workers (0.988 to 1.014), passing K3 cleanly. On CPU 4, the AVX2 marker finder scanned the 47.4 MB input in a median 4.82 ms (interval [4.81, 5.00] ms). It processed 9.842 GB/s and located all 1,724 block markers plus 48 stream-end markers, under half of K4's 10 ms limit. Standalone cost passed K2 at both judged counts. At 8 workers P/none was 1.052, yet its 95% confidence floor (1.023) remained under 1.03. At 9 workers P/none hit exact break-even (1.000). In traces, candidate copying moved 45.2 MiB in 4.32 to 7.24 ms against a ~5 ms estimate. In-decode marker finding took 4.97 to 7.35 ms. The 190.6 MiB symbol queue disappeared, and at 8 to 10 workers the worker idle share (job_wait / life) fell from 6.5–20.2% in none down to 1.2–2.5% in P.

Yet K1 fired at both judged counts, killing the prototype narrowly under the frozen rule.

Workers Status PC/C [95% CI] Bar \(\sqrt{SC/C}\) Ideal SC/C Capture Standalone P/none [95% CI]
6 reported 1.065 [1.040, 1.090] 0.940 0.884 −0.51 1.105 [1.094, 1.115]
7 reported 0.935 [0.922, 0.948] 0.891 0.794 0.29 1.100 [1.087, 1.114]
8 judged (K1) 0.862 [0.848, 0.876] 0.867 0.752 0.52 1.052 [1.023, 1.081]
9 judged (K1) 0.869 [0.833, 0.906] 0.864 0.746 0.48 1.000 [0.983, 1.017]
10 reported 0.848 [0.825, 0.873] 0.877 0.769 0.63 0.936 [0.909, 0.964]

The margin was tight. Behind ideal construction at 8 workers, pooling cut median wall time from 183.2 ms down to 158.1 ms, against 135.3 ms for an ideal scan. Its point estimate captured 52.1% of the scan's room. Even so, its 95% ceiling (0.8758) sat 0.009 above the 0.8670 bar. At 9 workers (C = 184.2 ms, PC = 159.9 ms, SC = 140.2 ms), capture fell to 48.1%. Its ceiling (0.9058) missed the 0.8636 bar by 0.042. Only at 10 workers did pooling clear the bar cleanly. There it achieved 62.7% capture behind C and a 6.4% standalone win by geometric mean (P/none = 0.9357; median wall fell 5.3% from 197.6 ms to 187.2 ms).

Standalone walls also missed the companion post's unscored forecast. The design analysis had projected 172 to 175 ms at eight and nine workers. Measured block means were 207.5 ms at 8 workers (206.5 to 208.6 ms) and 195.2 ms at 9 workers (192.3 to 198.1 ms).

The pooled-scan kill test: paired-oracle capture (K1) and standalone crossover (K2)

A. Paired-oracle test behind ideal C (K1)Ratio PC/C (95% CI) vs K1 bar sqrt(SC/C) and ideal SC/C0.750.850.951.001.05B. Standalone wall ratio P/none (K2)Ratio P/none (95% CI); K2 kills if LB > 1.03 at 8 or 90.900.951.00K2 1.031.051.106 workersreported6W ideal scan behind C (SC/C): 0.88366W K1 bar sqrt(SC/C): 0.94006W PC/C: 1.0646 [1.0401, 1.0898] vs bar 0.9400 (capture -0.51)cap -0.516W6W standalone P/none: 1.1045 [1.0942, 1.1148]1.1057 workersreported7W ideal scan behind C (SC/C): 0.79427W K1 bar sqrt(SC/C): 0.89127W PC/C: 0.9351 [0.9221, 0.9484] vs bar 0.8912 (capture +0.29)cap +0.297W7W standalone P/none: 1.1004 [1.0871, 1.1140]1.1008 workersjudged8W ideal scan behind C (SC/C): 0.75168W K1 bar sqrt(SC/C): 0.86708W PC/C: 0.8618 [0.8481, 0.8758] vs bar 0.8670 (capture +0.52)cap 0.52UB +0.009 (K1)8W8W standalone P/none: 1.0519 [1.0233, 1.0812]1.052 (K2 ok)9 workersjudged9W ideal scan behind C (SC/C): 0.74599W K1 bar sqrt(SC/C): 0.86369W PC/C: 0.8685 [0.8328, 0.9058] vs bar 0.8636 (capture +0.48)cap 0.48UB +0.042 (K1)9W9W standalone P/none: 0.9999 [0.9832, 1.0170]1.000 (even)10 workersreported10W ideal scan behind C (SC/C): 0.769410W K1 bar sqrt(SC/C): 0.877210W PC/C: 0.8484 [0.8249, 0.8725] vs bar 0.8772 (capture +0.63)cap +0.6310W10W standalone P/none: 0.9357 [0.9086, 0.9637]0.936 (-6.4%)SC/C (ideal scan)K1 bar sqrt(SC/C)PC/C (95% CI)Passing gates: K2 standalone LB <= 1.03 (1.023 at 8W) · K3 peak RSS 0.988-1.014 (<= 1.10) · K4 finder 4.82 ms / 9.84 GB/s (<= 10 ms) · 0 fallbacks
Measured data (pooled-scan kill test, i9-10900K, wikidata ×4, 12 randomised blocks). Shaded rows mark the two pre-registered judged counts (8 and 9 workers); unshaded rows (6, 7, 10) are reported only. Left: PC/C ratios and 95% intervals against the ideal-scan floor SC/C (hollow diamonds) and K1 threshold sqrt(SC/C) (amber bars). Right: standalone P/none ratios against break-even (1.00) and K2's 1.03 lower-bound gate.

5. Why pooling was not enough

At first glance, missing K1 by 0.009 at 8 workers looks like noise or a small implementation tax. The per-thread traces show a much clearer picture. Pooling worked as engineered, with zero duplicated work, tiny worker idleness and roughly 5 ms of chain overhead. Two effects explain the results in Section 4: a conservation law on CPU time drives the standalone crossover, while an asymmetric cold-store bias distorted the paired-oracle capture denominator.

In traced decodes, the workers' summed scanning CPU (A2 + A3) in P matched the dedicated scanner's CPU in none at every worker count:

Workers Pooled workers' scan CPU (P) Dedicated scanner CPU (none) Worker idle share (none → P)
6 172.9 [172.2, 173.6] ms 171.3 [170.2, 172.3] ms 1.4% → 0.9%
7 174.1 [172.5, 175.7] ms 170.6 [170.3, 171.0] ms 1.9% → 1.2%
8 177.7 [175.1, 180.3] ms 177.5 [148.2, 206.8] ms 6.5% → 1.2%
9 182.8 [171.9, 193.8] ms 173.4 [160.6, 186.3] ms 10.1% → 1.6%
10 192.7 [181.9, 203.6] ms 189.6 [184.1, 195.2] ms 20.2% → 2.5%

Unlike PR #770, which nearly doubled scanning CPU, this prototype wasted nothing. It simply moved roughly 178 ms of scanning CPU off the dedicated scanner core and spread it across the \(k\) worker cores.

That move turns the two-station bottleneck model from Section 9 of the companion post into a sharp wall-time comparison. Let \(s\) denote total scanning CPU per decode and \(w\) denote total parallel worker CPU. Let \(\epsilon\) denote the small residual from marker finding, candidate copying and tail imbalance:

\[ T_{\text{serial}}(k) \approx \max\!\left(s,\ \frac{w}{k}\right), \qquad T_{\text{pooled}}(k) \approx \frac{s + w}{k} + \epsilon. \]

The model's first-order arithmetic accounts for the direction and the crossover. It is only a first-order guide, because \(w\) itself grows with \(k\). In none, total CPU climbs from 1.714 s at 8 workers to 2.007 s at 10. Likewise, S's wall implies \(w\) rising from roughly 1,480 ms at 8 workers to 1,700 ms at 10. Part of that climb is RLE1/CRC (A9) under L3 pressure. Its traced CPU in none rises from 89.5 ms at 6 workers to 104.0 ms at 8 and 133.0 ms at 10. Holding \(w\) constant therefore overpredicts the 10-worker gain.

Below the knee (\(w/k \ge s\)), pooling must lose. Workers already set the wall clock. Adding \(s/k\) of scanning to each worker lengthens the decode by 22 to 30 ms. Deleting the 190.6 MiB symbol queue cannot offset that, because Section 1 proved that all inter-stage plumbing costs only ~5 ms. In this run, the S arm (ideal scan, real workers) took 184.9 ms at 8 workers against \(s \approx 178\text{ ms}\). Workers therefore still bind at 8 workers here. Adding \(s/8\) onto that 184.9 ms worker load gives about 207 ms, matching the measured 207.5 ms mean. Standalone P slowed 6 and 7 workers by 10% and slowed 8 workers by 5.2%.

Above the knee (\(w/k < s\)), pooling wins only when workers have slack to absorb \(s/k\). Setting \((s + w)/k < s\) yields the zero-overhead break-even point:

\[ k > 1 + \frac{w}{s}. \]

From this run's S arm at 8 workers (\(w/8 \approx 184.9\text{ ms}\) against \(s \approx 178\text{ ms}\)), the knee sits at \(w/s \approx 8.3\). That puts zero-overhead break-even near \(k \approx 9.3\). The earlier 25 November queueing post measured \(w/s \approx 7.67\) on older code, putting break-even near 8.7. Both agree within a worker: pooling loses at 8 workers and breaks even near 9, where P/none measured 1.000. At \(k = 10\), shipped workers sat 20.2% idle waiting on the serial scanner. Absorbing \(192.7 / 10 \approx 19.3\text{ ms}\) of scanning per worker fit inside that slack. Worker idleness fell to 2.5%, delivering a 6.4% win by geometric mean (P/none = 0.9357). Median wall time fell 5.3% from 197.6 ms to 187.2 ms.

Behind ideal construction, \(s/k\) explains the PC − SC gap, while a cold-store bias depressed capture. Making construction ideal (C) shrinks \(w\) enough that PC beats C by 14% at 8 workers. An ideal scan (SC) deletes scanning CPU completely, whereas a pooled scan still pays \(s/k\). At 8 workers, adding \(177.7 / 8 = 22.2\text{ ms}\) to SC's 135.3 ms predicts 157.5 ms against a measured PC of 158.1 ms. At 9 workers, adding \(182.8 / 9 = 20.3\text{ ms}\) to SC's 140.2 ms predicts 160.5 ms against PC at 159.9 ms. Both PC and SC pay that difference cleanly. Yet the ~50% capture figure itself was depressed by an asymmetric cold-store bias uncovered in PR #952. Zero-copy C forces the emission walk (A7) to read construction's store cold in every C arm. At 8 workers, traced A7 rose by +220.4 ms (PC − P) and +196.2 ms (SC − S). At 9 workers those jumps reached +293.9 ms and +257.7 ms. PC and SC are worker-bound (job_wait just 3.6 and 0.2 ms per worker at 8), so their walls pay that entire bloat. C alone is scanner-bound (job_wait 50.6 ms per worker at 8 and 91.8 ms at 9), so its wall absorbs the bloat completely. That asymmetry shrinks the C − SC denominator that capture divides by. Subtracting the traced bloat shifts 8-worker capture from 0.52 to roughly 0.73. That diagnostic bound shows pooling is not structurally capped near 50%, though it is not a re-grade of K1.

Moving work vs. stealing slack: dedicated scanner, full pool, and slack-only hybrid

Moving work vs. stealing slack: why pooling loses at 8 workers and wins at 10Per-decode wall-time budgets (ms) from pooled-scan medians and traces; workers spend the same 173-193 ms scanningAt 8 workers (balanced knee: dedicated scanner 177.5 ms, workers ~185 ms, only 6.5% idle)Shipped (none)1 scanner + 8 workersShipped 8W workers busy: ~180 ms; worker idle share 6.5%6.5% worker idle share waiting on serial scanner (none, 8W)workers: M · C · E · R (in parallel with 177.5 ms serial scan)192.9 msFull pool (P)8 workers absorb s/8Worker M, C, E, R share at 8 workersScan CPU moved onto 8 workers: 177.7 / 8 = 22.2 ms per workerFinder/copy/tail overhead (~5-6 ms)workers: M · C · E · R+s/8207.7 ms (1.052 gm)Behind ideal CSC vs PC (+s/8 gap)SC (ideal scan + ideal C) at 8 workers: median 135.3 msPC minus SC at 8 workers: 158.1 - 135.3 = 22.8 ms (matches s/8 = 177.7/8 = 22.2 ms; raw capture 0.52, diagnostic ~0.73 after cold-store A7 adjustment)SC ideal: 135.3 ms+22.8PC 158.1 ms (0.52 raw cap)At 10 workers (20.2% worker slack) — and the slack-only hybrid for all counts0 ms50 ms100 ms150 ms200 msShipped (none)10W sit 20.2% idleShipped 10W workers busy (~79.8% of 197.6 ms wall)20.2% worker idle share waiting on 189.6 ms serial scanner (none, 10W)10 workers busy (79.8%)20.2% idle197.6 msFull pool (P)scan fits inside slackWorker M, C, E, R share at 10 workersScan CPU moved onto 10 workers: 192.7 / 10 = 19.3 ms per workerFinder/copy/idle residual (2.5% idle; median 187.2 ms vs 197.6 ms, -5.3%; P/none geometric mean 0.936, -6.4%)10 workers: M · C · E · R+s/10187.2 ms (0.936 gm)Hybrid (proposed)design, not measuredProposed slack-only hybrid: keep dedicated scanner; workers scan ahead only from idle job_wait slackkeep serial scanner; idle workers scan ahead only when waitingno <=8W tax
Measured budgets at 8 and 10 workers (pooled-scan timed medians and traces; gm denotes per-block geometric-mean P/none ratios) beside the proposed slack-only hybrid (design, not measured). Visual analogy: a kitchen with one prep cook (S) and k line cooks (W). Dismissing the prep cook and splitting prep across the line cooks cuts waiting between courses (idle time at 8 to 10 workers falls from 6.5–20.2% to 1.2–2.5%), yet slows service whenever the line cooks are already flat out (k ≤ 8); service speeds up only when line cooks are waiting for prep (k = 10), or when only idle cooks step in to help (the hybrid). Where the analogy stops: CPU cores share a 20 MiB L3 cache, pay ~5 ms each for boundary finding and candidate copying, and still commit finished blocks strictly in order.

6. Keeping the verdict and what comes next

Even knowing that cold-store C biased K1 downward, honouring the frozen KILL verdict is both sound method and the right engineering decision.

Even setting K1 aside, standalone P/none measured 1.052 at 8 workers. Shipping the prototype behind an 8-worker flag would therefore ship a 5% slowdown where mibz2 defaults. Dissolving the dedicated scanner forces \(k\) workers to absorb \(s\) on top of \(w\), which taxes any worker count without slack. The same rule governs any streaming pipeline with a dedicated serial parser costing \(s\) and a worker pool costing \(w\). Removing the parser breaks even at \(k^* = 1 + w/s\) before overhead. It loses whenever \(k < 1 + w/s\) and wins only when \(k > 1 + w/s\). To win on both sides of the knee, a pipeline has two clean options. It can shrink \(w\) until \(1 + w/s\) drops below the target worker count. Alternatively, it can keep the dedicated parser alive and let workers help only from idle slack. There is also a clear experimental lesson for future gates. A paired-oracle kill test must not set a worker-bound candidate against a scanner-bound cold-store baseline, or asymmetric cache bloat will bias capture against the candidate.

Together, the zero-copy floor run, the pooled-scan kill test and the cold-store analysis close three blind alleys and lay out a clear order for our next work:

  • Closed targets. Pipeline plumbing (~5 ms, 2.7% of wall) needs no attention. The three-station DRAM-bandwidth hypothesis is not supported at 8–10 workers, though 20 MiB L3 capacity does bind for delivery and RLE1/CRC. Unconditional full pooling stops as built under its frozen K1 verdict.
  • Shrink worker demand \(w\) first. Lowering worker CPU speeds up 1–7 workers at once and pulls \(1 + w/s\) below 8 workers so scanning relief pays off where mibz2 ships. Four worker-side targets are open. Emission's word spelling (~230–245 ms estimated in situ) leads the list; its parts have since been measured by the spelling census (PR #951) and the Rauzy output census (PR #958). Beside it sit folding move-to-front into construction's first pass and forward wiring with multi-lane emission. The fourth target is single-pass RLE1/CRC to end unrle_in_place's four-pass L3 spill (104 ms of traced CPU at 8 workers).
  • Test a slack-only hybrid scanner under a warm paired baseline. Keep the dedicated scanner thread so saturated workers at six to eight cores never pay a scanning tax. Let workers claim look-ahead candidates with the proven 4.82 ms AVX2 marker finder only when they would otherwise wait in job_wait. Scanning CPU is then spent strictly from slack. Full pooling can also be re-tested under a fresh registration once worker-side cuts lower \(w\) and a warm baseline removes cold-store bias.
  • Contain L3 eviction in delivery and consider exposing zero-copy lending. Real delivery copy-out already climbs from 34.0 ms at 8 workers to 67.4–77.9 ms at 10 when faster workers pile 12–16 MiB of ready blocks into the 20 MiB L3. Zero-copy block lending already exists internally at StreamDecoder::read_block (src/parallel.rs:880, #[doc(hidden)]) and publicly through BzReader's BufRead (characterised in PR #966). The immediate no-API lever is tightening the READY_BYTES working-set cap so ready blocks stay L3-hot. Exposing read_block publicly remains an open API decision beside it.

Sources: