fix(build): the giant function's estimate covers its measured peak #2248
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
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
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2248
Loading…
Reference in a new issue
No description provided.
Delete branch "dazemc/Longshot:mem-need-giant"
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
mem_needis the build's compiler-memory estimate, and it charged a lifted chunk400 + 50 × MB of C + 250 × MB of its largest function. The units probe found that under-estimates the giant shape:code_024_1.c, 6.2994 MB of C with a 6.2449 MB function, peaked at 2,946 MB, while the formula charged 2,276 MB (1.29× under). On a memory-tight PC the gate can therefore start a compiler that does not fit.This changes the largest-function coefficient to 360 MB/MB, so that shape charges 2,963 MB, just over the measured peak. The coefficient is a named constant (
LARGEST_FUNCTION_MB) so the measured-peak refit in #2239 can take it without restating the number; #2239 is not edited.This is a build-correctness fix, not a perf change: it can make the gate start fewer compilers for a giant shape, never more, and it claims no build-time gain.
Why 360 and not the rounded 339: 339 comes from the 6.6 MB file size shown by the probe. On the parsed 6.2449 MB largest function it charges 2,831 MB, 114 MB short of the 2,946 MB peak; 2,848 MB is 339 at the test stand-in's 6.29 MB function. Neither reaches the peak.
Read first:
mem_needandlargest_functioninnx2/build.py, then the new check intests/test_mem_gate.py.See #2239 (the measured-peak refit) and #362 (the earlier memory-gate formula work).
AI assistance: written with an AI agent (OpenCode, DeepSeek V4.1 Flash).
Testing
Tested: Linux, this PC, game-free. No game run is needed:
mem_needis read only byMemoryGate.enter; it is in no flag, object key, lift key orchunks.txtentry, so the built objects and game binary are identical with and without the change.python -I -B tests/test_mem_gate.pyon the test-only commit3afc8055fails withFAIL: a giant function's need covers its measured peak (2288 MB against 2946 MB)(the check's 6,600,000-byte stand-in at 250 MB/MB); on the fix487520d4it passes:mem_needis 2,980 MB for that 6.294 MiB stand-in, above the 2,946 MB peak. The 2,963 MB figure is the units probe filecode_024_1.c(6.2994 MB of C, 6.2449 MB largest function), not the stand-in.tests/test_mem_gate_leases.pyandtests/test_mem_limit.pyalso pass.Full suite recorded at the pre-rebase head
6350aa0bona2dc5385:mise run test -- --jobs 5underMemoryMax=12G, 911 passed, 23 failed, 18 skipped in 410 s (Linux, 5 at once). All 23 failures are thea2dc5385baseline names:The head is a byte-identical rebase of
nx2/build.pyandtests/test_mem_gate.pyonto8aa5ab87, which includesfe1c437c(#2213) that rewrote 17 of the 23 named files and reportsmainback to one failure (test_dev_packs). The suite has now run at this head:942 passed, 19 failed, 18 skipped in 405 s (linux, 5 at once), its 19 failures exactly the CORE ids of SUITE-COMPARISON-RULE's Amendment 1 table; see themise run testbox.Still to test:
python -I -B tests/test_mem_gate.pyby hand or CI, expecting the same pass; the formula is platform-independent. No farm request is needed for a game-free check.Measurements
Verdict: the estimate now covers the measured giant: 2,276 MB before against a 2,946 MB peak (1.29× under), 2,963 MB after (0.6% over). This is an estimate correction, not a speed gain; no build wall-clock A/B was run.
Setup: Linux, clang 23, the units run's lift, one compiler at a time, the compiler tree's peak RSS. The file is the units run's
code_024_1.c(6.2994 MB of C, largest function 6.2449 MB).753fb5af487520d4code_024_1.cgit diff a2dc5385..753fb5af -- nx2/build.py tests/test_mem_gate.pyis empty, andmem_needhas the same body at753fb5afand8aa5ab87(sha256891f106ee27a4663f0009f240c08d20dc80d15ac55d60411e6eb4c44321357a6;tests/test_mem_gate.pyis unchanged between them), so the 2,276 MB before value computed ata2dc5385is exactly what current main (8aa5ab87) computes. The estimate and the focused check are base-independent; the suite is the part that moved (fe1c437crewrote 17 of the 23 named files), and it has now run at this head, as Testing says.No build A/B: the change only moves the gate's admission for a shape with a large function; it does not change the compile, the objects or the binary. A build with the same jobs and free memory may start the same number of compilers; the fix is that a giant is no longer under-reserved.
The fix's measurement is the test:
3afc8055fails onmain(2288 MB against 2946 MB) and487520d4passes (2,980 MB for the check's 6,600,000-byte stand-in; the probe's 2,963 MB is the table above); the focused check passes again at the rebased head. No build-time or size A/B is claimed; this estimator change cannot make a build faster and may start fewer compilers.Risks
longshot_options.ini, the shader cache and the pipeline cache are untouched. Only the build's memory estimate changes.fitsadmits a second 2,963 MB compile once 7,462 MiB is free (2 × 2,963 + 1,536).Checklist
Ready for review
main; the title is a Conventional Commit. The merge base is8aa5ab876d7cc3d5a19850f3cf7f29b2172c1863, which is currentmain, and heade0e7315cis that plus this PR's two commits (28f710b9the check,e0e7315cthe fix). One topic:git diff --stat origin/main...HEADisnx2/build.py9 lines andtests/test_mem_gate.py9 lines (2 files, +15/−3), the giant function's memory estimate and its check; the title isfix(build): .... No rebase remains: the head already containsmain.mise run testpasses (any failure that also fails onmainis named). Suite ate0e7315c5374ae4d2dedeba0a83525c7f7549121: 942 passed, 19 failed, 18 skipped in 405 s (linux, 5 at once), exit 1. All 19 failures are CORE ids in SUITE-COMPARISON-RULE's Amendment 1 table and carry their recorded exception classes (tests/test_amd_subgroup_profiles.py,tests/test_appimage_package_retry.py,tests/test_cpm_discovery.py,tests/test_crt_options.py,tests/test_dev_packs.py,tests/test_flat_map.py,tests/test_guest_holes.py,tests/test_menu_save_atomic.py,tests/test_menu_text_field.py,tests/test_nonuniform_image_arrays.py,tests/test_pipeline_share.py,tests/test_rdna2_mesh_only.py,tests/test_readback_timeout_source.py,tests/test_rumble_menu.py,tests/test_shader_profile_caps.py,tests/test_target_image_reuse.py,tests/test_vibration_menu.py,tests/test_vram_compact.py,tests/test_wb_spans.py). No id outside CORE ∪ FLAKY failed, and the five FLAKY ids (tests/test_crash_record.py,tests/test_seed_reader.py,tests/test_program_cache_reader.py,tests/test_audio_source.py,tests/test_heart_containers.py) all passed here. Counts are not compared (Amendment 1). Logprrefresh-logs/suite-2248-e0e7315c.log, sha2564e056e1b1cde18ded572c26b2877ad5102d8373bea729adf34646e03ceb04f3c; the JUnit reconciles (979 = 961 ran + 18 skipped; 942 + 19 = 961) and the skip set is identical.main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here.tests/that reads changed source is updated, not weakened.Assisted-by:/Co-Authored-By:trailers. (Both commits now carryAssisted-by: DeepSeek V4.1 Flash; the tree hashes are unchanged.)Ready to merge
main, measured again or a comment says why the numbers still hold.909a15f4736350aa0b69Both commits amended with Assisted-by: DeepSeek V4.1 Flash and force-pushed with lease; new head
6350aa0b(testcfaa1d19). Tree content unchanged; focused game-free tests pass. The mise run test box stays unticked until the full suite runs behind #2239 A/B and #2207 suite.Full suite at
6350aa0b: mise run test -- --jobs 5 under MemoryMax=12G, 911 passed, 23 failed, 18 skipped in 410 s; all 23 failures are thea2dc5385baseline names, listed in Testing. The mise run test box is ticked; checking the ready state.Wording only: the Windows game-free check needs no farm request; the suite result and all ticked boxes are unchanged. Marking ready next.
WIP: perf(build): the giant function's estimate covers its measured peakto perf(build): the giant function's estimate covers its measured peakperf(build) with no measured build gain. The title type is
perf, whose standard is "faster, or less memory" (docs/dev/standards.md→ Titles), but this raises the gate's estimate (2,276 → 2,963 MB) and its own Risks says it can make the gate start fewer compilers. Measurements says "This is an estimate correction, not a speed gain; no build wall-clock A/B was run." For a build change the Measurements table asks for build time and size onmainand with this PR; the numbers here are the estimator against the compiler's peak RSS (tests/test_mem_gate.py:46-52), not that. Either retitle tofix(build)— the test-only commitcfaa1d19already fails onmainand passes here, which is the fix measurement — or add the clean-build time/size A/B and state the cost. The formula that changed isnx2/build.py:1009-1025.perf(build): the giant function's estimate covers its measured peakto fix(build): the giant function's estimate covers its measured peakQuality comment 73202: retitled to fix(build) and removed the perf claim. This is a build-correctness fix; its measurement is
cfaa1d19failing on main (2288 against 2946 MB) and6350aa0bpassing (2,963 MB). No build-time or size A/B is claimed; head and code are unchanged.The title and body are now fix(build) with no performance claim; the kind/performance label is stale and needs removal/replacement before merge. Evidence:
cfaa1d19fails on main (2288 against 2946 MB),6350aa0bpasses (2,963 MB), and the full suite is 911 passed / 23 failed / 18 skipped, all 23 failures in thea2dc5385baseline.6350aa0b69487520d410Rebased onto
753fb5af; no code change; new head487520d4(test3afc8055). The focused check passes at the new head; the pre-rebase suite evidence still holds because the diff is unchanged.Rebased head
487520d4is still ready and waits only on fork CI: its 10pull_requestjobs are "Blocked by required conditions" and the PR has noci: approvedlabel. No earlier fork-CI ask names this head.@HumanBean: please approve this head's fork CI runs (the Actions jobs, and the
ci: approvedlabel for the fork project) and review #2248 — the giant function's estimate covers its measured peak.Evidence is in the thread, not re-posted:
tests/test_mem_gate.pyfails onmain(2,288 against 2,946 MB) and passes here (2,963 MB), and the 20:34 comment has the focused check at the new head. The description still warns that it was measured onmaina2dc5385; itsCI passes on the head; on current main, measured againbox needs that re-check.Read-only audit of head
487520d4(nothing built or run). The code reads sound:mem_needhas one reader,MemoryGate.enter(nx2/build.py:1014,:1072), so the built objects and binary are unchanged and the game-test N/A is right; the estimate arithmetic checks out (int(400 + 50*6.2994 + 360*6.2449) = 2963, against 2276 at 250), and the new check attests/test_mem_gate.py:46-52fails on main at 2288 for the 250 coefficient, which is the reason it targets. The gaps are evidence and description, not code.1. The
mise run testbox is stale against the rebased base. It rests on6350aa0b(basea2dc5385), but the head is on753fb5af. Main'sfe1c437c(#2213, "the checks main's last commits left stale pass again") is one of the 10 commits between those bases, and it edited 17 of the 23 named failing test files; its message says it brings the suite back to one failing check,test_dev_packs. The "diff is unchanged" argument in the 20:34 comment coversnx2/build.pyandtests/test_mem_gate.py(they are indeed identical between6350aa0band487520d4), not the 17 test files #2213 rewrote. So the 23 names are thea2dc5385baseline, not the753fb5afone. What would settle it: a suite run at487520d4, or a comment naming the753fb5afbaseline (with any failures there) and why the 23 names still apply; then tick the box. Until then the box is not evidence for this head.2. The base warning is material for the suite, not for the estimate.
git diff a2dc5385..753fb5af -- nx2/build.py tests/test_mem_gate.pyis empty, so 2,276 is exactly what current main computes; Measurements can say that instead of "the diff is unchanged", which clears thepr statuswarning for the number. The part that moved is the suite.3. "339 charges about 2,848 MB" does not follow from the parsed size.
int(400 + 50*6.2994 + 339*6.2449) = 2831MB, 114 MB short, not 2,848/~100. 2,848 is 339 at 6.29 (the test stand-in's size). Restate 2,831/114, or say the 2,848 is the stand-in. It does not change 360 (2,963).4. The Testing sentence "on the fix
487520d4it passes (mem_need2,963 MB)" mixes the probe with the test stand-in. The check writes 6,600,000 bytes, a ~6.294 MiB function, so its message would read 2,980, not 2,963; 2,963 iscode_024_1.c. Say which file each number is.Minor:
kind/performanceis still on the PR although the title isfix(build)(the 13:46 comment says it needs removing); and "On this PC's 15.5 GB the giant compiles at most one at a time" is not whatfitsenforces — two 2,963 MB compiles fit above about 7.3 GiB free (nx2/build.py:1062-1069), so if that is what the units build showed, say that. What would settle it: thefree_mbsamples from that build.Ready to merge: all four are correctly unticked; CI on
487520d4is 1 passed / 10 pending ("Blocked by required conditions"), and theci: approvedask is in the 22:44 comment.Description corrected against the read-only audit (no code, no head change; head stays
487520d4on753fb5af).a2dc5385baseline at6350aa0b;fe1c437c(#2213) rewrote 17 of the 23 named files and reportsmainback to one failure (test_dev_packs), and the suite was not re-run at the head.code_024_1.cprobe.git diff a2dc5385..753fb5af -- nx2/build.py tests/test_mem_gate.pyis empty, so the 2,276 MB before estimate and the focused check are base-independent; the suite is the part that moved. The Measurements before column now says753fb5af, with that provenance.fitsitself admits a second 2,963 MB compile once 7,462 MiB is free.kind/performanceis stale for afix(build)with no perf claim; it should bekind/bug. I could not change it — this account has read access to the repo (the label DELETE returns 403) — so a maintainer needs to make the change.The 22:44 CI ask still names this head
487520d4.fix(build): the giant function's estimate covers its measured peakto WIP: fix(build): the giant function's estimate covers its measured peak487520d410e0e7315c53@HumanBean — fork CI for head
e0e7315c, please.What it is:
mem_need's giant-function estimate now covers its measured peak (2,276 MB estimated against 2,946 MB measured).Asked: approve this head's fork CI runs, and a review when you have the time.
Evidence: Measurements' verdict at this tree, and the suite recorded at
6350aa0bona2dc5385(911/23/18, all 23 the baseline names).Still WIP — suites land one at a time, so this is not a merge request.
WIP: fix(build): the giant function's estimate covers its measured peakto fix(build): the giant function's estimate covers its measured peakView command line instructions
Checkout
From your project repository, check out a new branch and test the changes.