Gunnar

nordisk/znippy-zoomies

.nornir/lbunzip2-guide.md

# lbunzip2 — guide

> **Class:** `guide` · **Function:** `lbunzip2`. Build, run, tune. Shape in
> [`lbunzip2-design.md`](lbunzip2-design.md); why in
> [`lbunzip2-reasoning.md`](lbunzip2-reasoning.md).

## Build

```sh
CARGO_TARGET_DIR=/mnt/work4t/cargo-target/zoomies cargo build --release -p lbzip2
```

Binary lands at `target/release/lbunzip2`.

## Run

```sh
lbunzip2 planet.osm.bz2               # → planet.osm  (strips .bz2)
lbunzip2 in.bz2 out                   # explicit output path
```

Reads anything `bzip2` / `lbzip2` / `pbzip2` wrote (stock format, single-stream or
pbzip2-style concatenated). Watch `htop`: cores should sit near-flat; the block scan
is the only serial-ish work and it is itself fanned across cores.

## Tune

- `LBZIP2_THREADS=N` pins worker count. `LBZIP2_THREADS=1` forces the single-worker
  `_st` bench row and still streams the whole file (segments are floored at 2, decoded
  one at a time — see the design's "segmentation floor"). Unset ⇒ physical core count.

## Library twins

The CLI is streaming; for in-memory or `Read`-trait use reach for the library readers
(`lbzip2::parallel::decompress_parallel`, `StreamingBz2Read`, `ParallelBz2Read`) —
documented in [`lbzip2-readers-design.md`](lbzip2-readers-design.md) /
[`-guide`](lbzip2-readers-guide.md).

## Bench

HEAVY only (no smoke): `nornir bench run znippy-zoomies` then
`nornir docs book znippy-zoomies` fills the README A/B/C mashup. The `_st` single-core
row (`LBZIP2_THREADS=1`) races stock serial `bzip2`; the all-core row races
`lbzip2`/`pbzip2`. See [`decompressors-guide.md`](decompressors-guide.md).