perf(build): a source whose size, time and id are unchanged is not read again to name its object #2702
Closed
github-sync
wants to merge 1 commit from
github/pr/2702 into main
pull from: github/pr/2702
merge into: MagicBeanDev:main
MagicBeanDev:main
MagicBeanDev:github/pr/2893
MagicBeanDev:github/pr/2890
MagicBeanDev:github/pr/2887
MagicBeanDev:github/pr/2878
MagicBeanDev:github/pr/2875
MagicBeanDev:github/pr/2874
MagicBeanDev:github/pr/2873
MagicBeanDev:github/pr/2871
MagicBeanDev:github/pr/2756
MagicBeanDev:github/pr/2897
MagicBeanDev:github/pr/2896
MagicBeanDev:github/pr/2718
MagicBeanDev:github/pr/2842
MagicBeanDev:github/pr/2691
MagicBeanDev:github/pr/2895
MagicBeanDev:github/pr/2743
MagicBeanDev:github/pr/2765
MagicBeanDev:github/pr/2708
MagicBeanDev:github/pr/2732
MagicBeanDev:github/pr/2755
MagicBeanDev:github/pr/2817
MagicBeanDev:github/pr/2876
MagicBeanDev:release-please--branches--main
MagicBeanDev:release-please--branches--main--release-notes
MagicBeanDev:github/pr/2778
MagicBeanDev:github/pr/2888
MagicBeanDev:github/pr/2866
MagicBeanDev:github/pr/2877
MagicBeanDev:github/pr/2800
MagicBeanDev:github/pr/2829
MagicBeanDev:github/pr/2850
MagicBeanDev:github/pr/2889
MagicBeanDev:github/pr/2882
MagicBeanDev:github/pr/2860
MagicBeanDev:github/pr/2849
MagicBeanDev:github/pr/2886
MagicBeanDev:github/pr/2794
MagicBeanDev:github/pr/2840
MagicBeanDev:github/pr/2830
MagicBeanDev:github/pr/2834
MagicBeanDev:github/pr/2719
MagicBeanDev:github/pr/2742
MagicBeanDev:github/pr/2741
MagicBeanDev:github/pr/2820
MagicBeanDev:github/pr/2771
MagicBeanDev:github/pr/2859
MagicBeanDev:github/pr/2858
MagicBeanDev:github/pr/2823
MagicBeanDev:github/pr/2757
MagicBeanDev:github/pr/2769
MagicBeanDev:github/pr/2844
MagicBeanDev:github/pr/2843
MagicBeanDev:github/pr/2673
MagicBeanDev:github/pr/2855
MagicBeanDev:github/pr/2739
MagicBeanDev:github/pr/2807
MagicBeanDev:github/pr/2851
MagicBeanDev:github/pr/2789
MagicBeanDev:github/pr/2814
MagicBeanDev:github/pr/2818
MagicBeanDev:github/pr/2774
MagicBeanDev:github/pr/2772
MagicBeanDev:github/pr/2750
MagicBeanDev:github/pr/2786
MagicBeanDev:github/pr/2785
MagicBeanDev:github/pr/2782
MagicBeanDev:github/pr/2779
MagicBeanDev:github/pr/2775
MagicBeanDev:github/pr/2706
MagicBeanDev:github/pr/2766
MagicBeanDev:github/pr/2747
MagicBeanDev:github/pr/2759
MagicBeanDev:github/pr/2745
MagicBeanDev:github/pr/2740
MagicBeanDev:github/pr/2733
MagicBeanDev:github/pr/2725
MagicBeanDev:github/pr/2727
MagicBeanDev:github/pr/2728
MagicBeanDev:github/pr/2729
MagicBeanDev:github/pr/2721
MagicBeanDev:github/pr/2722
MagicBeanDev:github/pr/2715
MagicBeanDev:github/pr/2714
MagicBeanDev:github/pr/2707
MagicBeanDev:github/pr/2703
MagicBeanDev:github/pr/2705
MagicBeanDev:github/pr/2697
MagicBeanDev:github/pr/2679
MagicBeanDev:github/pr/2676
MagicBeanDev:github/pr/2669
MagicBeanDev:docs/what-hookshot-connects-to
MagicBeanDev:fix/hdr-encode-test
MagicBeanDev:fix/main-tests
MagicBeanDev:fix/play-cache-files
MagicBeanDev:perf/game-barrier-order
MagicBeanDev:feat/heap-lazy
MagicBeanDev:feat/texture-detail
MagicBeanDev:perf/astc-opaque-bc1
MagicBeanDev:fix/fs-dir-lock
MagicBeanDev:fix/framegen-native-kept
MagicBeanDev:fix/update-no-downgrade
MagicBeanDev:port/k10-gcn-f16-mirrors
MagicBeanDev:fix/framegen-mult-cap
MagicBeanDev:chore/release-as-2.1.1
MagicBeanDev:perf/pcache-load-switch
MagicBeanDev:fix/prepare-progress-log
MagicBeanDev:fix/update-closes-stale-game
MagicBeanDev:fix/hdr-scaled-sampled
MagicBeanDev:perf/first-start-preset
MagicBeanDev:perf/zero-upload
MagicBeanDev:fix/vcore-escape-2s
MagicBeanDev:test/fake-gh-atomic
MagicBeanDev:perf/batch-idle-flush
MagicBeanDev:test/finish-stub-a
MagicBeanDev:chore/record-2.1.0
MagicBeanDev:fix/main-red-tests
MagicBeanDev:fix/test-display-startup-driver-cache
MagicBeanDev:feat/mesh-shader-mode
MagicBeanDev:fix/menu-probes-at-startup
MagicBeanDev:fix/fps-counter-classic
MagicBeanDev:fix/test-log-batch-flake
MagicBeanDev:fix/narrow-screen-hud
MagicBeanDev:ci/prereleases
MagicBeanDev:release/v2.0.15
MagicBeanDev:hotfix/v2.0.15
MagicBeanDev:fix/present-ahead-replay
MagicBeanDev:release/v2.0.13
MagicBeanDev:fix/bracket-paths-2013
MagicBeanDev:fix/hdr-overlays-2013
MagicBeanDev:fix/fps-counter-scale-2013
MagicBeanDev:fix/stick-seen-at-rest
MagicBeanDev:hotfix/menu-fits-screen
MagicBeanDev:fix/f1-always-opens-menu
MagicBeanDev:fix/ini-keep-lines
MagicBeanDev:claude/cranky-pike-7cf247
MagicBeanDev:perf/texture-answer-flat
MagicBeanDev:fix/stamp-test-modules
MagicBeanDev:fix/appimage-fonts
MagicBeanDev:fix/display-awake
MagicBeanDev:release/v2.0.12
MagicBeanDev:fix/discord-windows
MagicBeanDev:rc/v2.0.12-tests
MagicBeanDev:fix/dlss-keep-feature
MagicBeanDev:rc/v2.0.12
MagicBeanDev:button-icons
No reviewers
Labels
Clear labels
accessibility
Barrier affecting people with disabilities
autorelease: pending
autorelease: tagged
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
duplicate
This issue or pull request already exists
enhancement
New feature or request
github_actions
Pull requests that update GitHub Actions code
good first issue
Good for newcomers
help wanted
Extra attention is needed
invalid
This doesn't seem right
question
Further information is requested
testing wanted
wontfix
This will not be worked on
No labels
accessibility
autorelease: pending
autorelease: tagged
bug
dependencies
documentation
duplicate
enhancement
github_actions
good first issue
help wanted
invalid
question
testing wanted
wontfix
Milestone
Clear milestone
No items
No milestone
Assignees
Clear assignees
No assignees
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Hookshot!2702
Loading…
Reference in a new issue
No description provided.
Delete branch "github/pr/2702"
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?
Every build reads and hashes each source again to name its object, and the 1.4 GB of lifted C up to three times:
migrate_stamps, the log's fingerprint andplan_jobs. On Windows that planning was 6–7.5 s of a one-file renderer edit's ~31 s build, as #2693's table shows. This is the dev-loop proposal's A5 (#2636).Change
build.pykeeps<build>/hash_cache.json. For each source it holds the size, modification time and file id, the content's sha1, and the object key worked out from it for each set of flags and headers (kept_part).key_of()returns that key without reading the file while all three match, and otherwise reads and hashes the file as before.object_key, the key's definition, is unchanged, so every object's key, every object cache and every player's kept translation stays as it is.plan_jobsand the kept list usekey_of. The log's fingerprint uses the recorded sha1, so its value changes once, and it still says which part changed.migrate_stampsreads nothing stamped with today's kind of key, since that key's object is in the cache.make_game.py's builds run (HOOKSHOT_TIMES). A barebuild.pyrun without it hashes incompile_oneas before.Measured
On Windows (Ryzen 9 3900X, NVMe), three one-file
gpu/vk/vk_draw.cppedit builds in a row, with #2693's table:Each build still compiled the edited file.
Testing
tests/test_build_hash_cache.py(new, 9 cases):object_key, and the next build doesn't read the source;migrate_stampsreads nothing already stamped with today's kind of key;mainwires it in that order.All fail against
main'sbuild.py.The checks that cut functions out of
build.py(test_compile_retry_jobs,test_dlss_sdk_cache,test_shader_stamp_cache) pass unchanged, sinceobject_keyandcompile_oneare as they were.Every check that reads
build.py(39), on Windows, passes apart fromtest_driver_cache_folder,test_fpx_stickyandtest_linux_update, which fail the same way withmain'sbuild.pyhere.Not tested: Linux. The file id there is the inode, as
os.statgives it.🤖 Generated with Claude Code
github-sync referenced this pull request2026-11-12 09:32:09 +00:00
This is the time of the save, after
plan_jobsstat'd and read every source (seconds earlier on a first build). For the 2 s rule to mean "the file was read at least one timestamp tick after it was written", this should be the time before the first stat of this build, e.g.time.time_ns()taken inload_hashesand kept for the save. Non-blocking: with ns/100 ns mtimes it's theoretical.Thanks, this is a clean A5. The key's definition is untouched (
key_ofcomputes exactly whatobject_keydoes, just from a remembered sha1 when size, mtime and file id all match), so no cached object or kept translation gets renamed, and a miss falls straight back to reading the file. Themigrate_stampsshortcut is sound too: an old-kind stamp can't name an object in the cache, so skipping stamps whose object is already cached only skips work that would have done nothing. The 6 s to 2 s planning numbers on the same one-file edit are what I wanted to see, and CI is green.Two non-blocking points:
written_nsis taken when the record is saved, after the whole plan, while each file was stat'd and read earlier, up to the ~6 s planning time before. Git's rule works because the index's time is close to the stat. Taking the time once before the first stat (e.g. inload_hashes, or at the start ofmain) and saving that would keep the 2 s rule exact even on a filesystem with coarse timestamps (exFAT, some network shares). It only matters for an edit landing in the same timestamp tick right after the read, so on NTFS/ext4 it's theoretical, but it's a one-line change.save_hasheskeeps every entry still on disk and everykept_parteach entry has seen.kept_partincludes the headers, so each edit to a header undergpu/vkadds one key to every renderer source that isn't itself touched. It's small per edit, but saving only the entries and keys this build used would keep the file (and the JSON parse every build) bounded.A Linux dev-loop run would be nice to have in the description when you get a chance (it should behave the same, as
st_inois the inode there), but I don't see anything platform-specific that would change. #2706 also changesbuild.py(and how the renderer's headers feed the key), so whichever of the two lands second may need a small merge.