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
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
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:
Three companion gates guarded against earlier failure modes:
- K2 (standalone cost). Kill if the 95% confidence floor of
P/noneexceeds1.03at a judged count. - K3 (memory). Kill if median peak RSS of
P/noneexceeds1.10at any count from 6 to 10. - K4 (finder speed). Kill if the single-threaded finder takes over
10 mson 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)
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:
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:
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
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 throughBzReader'sBufRead(characterised in PR #966). The immediate no-API lever is tightening theREADY_BYTESworking-set cap so ready blocks stay L3-hot. Exposingread_blockpublicly remains an open API decision beside it.
Sources:
- Zero-copy floor (PR #921, PR #931): floor results, report and raw table.
- Pooled-scan kill test (PR #932, PR #942): registration, results and report.
- Cold-store and L3 analysis (PR #952, PR #954, PR #966): cold-store and RLE1 LLC report, delivery characterisation, spelling census and Rauzy output census.
- Earlier parallel scans: PR #741 and PR #770, summarised in the registration.
- Preceding posts: Complementary bottlenecks and From bottlenecks to better algorithms.
- Earlier decoder posts: The decoder as a queueing network, Masked bottlenecks, Open Returns and Huffman decoding.
- Reproducible figures and measured surface: figures_floor_and_pooled_scan.py, surface.tsv and dead-ends.tsv.