fix(builder): the build's percentage no longer goes back when its time estimate grows #3076
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!3076
Loadingβ¦
Reference in a new issue
No description provided.
Delete branch "llun/Longshot:fix/build-progress-never-back"
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?
Summary
While the game builds, the percentage could go backwards: one player's build fell from 65% to 43%, then from 54% to 42%. Nothing was lost. The builder works the percentage out as the time spent over the time spent and the estimated time left, so a larger estimate lowered it.
The percentage now keeps the highest value said. It goes back only when shaders counted as ready or running have to be prepared from the start. The time left is unchanged and can still grow.
To see it on main: build the game on a PC whose shader step runs slower than the builder's fixed first guess (311 s). When the first 5% of the step is done, the percentage falls.
Read
Forecast::snapshotandForecast::shaders_cachedinbuilder/crates/build-core/src/report/forecast.rs.Testing
Tested: Windows 11, RTX 5080, NVIDIA 621.47, Ryzen 9 9900X3D.
longshot-builder dev build,--compile-shaders most, no upscaler) at6a8f5b3db: 959 percentage updates, none lower than the one before. The shader step was slower than the first guess, so the estimate grew as in the player's build.dev.py smoke): in play fromkokiri-start, 900 frames, the menu opened, no fatal line.a_larger_estimate_never_takes_the_percentage_backfails on main's code and passes here. Without the hold, or without the reset, a test fails.cargo test -p build-core -p build-driver -p longshot-builderat6a8f5b3db: 483 passed, 0 failed, 1 ignored. Clippy and rustfmt onbuild-core: pass.Reporterat real speed (13.5 min), before the rebase: numbers below.mise run testwith this change, before the rebase ontob4d56f526(#3070, a menu change); not run again after it: 830 passed, 2 failed, 51 skipped.test_i18n_complete.py(the ReShade preset names): fails on main @b4d56f526too.test_lifter.py, atbuild-tools'cargo_gets_the_toolchain_and_none_of_the_pc_s_settings: an earlier version of this text called it a failure of main. It came fromCC_,CXX_andAR_x86_64_pc_windows_gnullvmset in my shell, and cargo stopped there.test_lifter.py's three steps again at6a8f5b3dbwithout those three variables (gnullvm Rust,cargo test --release --workspace --no-fail-fast): rustfmt and Clippy pass; 3,420 passed, 2 failed, 6 ignored. Thebuild-toolstest passes.sites'every_site_has_one_owner_and_the_sites_are_the_ones_before_the_split: fails on main @b4d56f526too (#3078's run); #3083 fixes it.modtool'severy_example_passes_its_tests(theseven-rupeeexample's name test): failed once in that full run, then passed 3 of 3 run by itself. Not run on main. This change touches neither it nor what it reads.Still to test:
Measurements
Verdict: the percentage no longer falls: 114 drops before and 0 after in the replay, 0 in a real build. The time left is the same.
Setup: Windows 11, Ryzen 9 9900X3D, RTX 5080, NVIDIA 621.47. The replay: a player's build (9 workers, cold shaders, 810 s of its log) through
Reporterat its own speed, one run of each side, side by side; the old side matches the player's log within 0.001 points. The real build: one run of this PR only.2ca7d4f74670b8dba3 is this change before its rebase,
6a8f5b3dbafter it. The numbers still hold: the patch is the same, and main's only change between (#3070) is the game's menu and a user page, nothing inbuilder/. The real build at6a8f5b3db: 0 falls in 959 updates. From its time spent and time left, main's formula gives 53.7% to 32.8% when the shader estimate grew from 295 to 703 s; this PR stayed at 53.8% for 107 s.Risks
The bar can pause where it fell before: 107 s at 53.8% in the real build, about 4 minutes at 65% in the replay. A revert is enough. Nothing changes for a player's saves, settings or caches.
Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.π€ Generated with Claude Code
Tested in game: Windows 11, RTX 5080, NVIDIA 621.47: a real first build from empty caches with this change (959 percentage updates, none lower than the one before), then the game from that build (dev.py smoke, kokiri-start): in play, 900 frames, the menu opened, no fatal line.
Possibly related, for context:
@review
Recommendation: Approve. The forecast holds the percentage through growing estimates, and the reported build and replay show the original drop is gone. A rare early-shader fallback can still release the hold without any shader work having been counted, and the requested Launcher run remains outstanding. Nothing blocking is left: what remains is for the author before merging (below). Recommend approval; not approved on the forge.
The builder retains the highest reported overall percentage until it learns that previously counted shader work must be redone. This avoids backward progress at the cost of potentially long pauses in the bar; the reported real build paused for 107 seconds.
Should fix (1): not blocking, but worth doing before merging.
builder/crates/build-core/src/report/forecast.rs:67: The presence of an early shader worker resets the hold even when that worker never reported progress and its work was never counted. (more on the line) Do: Track whether cached or parallel shader work actually reduced a reported forecast and reset the hold only when that counted work is invalidated; cover the unstaged fallback with a test.Testing before merging (1) (the change behaves the same on every system: one run of the change itself is enough; it doesn't hold the recommendation)
@fixcan do L1.Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes. The reported replay had 114 percentage drops on main and none with the change; a real build at HEAD had none in 959 updates. The replay used one run per side, and the time-left difference was 0 seconds.
Other systems: The same forecast feeds JSON consumers and the builder's own progress display. The state is protected by the Reporter mutex; shader progress is sampled through its own mutex. The change does not alter build work, shader output, game runtime, paths or saved data.
Switches: None added, changed or removed.
Reviewed:
6a8f5b3dbdagainstb4d56f5264: Read AGENTS.md, CONTRIBUTING.md, the PR template, standards, both changed files in full, the commits and diff, and the relevant Reporter, builder, shader preparation and display paths. Read the fix-with-test rules. No review-checklist file or sibling Tooling checkout was present. Skimmed the surrounding builder code; no translations, generated files or recorded run artifacts changed.; nothing run (a code review).Checked and fine:
Testing: Read-only review; no code, tests or project scripts were run. The author reports 483 Rust tests passing at HEAD and a successful Windows build and smoke run. CI is still running.
Overlaps and merge order: Not checked; network access is unavailable.
Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.
@ -61,6 +64,10 @@ impl Forecast {}pub(super) fn shaders_cached(&mut self, cached: bool) {if !cached && (self.shaders_cached || self.parallel_shaders.is_some()) {L1 (should fix): The presence of an early shader worker resets the hold even when that worker never reported progress and its work was never counted.
When: On Linux, an early worker can fail to stage its files and fall back to normal preparation without reporting progress. If an earlier compiler ETA increase has already made the raw forecast lower than the held percentage, prepare_unless_kept reports an uncached result and this reset lets the next update fall, although no counted shader work was lost.
Do: Track whether cached or parallel shader work actually reduced a reported forecast and reset the hold only when that counted work is invalidated; cover the unstaged fallback with a test.
L1: no change. The hold does reset there, but the percentage can't fall.
Until the early worker reports progress, every update counts the whole shader step (311 s) as time left. So the percentage held so far is never higher than
time spent / (time spent + 311 s + game start). The reset comes fromprepare_unless_kept. The next update is the shader stage starting (or running), and its percentage is exactly that formula with more time spent. So it is the same or higher, even if the compiler's estimate grew earlier.Checked at
6a8f5b3dbwith a temporary test on the realForecast(not committed):The timings varied the compiler's estimates (growing and shrinking), the length of the stages and the game start.
L2: agreed. The Launcher run hasn't been done. It stays under Still to test.
@review
Recommendation: Approve. The code is ready: only testing is left (a run of the change itself). The reported build and replay show that the percentage no longer falls when the estimate grows. The cold build through the Launcher remains to be observed. Recommend approval; not approved on the forge.
The builder holds the highest reported percentage when its estimate grows, while retaining the existing time-left estimate. The bar can pause for several minutes; the change is small and includes a regression test and documentation.
Testing before merging (1) (the change behaves the same on every system: one run of the change itself is enough; it doesn't hold the recommendation)
Since the last review (on
6a8f5b3dbd)Withdrawn (it was wrong): L1 (The presence of an early shader worker resets the hold even when that worker never reporteβ¦)
Still open: L2 (The cold build through the Launcher listed under Still to test has not yet been observed.)
Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes. The reported replay fell 114 times before and zero times after; a real build at this head had zero falls in 959 updates. The replay showed no change in the time-left estimate.
Other systems: The Launcher consumes the changed build-progress events; a cold build through it is still untested. The forecast is shared across platforms, and the reported real build was on Windows.
Switches: None.
Reviewed:
6a8f5b3dbdagainstb4d56f5264: Read forecast.rs and its diff in full, the changed build-events documentation, the repository rules, pull request template, commits, relevant Reporter and shader-preparation callers, comments and reported runs. The remaining build-driver and Reporter code was skimmed. docs/review-checklist.md and the adjacent Tooling checkout were unavailable.; nothing run (a code review).Checked and fine:
Testing: No commands that run project code or tests were executed. The author reports 483 Rust tests passing, a real Windows build, and a game smoke run; CI is still running.
Overlaps and merge order: Not checked; the network is closed.
Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.