Speed: --bench with checksums, BC decode in bands (SIX-99) #206

Manually merged
github merged 3 commits from gh-pr/206/head into gh-pr/206/base 2026-11-26 20:18:05 +00:00
Owner

@⁠holdmysocks on GitHub · 2026-11-24 20:41 UTC · original
holdmysocks:six-99-speed → master · +472 −39 · 4 files · 3 commits · merged 2026-11-24 21:38 UTC

Linear: SIX-99.

What changes

sixng --bench (first commit). Times four things on the installed game data and prints a checksum of every result, so a speed change can be shown not to change the output:

  • Index: the stream scan and the name pass over part of one archive (default: the first 1024 MB of the largest RPF9 archive).
  • Search: loading every index, then six regex searches over all of them.
  • Textures: read, untile and decode mip 0 of every texture in 192 texture dictionaries, one texture at a time and then one texture per core.
  • Models: export 8 drawables with their textures into a scratch folder, which is removed afterwards.

It needs the archives indexed and writes nothing to the work dir. --bench-only, --bench-index, --bench-mb, --bench-at-mb, --bench-count, --bench-models and --bench-out narrow or move it. The subcommand is now optional so that sixng --bench works on its own; without either, the CLI prints an error as before.

BC1 to BC7 decode in bands (second commit). texture::to_rgba splits a block-compressed image into bands of block rows and decodes one band per core. Blocks do not depend on each other, so the bytes are the same. BC6H and BC7 split from 512 x 512 pixels, the faster formats from 2048 x 2048: smaller images stay on one core, because handing a few milliseconds of work to busy cores costs more than it saves. bc6h.rs and the BCPack decoders are untouched. A new test checks that every band split gives the bytes of a single pass, for all eight formats and for sizes that are not whole blocks.

Measured

6 threads, the best of several runs, before and after alternated. The PC was fully loaded by other work the whole time, so identical runs differed by 2x to 4x; read the times as rough.

Part Before After Checksum (same before and after)
Decode 499 textures, one at a time 1.69 s 0.60 s 514ad9522fb6bdf4
of which BC7 (35.5 megapixels) 1.31 s 0.23 s
of which BC6H (6.1 megapixels, 372 small textures) 0.31 s 0.33 s
Same textures, one per core 0.64 s 0.58 s 6d8beeb1d11cc8f5
Export 8 models with textures (919 files, 625 MB) 12.4 s 11.5 s 879ba0724b8fe1e8
Scan 1024 MB of levels.rpf 1.90 s 1.79 s 0be5f68d3c58589e
Name pass over the 1,370 entries found 4.35 s 4.85 s 8cfabd593b7d4546
Load 22 indexes / 6 searches 1.38 s / 0.54 s 1.26 s / 0.51 s 68c2e27fa4e23965

Only the first three rows are a real change: a single large BC7 texture decodes about five times faster on six threads. The rest is the same code and the differences are noise. Every checksum was identical in every run of every build.

Tried, not in this PR

  • zlib backend. flate2 already uses zlib-rs (since the first commit). Built with the other pure-Rust backend for comparison: the scan of the same 1024 MB took 2.32 s against 1.30 s, with the same checksums. Nothing to change.
  • Read-ahead while indexing (read the next 16 MB on its own thread while the current chunk is probed). Written and tested, output identical, no gain: 1.36 s before and 1.35 s after on cached data, and within the noise on six 2 GB regions that had not been read before. The scan already runs one segment per core, and reading 16 MB takes a few milliseconds against about a quarter of a second of probing. Left out.

Checks

  • cargo test -p sixng-core -p sixng-cli: 179 passed, 1 ignored.
  • sixng-gui was not rebuilt; it calls to_rgba through the same signature.
**@⁠holdmysocks** on GitHub · 2026-11-24 20:41 UTC · [original](https://github.com/holdmysocks/SixNG/pull/206) `holdmysocks:six-99-speed` → `master` · +472 −39 · 4 files · 3 commits · merged 2026-11-24 21:38 UTC Linear: SIX-99. ## What changes **`sixng --bench`** (first commit). Times four things on the installed game data and prints a checksum of every result, so a speed change can be shown not to change the output: - Index: the stream scan and the name pass over part of one archive (default: the first 1024 MB of the largest RPF9 archive). - Search: loading every index, then six regex searches over all of them. - Textures: read, untile and decode mip 0 of every texture in 192 texture dictionaries, one texture at a time and then one texture per core. - Models: export 8 drawables with their textures into a scratch folder, which is removed afterwards. It needs the archives indexed and writes nothing to the work dir. `--bench-only`, `--bench-index`, `--bench-mb`, `--bench-at-mb`, `--bench-count`, `--bench-models` and `--bench-out` narrow or move it. The subcommand is now optional so that `sixng --bench` works on its own; without either, the CLI prints an error as before. **BC1 to BC7 decode in bands** (second commit). `texture::to_rgba` splits a block-compressed image into bands of block rows and decodes one band per core. Blocks do not depend on each other, so the bytes are the same. BC6H and BC7 split from 512 x 512 pixels, the faster formats from 2048 x 2048: smaller images stay on one core, because handing a few milliseconds of work to busy cores costs more than it saves. `bc6h.rs` and the BCPack decoders are untouched. A new test checks that every band split gives the bytes of a single pass, for all eight formats and for sizes that are not whole blocks. ## Measured 6 threads, the best of several runs, before and after alternated. The PC was fully loaded by other work the whole time, so identical runs differed by 2x to 4x; read the times as rough. | Part | Before | After | Checksum (same before and after) | |---|---|---|---| | Decode 499 textures, one at a time | 1.69 s | 0.60 s | `514ad9522fb6bdf4` | | of which BC7 (35.5 megapixels) | 1.31 s | 0.23 s | | | of which BC6H (6.1 megapixels, 372 small textures) | 0.31 s | 0.33 s | | | Same textures, one per core | 0.64 s | 0.58 s | `6d8beeb1d11cc8f5` | | Export 8 models with textures (919 files, 625 MB) | 12.4 s | 11.5 s | `879ba0724b8fe1e8` | | Scan 1024 MB of `levels.rpf` | 1.90 s | 1.79 s | `0be5f68d3c58589e` | | Name pass over the 1,370 entries found | 4.35 s | 4.85 s | `8cfabd593b7d4546` | | Load 22 indexes / 6 searches | 1.38 s / 0.54 s | 1.26 s / 0.51 s | `68c2e27fa4e23965` | Only the first three rows are a real change: a single large BC7 texture decodes about five times faster on six threads. The rest is the same code and the differences are noise. Every checksum was identical in every run of every build. ## Tried, not in this PR - **zlib backend.** `flate2` already uses zlib-rs (since the first commit). Built with the other pure-Rust backend for comparison: the scan of the same 1024 MB took 2.32 s against 1.30 s, with the same checksums. Nothing to change. - **Read-ahead while indexing** (read the next 16 MB on its own thread while the current chunk is probed). Written and tested, output identical, no gain: 1.36 s before and 1.35 s after on cached data, and within the noise on six 2 GB regions that had not been read before. The scan already runs one segment per core, and reading 16 MB takes a few milliseconds against about a quarter of a second of probing. Left out. ## Checks - `cargo test -p sixng-core -p sixng-cli`: 179 passed, 1 ignored. - `sixng-gui` was not rebuilt; it calls `to_rgba` through the same signature.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 20:18:04 +00:00
github manually merged commit 17710a99a3 into gh-pr/206/base 2026-11-26 20:18:05 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.