Your browser sucks, JavaScript disabled! Gunnar's console needs JavaScript and WebAssembly. Git over SSH on port 2222 does not.

nordisk/znippy-zoomies

.nornir/assets/lbunzip2_flow.svg

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1180 620" font-family="'DejaVu Sans', 'Segoe UI', sans-serif">
  <defs>
    <linearGradient id="board" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#0b1c2e"/><stop offset="1" stop-color="#06111d"/></linearGradient>
    <linearGradient id="chip" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#14384f"/><stop offset="1" stop-color="#0e2a3e"/></linearGradient>
    <linearGradient id="rail" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#173d57"/><stop offset="1" stop-color="#0c2438"/></linearGradient>
    <linearGradient id="slot" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#123448"/><stop offset="1" stop-color="#0a2032"/></linearGradient>
    <marker id="ah" viewBox="0 0 10 10" refX="8" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path d="M0 0 L10 5 L0 10 z" fill="#6fd3f5"/></marker>
  </defs>

  <rect x="0" y="0" width="1180" height="620" fill="url(#board)"/>
  <g stroke="#143a52" stroke-width="1"><line x1="0" y1="74" x2="1180" y2="74"/><line x1="0" y1="576" x2="1180" y2="576"/></g>
  <g fill="#16415c"><circle cx="40" cy="38" r="2"/><circle cx="1140" cy="38" r="2"/></g>

  <text x="40" y="42" fill="#eaf6ff" font-size="22" font-weight="700">lbunzip2</text>
  <text x="176" y="42" fill="#9fc9e0" font-size="15">bzip2 CLI — streaming producer: read+carry → block-boundary split → self-dispatch BWT workers → ordered write (<tspan fill="#bfe6ff" font-weight="700">~7.8–11.5/12</tspan>)</text>

  <g font-size="12"><line x1="820" y1="60" x2="860" y2="60" stroke="#6fd3f5" stroke-width="3" marker-end="url(#ah)"/><text x="866" y="64" fill="#cfe6f5">parallel dataflow</text></g>

  <!-- INPUT -->
  <rect x="34" y="236" width="140" height="150" rx="10" fill="url(#chip)" stroke="#5aa6cf" stroke-width="2"/>
  <text x="104" y="262" fill="#eaf6ff" font-size="14" font-weight="700" text-anchor="middle">.bz2 input</text>
  <rect x="50" y="286" width="108" height="26" rx="5" fill="url(#slot)" stroke="#6fd3f5" stroke-width="1.4"/>
  <text x="104" y="303" fill="#bfe6ff" font-size="9" text-anchor="middle" font-family="'DejaVu Sans Mono',monospace">BZh[1-9] header</text>
  <rect x="50" y="318" width="108" height="26" rx="5" fill="url(#slot)" stroke="#6fd3f5" stroke-width="1.4"/>
  <text x="104" y="335" fill="#bfe6ff" font-size="9" text-anchor="middle" font-family="'DejaVu Sans Mono',monospace">BufReader 4 MB</text>
  <text x="104" y="362" fill="#7fa8c4" font-size="9" text-anchor="middle">bin/lbunzip2.rs:main</text>

  <!-- PRODUCER -->
  <rect x="212" y="150" width="212" height="322" rx="12" fill="url(#rail)" stroke="#7fc8ea" stroke-width="2.5"/>
  <text x="318" y="174" fill="#eaf6ff" font-size="14" font-weight="700" text-anchor="middle">producer (1 dispatch thread)</text>
  <text x="318" y="191" fill="#9fc9e0" font-size="10" text-anchor="middle">I/O overlaps decode</text>
  <rect x="230" y="204" width="176" height="30" rx="5" fill="url(#slot)" stroke="#6fd3f5" stroke-width="1.4"/>
  <text x="318" y="218" fill="#bfe6ff" font-size="9.2" text-anchor="middle" font-family="'DejaVu Sans Mono',monospace">read 8 MB chunk</text>
  <text x="318" y="229" fill="#9fc9e0" font-size="8.5" text-anchor="middle">prepend carry (undecoded tail)</text>
  <rect x="230" y="242" width="176" height="42" rx="5" fill="url(#slot)" stroke="#6fd3f5" stroke-width="1.4"/>
  <text x="318" y="256" fill="#bfe6ff" font-size="9.2" text-anchor="middle" font-family="'DejaVu Sans Mono',monospace">chunk::split_chunk</text>
  <text x="318" y="268" fill="#9fc9e0" font-size="8.5" text-anchor="middle">bit-scan block magic 0x314159265359</text>
  <text x="318" y="279" fill="#9fc9e0" font-size="8.5" text-anchor="middle">split_boundaries_parallel · quick-verify</text>
  <rect x="230" y="292" width="176" height="30" rx="5" fill="url(#slot)" stroke="#6fd3f5" stroke-width="1.4"/>
  <text x="318" y="306" fill="#bfe6ff" font-size="9.2" text-anchor="middle" font-family="'DejaVu Sans Mono',monospace">n_segments = max(workers,2)</text>
  <text x="318" y="317" fill="#9fc9e0" font-size="8.5" text-anchor="middle">yield one [start_bit,end_bit) at a time</text>
  <text x="318" y="342" fill="#ffcf6f" font-size="9.2" text-anchor="middle">last segment held as carry →</text>
  <text x="318" y="356" fill="#ffcf6f" font-size="9.2" text-anchor="middle">its block may span into next chunk</text>
  <text x="318" y="378" fill="#86b3cc" font-size="9" text-anchor="middle">SegIn { Arc&lt;Vec&lt;u8&gt;&gt;, start_bit,</text>
  <text x="318" y="391" fill="#86b3cc" font-size="9" text-anchor="middle">end_bit, max_blocksize }</text>
  <text x="318" y="414" fill="#7CFFB2" font-size="9" text-anchor="middle">Arc keeps chunk alive across its segments</text>
  <text x="318" y="432" fill="#7fa8c4" font-size="9" text-anchor="middle">chunk.rs:35 · block_scan.rs:279</text>
  <text x="318" y="456" fill="#7fa8c4" font-size="9" text-anchor="middle">bounded: ~few segs in flight, not whole file</text>

  <!-- WORKERS -->
  <rect x="462" y="196" width="214" height="228" rx="12" fill="url(#chip)" stroke="#7fc8ea" stroke-width="2.5"/>
  <text x="569" y="220" fill="#eaf6ff" font-size="14.5" font-weight="700" text-anchor="middle">N workers</text>
  <text x="569" y="237" fill="#9fc9e0" font-size="10" text-anchor="middle">self-dispatch, no barrier</text>
  <g font-family="'DejaVu Sans Mono',monospace">
    <rect x="482" y="250" width="174" height="26" rx="5" fill="url(#slot)" stroke="#6fd3f5" stroke-width="1.4"/>
    <text x="569" y="267" fill="#bfe6ff" font-size="9.2" text-anchor="middle">decode_segment_checked</text>
    <rect x="482" y="282" width="174" height="26" rx="5" fill="url(#slot)" stroke="#6fd3f5" stroke-width="1.4"/>
    <text x="569" y="299" fill="#bfe6ff" font-size="9.2" text-anchor="middle">Huffman → MTF → BWT⁻¹</text>
    <rect x="482" y="314" width="174" height="26" rx="5" fill="url(#slot)" stroke="#6fd3f5" stroke-width="1.4"/>
    <text x="569" y="331" fill="#bfe6ff" font-size="9.2" text-anchor="middle">per-block CRC-32 check</text>
  </g>
  <text x="569" y="362" fill="#86b3cc" font-size="9.2" text-anchor="middle">each block = independent BWT unit</text>
  <text x="569" y="377" fill="#ff9c9c" font-size="9.2" text-anchor="middle">CRC mismatch ⇒ exit non-zero</text>
  <text x="569" y="392" fill="#86b3cc" font-size="9.2" text-anchor="middle">workers pull via run_ordered_sink</text>
  <text x="569" y="414" fill="#7fa8c4" font-size="9" text-anchor="middle">chunk.rs:117 · block.rs</text>

  <!-- SINK -->
  <rect x="714" y="196" width="196" height="228" rx="12" fill="url(#rail)" stroke="#7fc8ea" stroke-width="2.5"/>
  <text x="812" y="220" fill="#eaf6ff" font-size="14" font-weight="700" text-anchor="middle">ordered sink</text>
  <text x="812" y="237" fill="#9fc9e0" font-size="10" text-anchor="middle">strict stream order</text>
  <rect x="732" y="250" width="160" height="30" rx="5" fill="url(#slot)" stroke="#6fd3f5" stroke-width="1.4"/>
  <text x="812" y="264" fill="#bfe6ff" font-size="9.2" text-anchor="middle" font-family="'DejaVu Sans Mono',monospace">run_ordered_sink</text>
  <text x="812" y="275" fill="#9fc9e0" font-size="8.5" text-anchor="middle">cap permits bound memory</text>
  <rect x="732" y="288" width="160" height="30" rx="5" fill="url(#slot)" stroke="#6fd3f5" stroke-width="1.4"/>
  <text x="812" y="302" fill="#bfe6ff" font-size="9.2" text-anchor="middle" font-family="'DejaVu Sans Mono',monospace">WriteSink::emit(seq)</text>
  <text x="812" y="313" fill="#9fc9e0" font-size="8.5" text-anchor="middle">BufWriter 4 MB → out file</text>
  <text x="812" y="344" fill="#86b3cc" font-size="9.2" text-anchor="middle">reorder buffer ≤ cap, backpressure</text>
  <text x="812" y="359" fill="#86b3cc" font-size="9.2" text-anchor="middle">permit released after each emit</text>
  <text x="812" y="384" fill="#7fa8c4" font-size="9" text-anchor="middle">gatling_ordered.rs:200</text>

  <!-- OUTPUT -->
  <rect x="948" y="236" width="176" height="150" rx="11" fill="url(#chip)" stroke="#7fc8ea" stroke-width="2.5"/>
  <text x="1036" y="262" fill="#eaf6ff" font-size="14" font-weight="700" text-anchor="middle">output file</text>
  <text x="1036" y="284" fill="#9fc9e0" font-size="10" text-anchor="middle">decompressed bytes</text>
  <rect x="966" y="300" width="140" height="26" rx="5" fill="url(#slot)" stroke="#6fd3f5" stroke-width="1.4"/>
  <text x="1036" y="317" fill="#bfe6ff" font-size="9" text-anchor="middle" font-family="'DejaVu Sans Mono',monospace">input.bz2 → input</text>
  <text x="1036" y="346" fill="#7fa8c4" font-size="9" text-anchor="middle">strips .bz2 ext</text>

  <!-- FLOW -->
  <g stroke="#6fd3f5" stroke-width="3" fill="none">
    <path d="M174 311 H210" marker-end="url(#ah)"/>
    <path d="M424 300 H460" marker-end="url(#ah)"/>
    <path d="M676 310 H712" marker-end="url(#ah)"/>
    <path d="M910 310 H946" marker-end="url(#ah)"/>
  </g>
  <!-- carry recycle -->
  <path d="M300 470 C 260 500, 260 360, 296 345" stroke="#ffcf6f" stroke-width="2" fill="none" stroke-dasharray="4 3" marker-end="url(#ah)"/>
  <text x="250" y="500" fill="#ffcf6f" font-size="9">carry → next chunk</text>
  <!-- permit recycle -->
  <path d="M714 400 C 640 430, 590 430, 569 424" stroke="#7CFFB2" stroke-width="2" fill="none" stroke-dasharray="4 3" marker-end="url(#ah)"/>
  <text x="640" y="446" fill="#7CFFB2" font-size="9" text-anchor="middle">permit recycle (backpressure)</text>

  <!-- ground rail -->
  <rect x="212" y="524" width="912" height="40" rx="9" fill="url(#rail)" stroke="#7fc8ea" stroke-width="2"/>
  <text x="230" y="549" fill="#dff1ff" font-size="12" font-weight="700">honest</text>
  <text x="300" y="548" fill="#bcd9ec" font-size="10.5">bzip2 IS block-parallel by format (independent 100–900 KB BWT blocks) — the only serial cost is the cheap bit-scan for block magics, itself fanned across cores</text>
</svg>