refactor(dev)!: dev.py builds runtimes with the builder's dev runtime; smoke, disk and tools commands #2869
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!2869
Loading…
Reference in a new issue
No description provided.
Delete branch "HumanBean/Longshot:cleanup/area9-dev-tooling"
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
The development builds had two incremental build systems. The Rust builder is incremental by content: its object
store, the lifts by key, the game's Rust by key, and a shared shader cache. Over it,
scripts/devtools/packs.py(1,328 lines) and
build.pykept a second one: a base, packs made of the files that differ from it, and runtimesassembled from both. To do that, the Python guessed at the builder's insides:
kProgramCacheFormat, read with a regex;shadercache.pywas a second shared shader cache, with a key of its own. On mod-api nearly every change reaches thegame's Rust, so a pack was the whole module anyway.
This replaces both with one builder command and keeps only the policy in Python.
longshot-builder dev runtime <dir>(new,build-driver/src/dev_runtime.rs) has four modes:--game(a build): it isdev build. Every file whose bytes are the base's (--base) is a hard link ofthe base's file. The install still stages each file and renames it in, so nothing ever writes through a link.
--game(a copy): a copy of the base. The builder's files are linked, the rest cloned, and the playstate is left out. It is refreshed in place, and the runtime's settings and env file are kept.
--prepare-only: the shaders prepared, only when the caches it has are not known to be this translator's,program-cache format's and shader list's.
--give-back: what a run added to the runtime's caches goes into the base and the PC's shared cache.The caches:
(
<cache>/shaders/<translator>f<format>/<drivers>/).or play markers.
cache/longshot_runtime_caches.txt).The build writes
program_cache_format=intolongshot_version.txt.longshot-builder infolists a new capability,dev_runtime.dev.py:rt: this checkout over the nearest base, in its own warm work folder. Two queue jobs under the base's lock: thebuild (
buildmode), then--prepare-only(sharedmode, the GPU).packis gone, folded intort.rt --emptyis a copy of the base.abkeeps a runtime that is current.check's builds and its cache harvest use the same steps.dev.py packs base|pack|rt|warmkeep the Test Farm's command lines and files:base.json(commit,game_source,upscalers);pack.json(generated,deleted);dev_packs.busy, and the work folders'build_times.json.A pack is now a game folder of its own over the base.
packs basestill refuses a tree with uncommitted sources.dev.py builder -- ARGSreplacespacks run;mise run buildandbuild-devrun it.packs head, whichnothing ran, is gone.
New
dev.py smoke: one headless queue run of a runtime. It plays from a save, presents 900 frames, opens theInsert menu, takes a screenshot and checks the log, then says PASS or FAIL. Every agent here kept its own script for
this.
New
dev.py disk [--prune]: what the development data uses on the disk, and what is safe to remove: never astore, never a runtime a process uses. It replaces
dev.py bases --prune.New
dev.py tools, whichmise run toolsnow runs: tools.lock's build tools installed once in the PC's sharedtools-store, with the checkout's
tools/a link to them. Before, every checkout unpacked its own.Removed:
shadercache.pyand its test, and about 700 lines of packs.py. packs.py went from 1,328 lines to 629.Read first:
builder/crates/build-driver/src/dev_runtime.rs;folder::install'sbaseargument;scripts/devtools/packs.py;build.py'scmd_rt;Testing
Tested: Linux (CachyOS), RTX 3090.
One build job:
tests/run_all.py;dev.py pack --own-work+rt) against the new (dev.py rt): a first build, a small Cchange (
host/hos_main.c) and a small Rust change (game/crates/longshot-game/src/cheats.rs), over the sharedbase
462919343e, with the same builder program.In the new flow, 46 of the runtime's 54 files were hard links of the base's. A C change then put 2 files in and kept
52, and a Rust change put 1 file in.
Then one shared job:
dev runtime --prepare-onlyprepared the new runtime in 97 s and published 7 cache files into the shared cache;dev.py smokeon it: PASS. In play from kokiri-start, 900 frames, the Insert menu opened with its page, noFATAL line.
Checks:
cargo test -p build-driver -p longshot-builderpasses (queue);-D warningsis clean;cargo fmt -pis clean for both crates.tests/run_all.py:test_lifter.pyfails oncargo fmt --all --checkofgame/crates/api/src/services/mod.rsandgame/crates/game-core/src/nav.rs. Those are mod-api's own (#2745), not touched here, and they fail on mod-api too.test_dev_packs.pyfailed because the job'sLONGSHOT_BUILDleaked into one test. That is fixed here, and thetest passes with
LONGSHOT_BUILDset.The light checks: test_dev_packs, build, ab, check, disk, smoke, game_tests, update, migrate, mise_build,
job_queue, doc_commands and doc_anchors pass; pre-commit is clean on every changed file.
The review's fixes (2d99edab..2006d19c), one build job:
cargo fmt --checkand clippy-D warningsofbuild-core and build-driver clean;
cargo testofdev_runtime11 passed (new: a unit taken whole and never to shrinka cache, a give-back skipping a unit a running game holds); test_dev_smoke, test_dev_disk, test_dev_packs,
test_doc_anchors and test_doc_commands pass.
No host, renderer or other C/C++ file changed, so no llvm-mingw compile was needed.
Still to test:
packs.py): a run on this branch once it has a base. Expectingpacks base,pack prand
rtto work as before, withbase.jsonandpack.jsonread as before (@Beanstalkafter the Farm's changesin Risks).
dev.py rt,rt --empty): expecting the hard links, the CoW-or-copy clones anddev.py tools'junction to work (by hand).
dev.py disk): a real dry run over the development folder. Expecting a listing with sizes and nothingremoved (by hand).
dev.py packs warmanddev.py check): expecting--give-backto copy grown caches back (by hand).Measurements
Verdict: the tools' own cost per change went from minutes to seconds. A runtime takes no disk beyond its own
files, and the old flow's 1.5 GB per checkout is gone.
Setup:
LONGSHOT_NO_PREPARE=1;btrfs filesystem du).cb37f5ab(dev.py pack --own-work+rt)dbc97d8b(dev.py rt)Caveat: the new side ran second. It took the objects and the game's Rust for the very same edits from the shared
store, which the old side had just compiled; the old pack's compile was its "done in" (0 to 1 min). So the
like-for-like number is the tooling's cost outside the compile: old rt about 54 to 86 s plus pack overhead, against new
about 8 s in all. A second run with distinct edits per side was not made, to keep to one queue job.
Switches: no new switch.
LONGSHOT_JOBS(the builder's compilers at once) is not changed here and ships at itsdefault, unset: one compiler per CPU thread but one, so the PC stays usable while it builds (the launcher's Automatic
does the same).
LONGSHOT_BUILD(a ready-madelongshot-builderfor dev.py, already on mod-api) is a developmenttool's variable, unset by default: each step uses the tree's own builder. Neither is read by the renderer or the host,
so neither has a
gpu/vk/switches.defrow.The review's fixes (2d99edab..2006d19c) change no timing: give-back and publish choose and lock differently, smoke and disk
judge differently. Nothing there to measure.
Risks
<runtime>/longshotdirectly. On mod-api the game islongshot-game, and only the builder starts it.packs.pywill need each side's builder to havedev runtime. A PR builder from before it exits 2 with"older than this dev.py". Check for
dev_runtimeinlongshot-builder info'scapabilities.builder, and use anolder tree's
packs.pyfor such a builder.packs/<name>/game, whose unchanged files are hard links of the base's; thereare no loose files over the base any more.
pack.json'sgeneratedanddeletedare always empty.But they hold no
program_cache_format=line and no caches note, so:dev.py pack,packs run(nowdev.py builder),packs headandbases --prune(nowdev.py disk --prune). Scripts calling them get an argparse error.dev.py ab's "current" check does not notice a change totools.lockor the build tools alone.program_cache_format=line inlongshot_version.txt. A revert is enough.Checklist
Ready for review
mod-api; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named). Run astests/run_all.py; its onefailure,
test_lifter'scargo fmt --all --checkofgame/crates/api/src/services/mod.rsandgame/crates/game-core/src/nav.rs, is mod-api's own (#2745) and fails there too, as Testing says.main, or Measurements says why there is nothing to measure (againstmod-api, this PR'sbase).
third_party/untouched; nothing GPL-incompatible.When it applies
tests/that reads changed source is updated, not weakened.Assisted-by:/Co-Authored-By:trailers.🤖 Generated with Claude Code
https://claude.ai/code/session_016o1k1SQVyAWsujjFVd8Wuc
dev runtime, a developer's game folder that shares what it can with a base 9544a9762f@review
Recommendation: Request changes. Cache give-back can replace a more complete cache with a smaller one or copy a cache while the game is writing it. The new smoke command can also report PASS without completing its frame wait, and disk pruning can remove an older base still in use.
The change consolidates development runtime builds and shader-cache handling in the builder and adds smoke, disk and shared-tools commands. It reduces duplicated build policy, but introduces cache consistency and cleanup risks that need correction before merge.
Blocking (2): must change before merging.
scripts/devtools/disk.py:272: An older base is marked removable unconditionally, without checking its busy marker, age or runtime references. (more on the line) Do: Apply the same busy, usage and runtime-reference protections to older bases, and do not automatically remove a base still usable by an older checkout.builder/crates/build-driver/src/dev_runtime.rs:286: This adds unsafe system-call code outside the locations allowed by the repository's builder rules. (more on the line) Do: Move the system call behind a safe interface in an allowed build-core system module, or change the repository rule through the appropriate decision.Should fix (3): not blocking, but worth doing before merging.
builder/crates/build-driver/src/dev_runtime.rs:468: Give-back replaces a base cache whenever the sizes differ, including when the runtime's file is smaller and older. (more on the line) Do: Keep the base file when the candidate is smaller, and transfer related cache files consistently.builder/crates/build-driver/src/dev_runtime.rs:470: Give-back copies renderer caches without taking the renderer's locks; the builder's game-folder lock does not protect files held by a running game. (more on the line) Do: Take the renderer's program-cache lock for the data and index as a unit, and skip or retry while the game holds it. Apply the same paired locking to publication.scripts/devtools/smoke.py:98: The result of the requested frame wait is ignored, so a timeout does not fail the smoke run. (more on the line) Do: Record and require a successful frame-wait reply in the verdict; likewise fail when the requested screenshot cannot be taken.Testing before merging (3) (runs on the systems it can change; it doesn't hold the recommendation)
@fixcan do L1, L2, L3, L4 and L5.Questions (1) (not confirmed from the code; they don't hold the recommendation)
Checks: Failing on this head, which is behind its base, where it passes:
PR description / Title and description (pull_request_target).@rebase(or@fix) brings it up to date and runs it again; not held against it.More: does it help, other systems, switches, what was read
Does it help: Unproven. The reported single-run comparison shows 118 s versus 8 s for a C edit and 94 s versus 9 s for a Rust edit, but the new side ran second and reused objects compiled by the old side. Repeated, interleaved runs with distinct equivalent edits are needed to establish the gain.
Other systems: The Linux RTX 3090 build and smoke run provide evidence for one runtime path. Windows runtime copying and tools junctions, Test Farm compatibility, and cache give-back after gameplay remain untested. The cache code also runs during parallel check launches and must coordinate with a running renderer.
Switches: No game switch added, changed or removed. The new command options control development tooling.
Reviewed:
dbc97d8b20againstcb37f5ab8a: Read the repository instructions, contribution rules, standards and PR template; reviewed the commit log, runtime and folder changes, and relevant build, packs, disk, smoke, check and bridge paths. Skimmed the remaining diffs and tests; did not read every changed code file in full or every documentation and test file.; nothing run (a code review).Checked and fine:
Testing: No commands from the pull request were run, as requested. The review uses the author's reported checks and Linux run as evidence.
Overlaps and merge order: The description identifies required Test Farm companion changes; their pull request and merge order were not available in the supplied context.
Automated code review by BeanBot (gpt-6.1-terra), asked for by HumanBean. Nothing was run; a maintainer decides.
@ -0,0 +283,4 @@fn reflink(from: &File, to: &File) -> bool {use std::os::fd::AsRawFd;// SAFETY: both are open files of this process; FICLONE reads the source's descriptor and nothing else.unsafe { libc::ioctl(to.as_raw_fd(), libc::FICLONE, from.as_raw_fd()) == 0 }L5 (blocking): This adds unsafe system-call code outside the locations allowed by the repository's builder rules.
When: The Linux reflink path permits unsafe code in build-driver, although the standards restrict such code to the named system-call modules.
Do: Move the system call behind a safe interface in an allowed build-core system module, or change the repository rule through the appropriate decision.
@ -0,0 +465,4 @@let theirs = cache_files(&to);let mut given = Vec::new();for (name, (size, time)) in cache_files(&from) {let newer = theirs.get(&name).is_none_or(|&(s, t)| s != size || time > t);L1 (should fix): Give-back replaces a base cache whenever the sizes differ, including when the runtime's file is smaller and older.
When: Two check launches start from the same cache. After the first gives back a larger cache, the second gives back its smaller cache: the size inequality replaces the larger file and loses the first launch's cached work.
Do: Keep the base file when the candidate is smaller, and transfer related cache files consistently.
@ -0,0 +467,4 @@for (name, (size, time)) in cache_files(&from) {let newer = theirs.get(&name).is_none_or(|&(s, t)| s != size || time > t);if newer {clone_file(&from.join(&name), &to.join(&name)).at(to.join(&name))?;L2 (should fix): Give-back copies renderer caches without taking the renderer's locks; the builder's game-folder lock does not protect files held by a running game.
When: The check warm-up calls harvest while its first game is still running. Give-back can clone its program data or index while the renderer appends to them, leaving the build with an inconsistent cache for later launches.
Do: Take the renderer's program-cache lock for the data and index as a unit, and skip or retry while the game holds it. Apply the same paired locking to publication.
@ -0,0 +269,4 @@out.append((e, "nothing this dev.py reads, and unused for %s: %s" % (ago, e["what"])))elif e["kind"] == "base":b = e["base"]if "game_source" not in b:L3 (blocking): An older base is marked removable unconditionally, without checking its busy marker, age or runtime references.
When: An older checkout is building or using a base whose base.json lacks game_source. A disk prune from this checkout selects that base and can delete it despite the older tools still using it.
Do: Apply the same busy, usage and runtime-reference protections to older bases, and do not automatically remove a base still usable by an older checkout.
@ -0,0 +95,4 @@return Nonein_play = ask("wait", timeout=plan["timeout"], event="in_play") is not Noneif in_play:ask("wait", timeout=plan["frames"] / 10, event="present", frames=plan["frames"])L4 (should fix): The result of the requested frame wait is ignored, so a timeout does not fail the smoke run.
When: The game reaches play but does not present the requested 900 frames within the wait. If its subsequent status still says play and the menu opens, the command reports PASS despite not completing the advertised check.
Do: Record and require a successful frame-wait reply in the verdict; likewise fail when the requested screenshot cannot be taken.
Thanks. Fixed in 2d99edab..2006d19c: give-back and publish now take a cache unit (an index with its data) whole, never to shrink a file, under the renderer's
<data>.lockon both sides, skipping what a running game holds (L1, L2); the FICLONE call moved into build-core'ssys.rs, reached throughfsx::reflink(L5);dev.py smokefails when the frame wait or the screenshot does not answer (L4);dev.py diskremoves an older dev.py's base only by a base's rules and when no process has it open (L3).L6 (an interleaved re-measure) and L7 (Windows) stay in Still to test: the Measurements caveat says why the gain is read as the tooling's cost outside the compile.