WIP: perf(build): a renderer header edit compiles the files that read it, not the whole back end #37
No reviewers
Labels
No labels
accessibility
autorelease: pending
autorelease: tagged
bug
dependencies
documentation
duplicate
enhancement
github_actions
good first issue
help wanted
invalid
needs measurements
question
testing wanted
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!37
Loading…
Reference in a new issue
No description provided.
Delete branch "dyst/Longshot:perf/renderer-depfiles"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Why
Editing any renderer header recompiles the whole back end: on Windows a comment in
vk_present_rect.h, which two files include, compiled 35 files again (417 s of compiler time; a 44 s build against 26 s for a.cppedit, and minutes on a 4–8 thread PC).What changed
nx2/build.pycompiles the back end's own files (gpu/vk/*.cpp, not Eden's or sirit's) with-MD, and clang writes a depfile beside each object (vk_x.dforvk_x.o,depfile_of).depfile_pathsreads a make-style depfile (the target left out, line continuations joined,\,$$and\#).renderer_depskeys each object by the headers its depfile lists under the same folders as before (vdeps_roots:gpu/vk,gpu/render,gpu/compat, suyu's texture decoders), by name and content (_HEADER_DIGESTS). A header the file doesn't read no longer changes its key; one it reads, or one that's gone, does.tree_headers) stays as the fallback, for a file with no depfile yet or one whose depfile names nothing under those folders.flag_textleaves-MDout of the key, so no key changes and nothing compiles again for this change itself; depfiles appear as files are compiled.compile_oneneither caches nor stamps an object under a key that came from the last compile's depfile (it hashes the new source with the old include list): it stamps itDEPFILE_PENDING.rekey_depfiles, run inmainafter the compile, stamps and caches each back-end object of this build (DEPFILE_JOBS) by the key its own new depfile gives, also when that is the planned key; an object stamped otherwise is another build's and is left alone. A build that stops before re-keying leaves the object pending, and the next build compiles it again. This answers hckrman101's review (an include added, removed, the header edited, the include back used to get the first object back from the cache).tests/test_renderer_depfiles.py(new, 11 cases).tests/test_compiler_failure.py,tests/test_mem_gate_leases.pyandtests/test_compile_retry_jobs.pytakeDEPFILE_DEPSandDEPFILE_PENDINGwithcompile_one;tests/test_dlss_sdk_cache.pyandtests/test_shader_stamp_cache.pyrun the job loop with its new helpers.Flags and settings
None. (The back end's files are compiled with
-MDnow: a compiler flag inside the build, not a switch, and left out of object keys.)Measurements
Measured on the GitHub version (NotRexed/Hookshot#2706), not yet on Longshot: this PR stays WIP until it is.
Hardware: Ryzen 9 3900X, NVMe, Windows
Scene: none (a build measurement)
Method: one build after a comment was added to
gpu/vk/vk_present_rect.h, without depfiles and with them; then the header revertedvk_present_rect.hvk_framegen.cpp,vk_menu.cpp,vk_replay.cpp, andhost/hos_main.c, through the host's own blob.In the game (a check, not a comparison): RTX 3080 (NVIDIA 621.14), Ryzen 9 3900X, 64 GB, Windows 11, this branch's
build.py(with the review fix) on GitHub'smainee29dd55. A build with depfiles, then one with a comment added tovk_present_rect.h: 5 files compiled (the four above, andvk_hangdump.cpp, which reads no repo header, so its depfile names nothing under those folders and it keeps the blob), no object left pending; with the comment taken out again, 0 files. That game, launched headless through the control bridge from a save: in play in Kokiri Forest, 27–34 fps over five samples, nothing in the log about a lost device or a crash.Testing
Tested: the runs under Measurements (on the GitHub version) and the game-free checks this description names. Checked but not measured: the game on Windows (above): the change is build-only, and nothing in play was compared with
main.Not tested: Linux. gcc and clang write the same make-style depfile.
Needs other testers:
gpu/vkheader, expecting only the renderer files that include it compiled again (request to open)Screenshots
Nothing on screen.
Risk and rollback
rekey_depfilescover a header read for the first time; the remaining limit is make's and ninja's: a newly added header that shadows another earlier in the include path isn't seen until something the file reads changes.Reviewer notes
Carried over from NotRexed/Hookshot#2706 with the move to Longshot: the same change on Longshot's
main, with its rename applied. Its review and discussion are there (reviewed by Joey-Magnus, jordanella).run_all.py): every check that readsbuild.py(39), on Windows, passes apart fromtest_driver_cache_folder,test_fpx_stickyandtest_linux_update, which fail the same way onmainthere.tests/test_renderer_depfiles.py: the depfile read as clang 23 writes it on Windows (/and\in paths with spaces, CRLF continuations), plus$$and\#;-MDin no key; no depfile keeps the blob; an unread header or one outside the folders changes nothing, while a read header or a gone one changes the key; the re-keying, and that it leaves alone an object not of this build; the wiring; and hckrman101's four steps, with a stand-in compiler that writes the headers it read into the object and a real depfile (on the previous commit step 4 got back step 2's object, built with the oldb.h). It fails againstmain'sbuild.py.test_dlss_sdk_cache.pyandtest_shader_stamp_cache.pystill take an olderbuild.py(--build-script), andtest_shader_stamp_cachepasses againstmain's.Issues
None.
Checklist
For everyone
type(scope): description).main.python -I -B tests/run_all.pyrun and passing (any failure that also fails onmainis named above).third_party/untouched (a new folder with aPROVENANCE.mdinstead).If applicable
Assisted-by:/Co-Authored-By:trailers.docs/tested-configurations.mdfor each measured run.MKWVK_API_VERSIONbumped (gpu/vk/vk_api.h'sMkwVkHostorMkwVkRendererchanged).mainand passing here.tests/that reads changed source updated in this PR, not weakened.🤖 Generated with Claude Code
perf(build): a renderer header edit compiles the files that read it, not the whole back endto WIP: perf(build): a renderer header edit compiles the files that read it, not the whole back endBack to WIP under #48's process: this was carried over before the new template. Its description will be brought to the template and measured on Longshot (main against this PR, at named commits) when it's wanted for review; ask here if you'd like it sooner.
Description brought to Longshot's PR template (#48). Still WIP: its numbers are from the GitHub version, and it isn't rebased on current main; it gets measured on Longshot (main against this PR, at named commits) before it is marked ready.
Description moved to the template's Testing section and whole checklist (#72): what was tested, what wasn't, and what needs other testers (their test requests to open while this is WIP).
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.