fix(build): a new work folder's second build no longer translates the game again #2674
Closed
github-sync
wants to merge 2 commits from
github/pr/2674 into main
pull from: github/pr/2674
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!2674
Loading…
Reference in a new issue
No description provided.
Delete branch "github/pr/2674"
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?
In a new work folder (a fresh worktree, or a player's new install), the second build translates the whole game again even though nothing changed: 319 s for a no-op rebuild on Windows, 290 s of it the lift. For players, the first update after a new install doesn't get to keep the translation (#2324).
Cause
lift_keyhashesimage/hot_pieces.txt, split_hot's kept pieces, and the first lift in a work folder is what writes that file. The key was taken before that lift and stored after it. So the next build, which now findshot_pieces.txt, computes another key and translates again. After that the key is stable, which is why the problem only shows once per folder.Change
translate()takes the key again after the lift and split_hot, from the files the next build will read, and stores that one.keep_translationuses it too (nonlocal key).Testing
tests/test_lift_cache.py:E:\Hobby Development\...). It now reads by lines. CI's paths have no spaces, so CI was not affected.tests/test_lift_cleanup_error.pyruns the fresh-lift branch with stubs; it now stands in forlift_keyand expects lift → key taken again → key written. Againstmain'smake_game.pyit fails, with the change it passes.mainat0ec31ff6plus this change): in a work folder with nohot_pieces.txtand no key, the first build took 315 s (the lift is needed) and the second 14 s, skipping the lift. Without the change, the second took 319 s.run_all.pyon Windows: every check that readsmake_game.py(52) passes, apart fromtest_cpp_preflight,test_linux_updateandtest_prepare_stall, which fail the same way on a cleanmainhere.Not tested
A player's update through the Builder end to end. It takes the same path in
make_game.py(keep_translation, thenkept_beforewith this key), but I haven't run it through the Builder.Part of the dev-loop proposal's Phase 0 (#2636).
🤖 Generated with Claude Code
github-sync referenced this pull request2026-11-12 06:22:54 +00:00
One case to close before this merges; the fix itself does what it says (the second build in a new work folder no longer translates again).
The self-produced
hot_pieces.txtfix is sound, but recomputing the whole key at7a561e39:nx2/make_game.py:2181–2182can certify output made from an older tracked input.I reproduced this without a game: real production key/stamp/cache-predicate functions and the actual
translate()AST, with tiny authored files and stand-ins only for the lift/split children (the fixture; it reads both commits from a clone).nx2/lift.pyinput and emits OLD output.chunks.txt/hot_pieces.txtnormally.lifted_beforepredicate about the current inputs.Observed Linux/Python 3.12 fixture output (
next_liftcounts child calls in that second build):The base stamped the pre-lift key, so the changed input safely forced the next lift; this PR stamps the changed-input key over OLD output.
An in-memory observation comparing non-self inputs before/after and refusing to stamp when they change fixes this case; the self-file-only control still skips the second lift, preserving your intended improvement.
Please refresh the self-produced planning inputs only after confirming the remaining inputs are unchanged, or use an immutable input snapshot.
This window requires a tracked input to change during a lift—for example an edit while its minutes of work run—not an ordinary unchanged build; no compiler, game or GPU was used.
Thanks, this is a clean fix and the cause is explained well.
I checked the parts that have to hold for it to be safe:
lift_keyhashesimage/hot_pieces.txt, andsplit_hotwrites it during the lift. The cleanup step removessaandprobebut leavesimage/, so the next build hashes the same file.build.pywrites its kept list header from.lift_key(lift_key_of), which now holds the new key, andkeep_translationchecks against the same key throughnonlocal key. So the player'skept_beforepath agrees with the dev path.prevequal to the pieces this lift just saved and the same bodies,sticky_splitputs every function back in its own piece. Its largest cost then equals the fresh split's, so the sticky split wins, and each piece is written assorted(names). The relift would write the same C, so the claim in the description holds. A stalehot_pieces.txtthat split_hot dropped as out of balance is handled too: the key now picks up the rewritten file.test_lift_cleanup_errorcompiles only theif lifted_beforebranch, sokey = lift_key(...)rebinds the key in the test's namespace, and the stub sees exactly onerekeybetweenliftandkey. Thesplitlines()fix intest_lift_cacheis a real fix for checkouts whose path has a space in it.Re-hashing costs one extra
lift_keycall (an import walk and hashes of a few files) after a lift that takes minutes anyway, so that's fine.CI: when I looked, the Python source checks on Windows (both parts) and Ubuntu part 2/2 were still running, along with the Builder package and DLSS/FSR link check jobs. Everything finished so far passes. Good to merge once those are green (Windows part 2/2 currently fails on main on test_psychov35/test_pcache_header_read; those failures aren't from this PR).
Thanks, @mooki000: you're right, and I missed that window. Taking the whole key after the lift lets a translator file edited mid-lift vouch for C made from the old one. #2686 does what you suggested. It snapshots everything but the lift's own planning files (
lift_key(..., planning=False)) as the lift starts, compares after it, and takes the key again only if nothing else changed; otherwise the pre-lift key stays and the next build relifts, as on the base.test_lift_cleanup_error.pyhas the mid-lift edit as a case, and it fails onmain. I couldn't run your gist fixture here (this machine's tool permissions), so a run of it against #2686's head would be very welcome.