Repository navigation
d3d12: stamp compute journal files with the writing build; precompile re-checks other builds' files (RT-PIPELINE-JOURNAL-BUILD-ID) - #2511
Open
Tyrannys wants to merge 1 commit 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>
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.
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.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.ctest -R "^(pipeline_cache_journal|pipeline_cache_store|pipeline_cache_file|pipeline_cache_seed|compile_helper|d3d12_compute_journal|precompile_skip_list)$": 7/7 pass (withpipeline_cache_fileandpipeline_cache_seed).scripts/check_no_game_data.py: clean.Not tested: NVIDIA 621.40 (enlight3d's driver), AMD or Intel, and a game boot. 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.
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