Repository navigation
d3d12: stamp compute journal files with the writing build and device-create config; precompile re-checks other writers' files (RT-PIPELINE-JOURNAL-BUILD-ID) - #2511
Open
Tyrannys wants to merge 2 commits into
Conversation
… re-checks other builds' files
A compute journal file (pipeline_cache.d/cs-*.bin) was taken by gta6rt --precompile-pipelines as
journaled already whenever its blob header named this device and driver. enlight3d measured on
NVIDIA 621.40 that a rebuilt runtime got few hits from the files another build wrote, so after a
rebuild the precompiler could report a complete journal that did not help.
Each journal file now starts with a 16-byte stamp ("LPJ1", its size, a 64-bit hash of the gta6rt
executable that wrote it) before the VkPipelineCache blob; the stamp is removed before the blob
reaches the driver. Files without a stamp are read as before.
- The precompiler skips only files this build wrote (entry_current). A file from another build is
built against: a hit takes milliseconds and the file is stamped as this build's, a miss compiles
and rewrites it. A line after the summary counts them.
- The runtime's journal line counts files from another build and how many of them still hit.
- LEONIDA_PIPELINE_JOURNAL_BUILD=<hex> stands in for the executable's hash (tests).
pipeline_cache_journal_test gains test_stamp; check_precompile_skip_list checks the stamp and a run
as another build. Docs updated.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…other diagnostics setting On NVIDIA 621.01 (RTX 4070 SUPER), a compute journal precompiled without LEONIDA_DEVICE_FAULT and booted with it gave 0 of 10 pipelines from the journal (10 compiled); with the setting matching both ways, 10 of 10. - The journal stamp grows to 24 bytes: the writing binary's build plus a hash of the VkDeviceCreateInfo (src/vulkan_device_config.h: enabled extensions in any order, core and chained feature bits, the device fault and NVIDIA diagnostics config structures with their flags). Only a file this build wrote under this config is "journaled already" for --precompile-pipelines; a file from another config is built against again and restamped on a hit, like a file from another build. - The diagnostics config already names its pipelines apart, so a boot with it finds no file for a journal precompiled without it. Such a pipeline (no file, one under the other setting) is now counted: once at boot with a hint to precompile with the boot's setting, in the journal's running line, and in a closing line of the precompiler. - Tests: vulkan_device_config_test (CPU); pipeline_cache_journal_test covers the config in the stamp; check_precompile_skip_list runs LEONIDA_DEVICE_FAULT=2 and =1 against the journal when the device has them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Independently checked head Local build & dual-GPU verification:
Code review notes:
Overall looks clean and solid. AI-assisted. |
This was referenced Nov 28, 2026
4 tasks done
lixonik
approved these changes
Nov 28, 2026
lixonik
left a comment
Contributor
There was a problem hiding this comment.
Reviewed 4a497c8f1 and tested both CPU unit tests and live Vulkan compute journal / precompile paths.
Code audit:
runtime/src/vulkan_device_config.h: cleanly hashes sorted/deduplicated device extensions,pEnabledFeatures, and thepNextchain (using exact member ranges without reading trailing padding; bounded chain traversal; non-zero result).runtime/src/pipeline_cache_journal.h: 24-byteLPJ1stamp (magic,stamp_bytes, executablefile_build,device_create_config) is backward compatible with unstamped files,check_entryreads only stamp + cache header for fast precompile scans, andentry_currentproperly gates precompile skips.runtime/shims/d3d12_vulkan_device.cpp: restamping on hits from another build/config skips immutable seed files, updatesjournal_bytesatomically, and surfaces theother_diagnosticshint cleanly.
Verification (Windows 11, MSVC 19.44, Ninja Release, LEONIDA_VK_VALIDATION=1):
- Built
pipeline_cache_journal_test,vulkan_device_config_test,d3d12_m4_compute_test, andgta6rt. ctest -R '^(pipeline_cache_journal|vulkan_device_config|d3d12_m4_compute|precompile_skip_list)$': 4/4 passed.python -I scripts/check_no_game_data.py: passed.
GPUs tested: NVIDIA GeForce RTX 5070 12 GB (Windows 11, driver 610.88, Vulkan 1.4.341, VK_LAYER_KHRONOS_validation 1.4.363).
AI-assisted (Antigravity, Gemini).
3 of 4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Claimed in the coordination issue as: RT-PIPELINE-JOURNAL-BUILD-ID (#1608 (comment))
What and why
From @enlight3d's finding in #1608 (#1608 (comment)). Thanks for the measurements.
On NVIDIA 621.40, a compute journal file in
pipeline_cache.dwas measured giving cache hits mostly to the gta6rt build that wrote it. The runtime checks only the blob header (vendor, device, pipeline-cache UUID).gta6rt --precompile-pipelinesskipped any file whose header matched as "journaled already". So after a rebuild it could report a complete journal that the new binary got few hits from.What our code gives the driver. Nothing in it changes from one build to the next:
VkApplicationInfohas only the namegta6rtand API 1.3, with no application or engine version.So there was no per-build input to make stable.
Measured here. A standalone Vulkan program, RTX 4070 SUPER, driver 621.01:
VkPipelineCacheblob written by one executable gave a cache hit (creation feedbackAPPLICATION_PIPELINE_CACHE_HIT, 3-75 ms instead of 2.6-22 s) to all of these:robustBufferAccessorshaderInt64enabled on the device.%LOCALAPPDATA%\NVIDIA\GLCache) did key on the executable. A renamed byte-identical copy got a file of its own there and compiled again (4.7 s) when given an emptyVkPipelineCache.So this driver did not show the effect. What the driver keys on in enlight3d's case is still open. Their same-binary drop (all compute pipelines from the journal at 20:16, 22 at 21:45) also points at something besides the binary.
Device-create config (second commit). A boot A/B on the same RTX 4070 SUPER (621.01), counts only:
LEONIDA_DEVICE_FAULT, boot withLEONIDA_DEVICE_FAULT=1: 10 compiled, 0 from the journal;The NVIDIA diagnostics config (
=1, orLEONIDA_AFTERMATH=1) already names its pipelines apart (since #2098), so such a boot simply had no file for those pipelines, and nothing said why.Change. Whatever the cause, the precompiler should not count a file as done without knowing the driver takes it for this binary.
Stamp (
pipeline_cache_journal.h). Each journal file now starts with 16 bytes:LPJ1and the stamp's size;file_build, computed once per process).read_entry_fileremoves the stamp before the blob goes to the driver.check_entry/entry_usableread the stamp and blob header. The newentry_currentis true only for a file this build wrote. A file without a stamp (an older runtime) is read as before and counts as from another build. An older runtime reading a new file sees a header it does not know and rebuilds that file.Precompile (
d3d12_vulkan_device.cpp). Withskip_journaled, onlyentry_currentfiles are skipped. A file from another build is built against, as at a dispatch:restamp_hits), so the next run skips it;After the existing
done:line (unchanged, so the existingcheck_precompile_skip_listpatterns still match), a second line follows when there were any:N journal file(s) from another gta6rt build or without a build stamp: H still found by the driver (now stamped as this build's), C compiled again.Runtime. The journal's "so far" line also gives
from another build: N, M of them found. A boot after a rebuild then shows directly whether that driver still takes another build's files. The runtime does not restamp, so files from another build keep counting until the precompiler runs.LEONIDA_PIPELINE_JOURNAL_BUILD=<hex>replaces the executable's hash. It is for tests: a second build without a second binary.docs/d3d12_vulkan.mdanddocs/running.mddescribe the stamp and say to run the precompiler again after a rebuild.Device-create config in the stamp (second commit). The stamp grows to 24 bytes: the build, then
device_create_configof theVkDeviceCreateInfo(newsrc/vulkan_device_config.h): the enabled extensions in any order,pEnabledFeatures, and eachpNextstructure by type, with the contents of the core 1.1/1.2/1.3 feature structures, robustness2, device fault and the diagnostics config (features and create info with its flags).entry_currentneeds both to match. A file this build wrote under another config (for exampleLEONIDA_DEVICE_FAULT=2, which adds fault info and checkpoints but keeps the names) is built against again and restamped on a hit, and counted apart from other builds:[precompile] N journal file(s) from this build under another device config (...): H still found by the driver (now stamped with this config), C compiled again, andfrom another device config: N, M of them foundin the runtime's line.The other diagnostics setting. Each build also names the file under the other diagnostics config setting. When the pipeline has no file but that one exists, it is reported once at boot (
<entry> has a journal file only for a device without NVIDIA's diagnostics config ...; run gta6rt --precompile-pipelines with this boot's setting), counted in the runtime's line (only under the other diagnostics config setting: N), and in a closing line of the precompiler (N entries had a journal file only for a device without NVIDIA's diagnostics config: built for this setting).Unchanged: the compile helper's readiness checks and the compile server's idle fill still use
entry_usable(any build). The helper is the same executable as the game, so its files carry the game's stamp.Overlap: #2198 (
--precompile-pipelines --verify), #2179 and #2228 (journal rewrite and stale-file probe), #2307 (pipeline_cache_journal.hguards) and #2392 (make_game pipelines via the runtime) touch the same files on other lines. #2179 matters here: on a seeded miss, NVIDIA returned the seeded data without the new pipeline, so a rewrite could keep a file that misses. With this change, such a file also gets this build's stamp. #2179 fixes the rewrite itself.Tested
Windows 11, MSVC (VS 18), RelWithDebInfo, on
main34e33d3. Short GPU runs only.pipeline_cache_journal_test(CPU) gainstest_stamp:entry_currentonly for the writing build, never for build 0;file_buildis the same for a copy under another name, differs for a one-byte change and for one byte fewer, and is 0 for a missing or empty file.check_precompile_skip_list.cmake(gta6rt, real device, two small synthetic modules) gains three checks:LEONIDA_PIPELINE_JOURNAL_BUILD), both files are built again, not counted as journaled already: 2 found in a cache, 0 compiled, and the new line reports 2 from another build;With
main's skip check (entry_usable) restored in this branch, the "another build" step fails on both of its patterns: the files are counted as journaled already and no other-build line is printed.Second commit:
vulkan_device_config_test(CPU): the same create info gives the same value; extension order does not matter, an added extension does; core and chained feature bits (including the last member of the 1.2 and 1.3 structures) count;LEONIDA_DEVICE_FAULT=1and=2(through the runtime'sDeviceFaultFeatures) differ from a plain device and from each other; Aftermath's extra flags count;=1on a device without the config equals=2; never 0.pipeline_cache_journal_test: the config in the stamp,other_configapart fromother_build(an unstamped file counts only as another build),entry_currentfalse for another config, a seed file's config.check_precompile_skip_list.cmakegains steps 6-9, run here (fault info, checkpoints and the diagnostics config are all on this device): withLEONIDA_DEVICE_FAULT=2, both files are reported from another device config (2 still found by the driver), then journaled already on the next run; withLEONIDA_DEVICE_FAULT=1, both are built (no file under the diagnostics names), the new line reports 2 with a file only without the config, the journal holds 4 files, and the next run counts 2 journaled already. Each step falls back to a note on a device without those extensions.entry_current, step 6 fails on both of its patterns.ctest -R "^(pipeline_cache_journal|pipeline_cache_store|pipeline_cache_file|pipeline_cache_seed|compile_helper|d3d12_compute_journal|precompile_skip_list|vulkan_device_config|vulkan_device_fault)$": 9/9 pass.scripts/check_no_game_data.py: clean.Not tested: NVIDIA 621.40 (enlight3d's driver), AMD or Intel, and a game boot with this branch (the A/B counts above are from a boot of
main). A boot after this lands, with a journal from the previous build, would show in the runtime's line how many of that build's files the driver still takes. Files written by the first commit's 16-byte stamp (never merged) read as unstamped.GPUs tested: profile M: NVIDIA GeForce RTX 4070 SUPER, 12 GB, desktop, driver 621.01, Windows 11
AI-assisted: yes (Claude Code)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator change)🤖 Generated with Claude Code