WIP: perf(build): skip unchanged links, write compile_commands.json, key the hot pieces by the profile's contents #30
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!30
Loading…
Reference in a new issue
No description provided.
Delete branch "dyst/Longshot:perf/link-skip"
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
A build with nothing to compile still relinked the 440 MB executable and the renderer, a build from a second checkout of the same tree recompiled all eight hot pieces (~10-20 minutes) because their keys named the play profile by its path, and clangd had no compile database.
What changed
run_linkinnx2/build.pyskips a link whose inputs are the last successful one's.link_keyhashes the command, the compiler (its size and time) and the work folder'ssystem_headers.txt; each object's key (its.o.sha1, or its size and time without one); and the contents of the other files the command names, inside options too (link_inputs: the@response files, the hot symbol order, the libraries, the resources; not the output or a.map). The key is kept beside the output as<output>.linkkeywith the output's size; a failed link, or an output of another size or gone, links again. The three links inmaingo through it (the executable's, the renderer's and the game DLL's). (A4)write_compdbwrites every compile ascompile_oneruns it to the build folder'scompile_commands.json, for clangd and clang-tidy; a failure to write it does not fail the build..gitignoreignores/compile_commands.jsonat the checkout's top, for a copy there. (A8)flag_textleaves the path of-fprofile-instr-use=out of the hot pieces' object keys, since-DLONGSHOT_PROFILE_SHA1beside it already says what the key needs of the profile. This changes their keys once.nx2/build.pyimportsre(GitHub'smaindidn't; NotRexed/Hookshot#2706 adds it too).tests/test_link_skip.py(new) runs a stand-in linker through the realrun_link: the same inputs aren't linked again; a changed object, library or symbol order is; so is an output of another size or gone; a failed link forgets its key; the files inside options are inputs; the compile commands are the compiles; the build's links go through it.tests/test_profile_path_key.py(new): two paths, one profile give one key; another profile, another key; every use of the profile's path names its contents too.Flags and settings
None.
Measurements
Measured on the GitHub version (NotRexed/Hookshot#2893), not yet on Longshot: this PR stays WIP until it is.
Hardware: Ryzen 9 3900X, Windows 11 (as the GitHub description states it), a dev work folder.
Method: the GitHub description gives one figure for each side and does not say how many runs.
One renderer edit, on this PR: only the renderer's link runs (no figure for
main).Testing
Tested: the runs under Measurements (on the GitHub version) and the game-free checks this description names. Checked but not measured: every build the author ran in the game that day used this
build.py. The latest: Windows 11, RTX 3080 (NVIDIA 621.14), a dev-profile build, from a save, headless through the control bridge: in play in Kokiri Forest, 28-31 fps, nothing in the log about a lost device or a crash. A skipped link leaves the same binary in place.Not tested: Linux.
Needs other testers:
compile_commands.jsonwritten (request to open)Screenshots
Nothing on screen.
Risk and rollback
A link that should have run but was skipped would leave an old binary in place: the key covers the command, the compiler, each object's key and the files the command names, and deleting
<output>.linkkeymakes the next build link again. The hot pieces' new keys compile the eight hot pieces once after this lands. Reverting the commit is enough.Reviewer notes
Carried over from NotRexed/Hookshot#2893 with the move to Longshot: the same change on Longshot's
main, with its rename applied. Its review and discussion are there.Three small changes to
nx2/build.pyfrom the dev-loop proposal (NotRexed/Hookshot#2636, A4 and A8), in one PR because they touch the same lines; they can be split if preferred.Checks run on the GitHub version: every check that reads the changed files (37), through
run_all.py, rebased on GitHub'smainof that day, Windows: pass, apart from four that fail the same way onmainthere (test_driver_cache_folder,test_fpx_sticky,test_linux_update,nx2/test_dll.py). Only those checks were run, not the whole suite. The checks and the game runs were done on the GitHub version; this branch is the same change with the rename applied (the same files and line counts). Forgejo runs no checks; they were not run again here.Issues
None on Longshot. See NotRexed/Hookshot#2636 (A4, A8).
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): skip unchanged links, write compile_commands.json, key the hot pieces by the profile's contentsto WIP: perf(build): skip unchanged links, write compile_commands.json, key the hot pieces by the profile's contentsBack 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.