Repository navigation
Conversation
tools/startup/run_preset.py takes three choices (--console x|s, --gpu nvidia|amd, --os win11|win10|linux, default this host) and reads every other setting from tools/startup/run_presets.json: a base layer, then one layer per choice, each entry with the reason it is there. The launcher stages the executable's PE files (hard links, else copies) so the package is never written, gives every run an empty storage folder, maps the package on its drive letter with subst for the run, starts run.ps1 or run.sh, and runs triage_run.py. The base layer turns off R0Y00#1408's thread holding (run.ps1 -SuspendOthers 0, R0Y00#3332) and uses subst rather than run.ps1 -MapDrive; the measurements behind both, and behind the D3D12 switches it sets, are in the preset's "why" text and docs/startup-runtime.md. tests/startup_run_preset_check.py checks all 12 choices against the switches run.ps1 and run.sh define, the layer rules, drive mapping through a fake subst, and staging on a synthetic package, with refusal controls. Registered in CTest and the python-linux check list.
X2W_PROBE_PRECHECK=0 (R0Y00#3313) skips the VirtualQuery the stand-ins run before each probe and copy while a debugger is attached; title runs always start under debug_launch.py. Same package, input and 420 s, NVIDIA, Windows 11, ec71c29: 1,142,089 vs 162,303 translated draws, 80,175 vs 15,001 executes, 5,372 vs 2,134 textures uploaded. The reason is recorded in run_presets.json and docs/startup-runtime.md.
The base layer now sets X2W_HIDE_TITLE_WINDOW=1 on every host, so once presents reach the output window the title's own window, which nothing presents to, is hidden. Dialogs stay visible and the window comes back when a present misses the output window. The Linux layer's hide_title_window switch is dropped: run.sh's flag only exports the same variable. The preset check asserts the variable for all 12 choices; removing it from base fails all 12. Real run (420 s, Series X / NVIDIA preset, Windows 11, ec71c29): the stand-in logged that it hid one title window and never showed it again, the run was alive at the timeout, and the title read input from 58 s. Translated draws were 975,488 (1,142,089 in the run before this change).
…m current AGENTS.md now says to start package runs with tools/startup/run_preset.py, and to keep tools/startup/run_presets.json current: add a helpful opt-in switch to its layer, change a setting when a measured run shows it, put the evidence in the layer's why, and leave out switches that main does not read yet.
Leyukaka
left a comment
There was a problem hiding this comment.
Reviewed 4d1b42bd by its diff.
The package folder can be written. stage() in tools/startup/run_preset.py hard-links every .exe/.dll of the executable's folder into the stage (os.link(f, target), copy only on OSError), and the command runs the staged executable. run.ps1 then copies the 8 stand-ins into that folder ($runDir = Split-Path -Parent $Exe, Copy-Item ... -Force, tools/startup/run.ps1:43-47), and run.sh does the same with cp -f (run.sh:99-102). If the executable's folder holds a file with a stand-in's name and the stage is on the same volume, the staged entry is a hard link to the package's file. cp -f truncates and rewrites an existing destination in place, so on Linux the copy writes into the package's file when it is writable; Copy-Item -Force likely does the same on Windows (not measured). The docs say "the package folder itself is never written", and the stage() docstring "Nothing under the package is written". Fix: do not link a file whose name is one of the stand-ins (copy or skip it), or copy instead of linking, and add a test with such a file that checks the package copy is unchanged.
Caller environment is not recorded. The child starts from dict(os.environ) and the layers are applied on top (env = dict(os.environ); env.update(settings["env"])). An X2W_* already set in the caller's shell reaches the run, settings.json (choice, run, env, layers, command) does not record it, and an env: null in a layer cannot remove it, because null only drops values from earlier layers. Fix: record the inherited X2W_* values in settings.json and make null remove the variable from the child's environment. If inherited values are dropped instead, keep the ones run.sh reads from the caller (X2W_WIN_PYTHON, X2W_FXC, X2W_HOST_PYTHON).
|
Thanks for this. Checked at 4d1b42b: the trial merge onto main aec2e08 is clean ( MUST: run.sh writes into the package through the hard link. This prints SHOULD: the check Minor: Linux This comment was AI-assisted. |
run.ps1 (Copy-Item -Force) and run.sh (cp -f) copy the 8 stand-ins next to the staged executable and rewrite an existing file in place. A package file with a stand-in's name was hard-linked into the stage, so that copy wrote into the package. Measured on NTFS with a synthetic package: after Copy-Item -Force under pwsh 7.7 and Windows PowerShell 5.1, the package's linked xg_xs.dll held the stand-in's bytes. stage() now always copies a file whose name (any case) is one of STAND_INS. The check stages a package with GameInput.dll and XMEM.dll, rewrites the stand-ins over the stage the way the scripts do, and compares the package; a control with the names linked must change it. STAND_INS is checked against the lists in run.ps1 and run.sh.
The run's environment starts from the caller's shell. An X2W_* value set there reached the run without appearing in settings.json, and a layer's null only dropped an earlier layer's value, not the caller's. merge() now also returns `unset`, the keys whose last value is null, and child_env() removes them from the child's environment before the layers apply. The X2W_* and WINE* values that reach the run unchanged are recorded in settings.json as `inherited_env` and listed by --print, so the variables run.sh reads from the caller (X2W_WIN_PYTHON, X2W_FXC, X2W_HOST_PYTHON) are kept and shown. The check covers child_env() and a run with the child start replaced: the environment it is given and what settings.json records.
The check refused any difference between the AMD and NVIDIA merges, so the edit the docs ask for (a measured switch in that host's layer, with its reason) failed it: adding X2W_SPLIT_INDIRECT_DISPATCH to gpu.amd printed "AMD and NVIDIA differ without a recorded reason". A difference in env or run between GPU choices is now accepted when each GPU layer that sets the key names it in its `why`, for every OS and console. Controls: that same edit passes, and an unnamed env value plus an unnamed run option fail on every OS and console. AGENTS.md and docs/startup-runtime.md say to name the switch in the layer's why.
…he preset check The Linux commands were never checked for --suspend-others 0, only the Windows -SuspendOthers. A command without -StoragePath, --storage, -SuspendOthers or -Seconds raised ValueError in cmd.index instead of a named FAIL. arg_after() returns None for a missing flag. Mutations: dropping -StoragePath gives 8 named FAILs (per-run storage), and leaving --suspend-others out of run.sh commands gives 4.
|
Thanks @Leyukaka and @JohnConnorNPC. Pushed four commits on top of Package written through the hard link (both of you). Confirmed on Windows too: on NTFS, with a synthetic Caller environment (Leyukaka). GPU check vs. the documented edit (John, SHOULD). Minor (John). After each commit: This reply was AI-assisted. |
Change
Adds
tools/startup/run_preset.py, a launcher for runs of a local package. It has three choices: console (xors), GPU (nvidiaoramd) and OS (win11,win10orlinux; the host by default). Every other setting comes fromtools/startup/run_presets.json, which is applied in layers: base, then OS, console, GPU. Each layer says why its settings are there and gives the measured run behind them.The launcher also:
G:withsubstfor the run and removes the mapping afterwards. It refuses a letter that is taken, unlesssubstalready maps it onto this package;settings.json, startsrun.ps1(orrun.shon Linux) and printstriage_run.pyfor the logs.--printshows the merged settings and the exact command without starting anything.The base layer sets:
-SuspendOthers 0(startup: let run.ps1 and run.sh turn off the hook thread holding #3332);X2W_PROBE_PRECHECK=0(startup: let X2W_PROBE_PRECHECK=0 turn the probe pre-check off under a debugger #3313);X2W_D3D12_RING_RELEASE_AT_SUBMIT(startup: opt-in release of upload ring chunks at a fenced submit #2949),X2W_D3D12_ROOT_SRV_AT_DRAW(startup: opt-in skip of the graphics root SRV copy that no draw reads #3028) andX2W_D3D12_TABLE_ALIAS(startup: opt-in alias binding for table buffer views over aliased placed buffers #2977);X2W_HIDE_TITLE_WINDOW=1, so only the output window stays on screen;AGENTS.mdgets a short section that points to the launcher and asks contributors to keep the presets current, with evidence for each change.Why
substand notrun.ps1 -MapDrive:-MapDriverewrites only opens that pass through the debugger's file hooks. With it, a real-package run stayed on its first screens, with 11 pipelines translated in 420 s. The same settings on asubstdrive kept loading and reached 76.Refs #870, #3331
Verification
Build:
4d1b42bd(this branch onaec2e084), release, Windows 11 Pro 26200, NVIDIA.python -B tests/startup_run_preset_check.py:OK: 12 preset choices, staging and controls. The check covers:run.ps1/run.shswitch names;substhandling with a fakesubst.Negative controls, each of which must be refused or caught:
subst;Executable.Taking
X2W_HIDE_TITLE_WINDOWout of base fails all 12 choices.python -B tests/startup_run_ps1_check.py: exit 0.python -B tests/docs_links_check.py:Checked 156 Markdown files and 681 links.tests/startup_run_sh_check.pyskips on Windows (POSIX launcher), so it was not run.Real-package runs (local data, not reproducible from this repository), Series X / NVIDIA preset, 420 s, same input script and seed storage on every run:
ec71c290+ #3332ec71c290+ #3332-MapDriveec71c290+ #3332subst, beforePROBE_PRECHECK=0ec71c290+ #3332X2W_PROBE_PRECHECK=0ec71c290+ #3332X2W_HIDE_TITLE_WINDOW=14d1b42bd(this branch)The Series S preset (
--console s) onec71c290+ #3332 was also alive at 420 s, with 1,008,389 draws and 75 pipelines.With one run per configuration, the draw counts vary a lot from run to run: the two Series X runs with the same settings drew 975k and 1.14M. The table supports "runs to the timeout with these settings", not a ranking of small differences.
Evidence and follow-up
Not measured: AMD, Linux (Wine/Proton) and Windows 10. The AMD and NVIDIA layers are deliberately identical. They exist so that a measured difference has somewhere to go. The Linux layer copies
run.sh's defaults and the lazy-commit pair from the one reported Linux run (#1198, #2911).Left out on purpose:
X2W_D3D12_VIEW_TOKEN_GUARDED(startup: opt-in guarded write of the view token in note_view #3097), because main does not read it yet;Whether keyboard input reaches the title after its window is hidden is still unmeasured. The output window belongs to the same process, so the input stand-in's focus check still sees the process in front. The runs above used the input script.
Checklist
This pull request was AI-assisted.