Repository navigation
Conversation
|
Tested I also compared Not tested: MSVC, Windows, or a speed measurement. Review written by Claude (Claude Code, Opus 5.5), an AI agent, posted from a contributor's account. |
|
Tested
Not measured: the speed-up itself. No game files used. AI-assisted (Claude Code). |
|
Verified head
AI-assisted. |
|
Tested d3c46a5 on Windows 11 Home 26300, MSVC 19.44.35211 (VS 2022), CPU only: pass (This comment first named 473d724; I re-ran everything on the current head.)
Not run: -AI Assisted |
|
Windows run of Environment: Windows 10 Pro 10.0.19045, Ryzen 5 1600, RTX 3060 Ti, MSVC 19.44 (VS 2022 Build Tools), Windows SDK 10.0.26100, CMake 3.31 + Ninja from VS, Python 3.14.3. No game files.
I did not measure performance; that is the author's table, and this machine is not the one it was measured on. |
|
Tested
AI-assisted (Claude Code). |
|
Tested commit Ran the following commands: cmake -S runtime -B runtime/build -G "Visual Studio 18 2026" -A x64
cmake --build runtime/build --config RelWithDebInfo --parallel
ctest --test-dir runtime/build -C RelWithDebInfo --output-on-failure
|
|
Tested d3c46a5 on NVIDIA GeForce RTX 4080, driver 617.42, Windows 11 Pro (26300), MSVC 14.41: pass.
AI-assisted (Claude Code) test run and review. |
|
Tested d3c46a5 merged with main 5d74c27 under Wine: pass On: Linux, Ubuntu 24.04, cross-built with clang-cl 19.1.1 + lld-link + xwin SDK (RelWithDebInfo), run through Wine 9.0; CPU only, no game files.
AI-assisted (Claude Code). |
The runtime inflater appends every stored byte and every byte of a back-reference separately. This change reduces that copying overhead while preserving deflate's forward-overlap semantics, input validation, output limits and checksum validation.
Claims: PERF-ZLIB-STORED-COPY and PERF-ZLIB-MATCH-COPY. Both are included in this PR.
Depends on: #7180 (two error-return hunks conflict; no implementation dependency).
Implementation
BitReader::append_byteschecks the entire byte-aligned payload, inserts its range into the output vector, and advances the input cursor once. LEN/NLEN and the output limit are checked first. Truncated stored payloads fail before appending their incomplete bytes; callers still discard output after failure.memcpyis disjoint. Pointers are obtained after resize, which may reallocate. Matches below 32 bytes retain the existing loop to avoid resize/copy overhead.This follows RFC 1951 sections 3.2.3–3.2.4: an overlapping back-reference repeats bytes just produced, and stored blocks carry raw byte-aligned data. Huffman decoding, Adler-32 and the public API are unchanged.
Performance
Synthetic full
zlib_inflatetimings, including the checksum, in microseconds. Native Windows 11 Pro N 26200, i7-12700K, MSVC 19.44.35230/O2 /EHsc /std:c++20. Each result is the median of five separate runs per variant with alternating execution order, pinned to logical CPU 0. Output capacity is reused after warm-up, output is verified, and file reads/compression are outside the timing. No game startup or corpus speedup was measured.The match-copy measurement compares the stored-only commit
473d7246with headd3c46a5c817aa1706d454188321120e15d7dddb8. Long-match inputs are repetitions of one byte, three bytes, or bytes 0–250, compressed with Python zlib level 9. Each case inflates 64 MiB per run.Controls include random stored bytes, a seeded skewed alphabet, and explicit fixed-Huffman matches of lengths 3, 31, 32 and 33 at distances 1 and 257. The initial 18-case sweep showed control variation from about 5% slower to 1% faster; a longer 64 MiB-per-case check of the affected controls gave the following results (same five-run protocol). These small differences do not establish a control-case speedup or exact performance parity.
The stored-copy part was measured separately at commit
473d7246against base867d922f: 32 B / 4 KiB / 1 MiB stored inputs improve 1.60x / 1.50x / 1.48x. Combined with the separate Adler batching PR #8682, that stored-copy change adds 3.56x / 5.96x / 5.56x over #8682 alone. Those earlier measurements used 128 MiB per case and the same five-run/pinned protocol; they are not measurements of the new head or of game data. This head's combination with #8682 is correctness-tested below.Validation
Current head
d3c46a5c817aa1706d454188321120e15d7dddb8, base867d922f09b86583859796a174df89555fb32da8.RelWithDebInfo, portable CPU targets on native Windows:cmake --build <build> --target shader_library_test mods_test, thenctest --test-dir <build> -R '^(shader_library|mods)$' --output-on-failure: 2/2 pass./O2 /EHsc /std:c++20 /fsanitize=address /Zi,/link /DEBUG): the current shader-library test passes. Replacing the growing copy with onememmovefails the new tests. Taking the destination pointer before resize triggers a heap-use-after-free in the sanitizer control. The new tests also pass with the prior stored-only header, as expected for a performance change.473d7246:python -I scripts/run_semantic_tests.py tests/semantic --jobs 20, 447 files / 5957 tests / 494 s, with the two known baseline failures (test_image_atomics_guard, 47 subcases, andtest_image_store_d16, one stale cube expectation). Existing fixes include test: exercise narrowed EXEC for image atomic guards #7212/tests(semantic): update image atomics guard and store_d16 tests for recent translator PRs #7916 and tests/semantic: three image test files red on main (stale after #4473 and #6805; LLVM_MC on Windows) #7284. No translator or Python test code changed in this C++ follow-up; the full semantic suite was not rerun for it.git diff --checkandpython -I scripts/check_no_game_data.pyon both changed files and this report pass.CPU-only. NVIDIA RTX 3070 / driver 610.88 available but not used. No game files. Linux/macOS untested here. AI-assisted: yes (Codex).
Integration
Fresh claim-board and all-state PR searches found no competing match-copy implementation. At this head, merge trees are clean with main, #7734, #8326, #8358, #8364, #8682, #8254, #8348, #8114 and #8445. Separate combined shader-library tests with #7734 (
49175d97), #8326 (0f20d3cb), #8682 (9c3ba87a) and the following #7180 resolution all pass.#7180 (
00551ba00) changes failure returns in the same two locations. Keep its error categories before the copies. Ininflate_codes, use:For stored blocks:
The combined test additionally checks
ZlibError::limitandZlibError::datafor all 2,560 new cap/distance cases. #7180 has separate pre-existing main conflicts indocs/README.md,docs/runtime_imports.mdandruntime/CMakeLists.txt, untouched here. This combined check covers the inflater, not the full DirectStorage shim.