inflate: copy DEFLATE stored blocks in bulk (RT-INFLATE-STORED-COPY) #1189

Open
github-bot wants to merge 1 commit from github-bot/gh-1189 into main AGit
Owner

@⁠sodove on GitHub · 2026-11-24 19:53 UTC · original
sodove:perf/rt-inflate-stored → main · +21 −6 · 2 files · 1 commits · open

Claimed in the coordination issue as: RT-INFLATE-STORED-COPY (claim).

Depends on: none. Applies independently alongside #1081, which changes match expansion and Adler-32.

What changed

The CPU zlib inflater used by the DirectStorage request handler and shader-library extraction appended each byte of an aligned DEFLATE stored block separately. It now takes the available input as a span and appends that range in one operation. The declared length is still checked against the output limit before copying. A truncated block still contributes its available prefix before reporting a data error.

Measured on the runtime queue

Windows 11 x64, Ryzen 5 9600X, MSVC 19.44 /O2. Synthetic zlib requests each produced 4 MiB. The indicated percentage of output came from stored blocks containing pseudorandom bytes. A compressed tail kept every request within the shim’s source/destination size contract.

Source and share from stored blocks main 6293c1c4f → this PR (ms/request) #1081 09ba0aa85 → both (ms/request)
Memory, 0% (control) 18.08 → 18.24 2.16 → 2.12
Memory, 50% 18.13 → 15.23 4.20 → 2.52
Memory, 95% 18.63 → 12.37 6.53 → 2.78
File, 95%, warm OS cache 20.82 → 13.89 7.73 → 3.57

Each figure is the median of ten paired rounds with alternating run order. Timed the actual queue from enqueue through submission and its completion event, eight requests per sample after a warm-up batch. Every request returned S_OK and its full destination matched outside the timer. The mixed cases improved in all ten pairs. Changes on the 0% control were within 2% in either direction. The retail block mix, game startup time and FPS were not measured.

Tested

  • Built gta6rt.exe in RelWithDebInfo on native Windows. CTest passed shader_library and dstorage (329 checks in the latter). The shader-library suite also passed on Linux x86-64 with GCC 15.2.
  • Extended the existing mixed-block test across all eight alignments to check the exact output prefix and error classification. A control that rejected a short block before appending its prefix failed the new assertion.
  • 710 additional synthetic boundary, output-limit and checksum checks passed on each of the four variants, including empty and 65,535-byte blocks.
  • Full semantic suite passed (6,168 tests, 470 files). The two changed paths passed the game-data check. git merge-tree applies this PR and #1081 cleanly.

GPUs tested: n/a (CPU and DirectStorage queue). Only synthetic input used.

AI-assisted: yes (OpenAI Codex).

Checklist

  • Based on current main and merges cleanly.
  • One topic.
  • Source and synthetic tests only.
  • No translator rule changed.
**@⁠sodove** on GitHub · 2026-11-24 19:53 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1189) `sodove:perf/rt-inflate-stored` → `main` · +21 −6 · 2 files · 1 commits · open Claimed in the coordination issue as: RT-INFLATE-STORED-COPY ([claim](https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14)). Depends on: none. Applies independently alongside #1081, which changes match expansion and Adler-32. ### What changed The CPU zlib inflater used by the DirectStorage request handler and shader-library extraction appended each byte of an aligned DEFLATE stored block separately. It now takes the available input as a span and appends that range in one operation. The declared length is still checked against the output limit before copying. A truncated block still contributes its available prefix before reporting a data error. ### Measured on the runtime queue Windows 11 x64, Ryzen 5 9600X, MSVC 19.44 `/O2`. Synthetic zlib requests each produced 4 MiB. The indicated percentage of output came from stored blocks containing pseudorandom bytes. A compressed tail kept every request within the shim’s source/destination size contract. | Source and share from stored blocks | main `6293c1c4f` → this PR (ms/request) | #1081 `09ba0aa85` → both (ms/request) | |---|---:|---:| | Memory, 0% (control) | 18.08 → 18.24 | 2.16 → 2.12 | | Memory, 50% | 18.13 → 15.23 | 4.20 → 2.52 | | Memory, 95% | 18.63 → 12.37 | 6.53 → 2.78 | | File, 95%, warm OS cache | 20.82 → 13.89 | 7.73 → 3.57 | Each figure is the median of ten paired rounds with alternating run order. Timed the actual queue from enqueue through submission and its completion event, eight requests per sample after a warm-up batch. Every request returned `S_OK` and its full destination matched outside the timer. The mixed cases improved in all ten pairs. Changes on the 0% control were within 2% in either direction. The retail block mix, game startup time and FPS were not measured. ### Tested - Built `gta6rt.exe` in RelWithDebInfo on native Windows. CTest passed `shader_library` and `dstorage` (329 checks in the latter). The shader-library suite also passed on Linux x86-64 with GCC 15.2. - Extended the existing mixed-block test across all eight alignments to check the exact output prefix and error classification. A control that rejected a short block before appending its prefix failed the new assertion. - 710 additional synthetic boundary, output-limit and checksum checks passed on each of the four variants, including empty and 65,535-byte blocks. - Full semantic suite passed (6,168 tests, 470 files). The two changed paths passed the game-data check. `git merge-tree` applies this PR and #1081 cleanly. GPUs tested: n/a (CPU and DirectStorage queue). Only synthetic input used. AI-assisted: yes (OpenAI Codex). ### Checklist - [x] Based on current `main` and merges cleanly. - [x] One topic. - [x] Source and synthetic tests only. - [x] No translator rule changed.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:42:06 +00:00
Author
Owner

@⁠Deedlyy on GitHub · 2026-11-24 20:08 UTC · original

Recommendation: [MERGE]

Reasoning: The CPU zlib inflater copies DEFLATE stored blocks with one range append instead of byte by byte, keeping the output-limit check and truncated-block behaviour. Small performance change in the DirectStorage/shader-library path, with a test. It's independent of #1081. CI (label, change-scope, no-game-data and the Runtime jobs) is still queued awaiting maintainer workflow approval, so nothing has run in CI yet; GitHub reports no merge conflict with main. Merge once the queued checks are green.

Impact level: 3/10

**@⁠Deedlyy** on GitHub · 2026-11-24 20:08 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1189#issuecomment-7143105142) **Recommendation:** [MERGE] **Reasoning:** The CPU zlib inflater copies DEFLATE stored blocks with one range append instead of byte by byte, keeping the output-limit check and truncated-block behaviour. Small performance change in the DirectStorage/shader-library path, with a test. It's independent of #1081. CI (label, change-scope, no-game-data and the Runtime jobs) is still queued awaiting maintainer workflow approval, so nothing has run in CI yet; GitHub reports no merge conflict with `main`. Merge once the queued checks are green. **Impact level:** 3/10
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1189/head:github-bot/gh-1189'
git switch 'github-bot/gh-1189'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1189'
git switch 'github-bot/gh-1189'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1189'
git switch 'github-bot/gh-1189'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1189'
git switch 'main'
git merge --squash 'github-bot/gh-1189'
git switch 'main'
git merge --ff-only 'github-bot/gh-1189'
git switch 'main'
git merge 'github-bot/gh-1189'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.