[pr-performance] The prelude worker follows the helpers' priority, like the other threads the submitting thread waits for #322
Loading…
Reference in a new issue
No description provided.
Delete branch "iridiumlotus/Darner:prelude-raised"
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?
What it changes
DARNER_TIMELINE, diagnostics build of mainf3840d7plus #216) on an 8-core CPU, standing still in the open world: the submitting thread waits 7.7 ms a frame fordarner-preludein ten waits (WaitOnAddress at host::Host::submit < host::Host::send_late, ended bydarner-prelude), while that thread runs only 4.4 ms a frame. On the chain each frame's present came out of,darner-preludestands "woken, not running yet" for about 3.9 ms a frame (15.6 ms in the four frames sampled), more than half of the chain's 6.8 ms a frame of "woken, not running yet".DARNER_ASYNC_PRELUDES(on by default) records a submission's preludes on a worker thread, and the submitting thread joins it before it sends. The submitting thread runs above normal priority (or asDARNER_SUBMIT_PRIORITYsays, or highest on a core of its own), and the other threads it waits for are raised as well by the helpers' priority policy (DARNER_HELPERS_RAISED, on by default: above normal, or the number inDARNER_HELPER_PRIORITY;darner-wide, thelandpools,darner-heap-sync,darner-aside, ...). The prelude worker was started at normal priority, so on a CPU where the title's threads and the list translators keep every core busy it waits for a processor while the submitting thread waits for it. That is the caseDARNER_HELPERS_RAISEDwas made for (its comment incores.rsdescribes it on a 6-core CPU); this thread was not on its list.This gives the prelude worker a
cores::Priority, kept before each batch of preludes like the other helpers, so it follows the same policy they do: withDARNER_HELPERS_RAISEDon (the default) above normal, or the number inDARNER_HELPER_PRIORITYif one is given; with it off, normal. The submitting thread's own priority (DARNER_SUBMIT_PRIORITY, highest on a dedicated core) is not copied. Five lines inhost.rsplus the comment there; thehelpers_raisedcomment lists the thread and the measurement.Not in this PR: keeping the worker on the fast cores of a hybrid CPU (
keep_on_fast_cores), which the other helpers also ask for. I have no hybrid CPU to measure it on.How it was tested
Tested revision:
d0bd297(this branch, on mainf3840d7) for the clippy gates and the policy check; the tests ran on its parent6ffc294(the head only rewords a code comment, after the review comment below). In the game: a release build of270e8bf, the same code (the later commits differ only in comments and in the commit message), withscripts\play-nvidia.ps1 -NoMenu -Dlss ultraperformance: loaded the save and stood in the world for the 2 minutes of the run, 0 errors; read from outside the process 150 s after the start,darner-preludeis at thread priority 1, asdarner-submit,darner-aside,darner-wide-0,darner-late-wait,darner-relayanddarner-list-0are.Commands and results: the A/B below; gates further down.
Changes a default: yes, for everyone with
DARNER_ASYNC_PRELUDESandDARNER_HELPERS_RAISEDat their defaults (both on). It changes one thread's priority. Expected to matter where the CPU is fully busy (8 cores or fewer) and to do nothing where a core is free for the worker anyway.A/B result: in-run A/B with
DARNER_AB(same run, same scene, the switch flipped every 7 or 10 seconds).DARNER_ABcan only flipDARNER_HELPERS_RAISEDfor all helpers at once, so these numbers are from an experiment build: mainf3840d7plus #216 plus this change behind a temporary switch of its own (not in this PR), built with--release --features ab. In it the worker's priority read from outside flips between 0 and 1 with the phases while the other threads stay at 1. Ryzen 7 5800X3D (8 cores, 16 threads), RTX 5080, 32 GB, Windows 11;scripts\play-nvidia.ps1 -NoMenu -Dlss ultraperformance(Series X profile, 2560x1440 output, scene 853x480, no ray tracing, no frame generation; the launcher setsDARNER_HELPER_PRIORITY=1, and the submitting thread is at 1 as well: no dedicated core, noDARNER_SUBMIT_PRIORITY), standing still in the open world on a daytime save, copied fresh from a backup for each run; 13.4 of the 16 logical processors busy. The scene's draw count moves between 6,700 and 14,600 a frame in a 60-second cycle, so each phase's mean frame time is fitted asa + b * draws + effect(A = the fit's value with the worker at normal priority; B - A = the effect):DARNER_ASYNC_PRELUDESas the second switch, 29 phasesRun 1 is the one to go by: it has every other thread as the launcher sets it. In runs 2 to 5 the experiment build also held
darner-late-waitanddarner-relayat priority 0 (the launcher'sDARNER_HELPER_PRIORITY=1has them at 1; a sixth run that flipped those two showed nothing: +0.8 ms +-0.8 and -0.5 ms +-0.8). With 10 s phases the A/B cycle is in step with the scene's 60-second cycle, so the busy stretch fell on the same side every time and the fit over draws has to carry that; runs 1 and 2 have 7 s phases for that reason. In run 5,DARNER_ASYNC_PRELUDES=0is -0.5 ms +-0.7 against the worker at normal priority.Also tried and left out because it adds nothing on top of the raise: the submitting thread recording the preludes itself when the worker has not begun them (-1.5 ms +-0.5 alone).
Gates run (the three in AGENTS.md; there is no CI):
cargo clippy --workspace --all-targets --locked -- -D warningspassed; the same with--all-featurespassed;cargo xtask policypassed (555 files ok); those three ond0bd297.cargo test --workspace --locked --no-fail-faston6ffc294did not pass as a whole on this PC: every package passes except three tests outside this change (it toucheshost.rsand a comment incores.rs, both in darner-gpu):watch::tests::ask_once_by_res_splits_reservations_without_refusals. It orwatch::watch_pipe_epoch_tests::ask_once_delta_reask_direct_carves_refreshes_and_updates_page_epochsfails in most full runs of the package here, on mainf3840d7without this change as well (3 full runs of 3 on main; 3 of 4 on this branch, the fourth all passed), and the first passes when run alone (3 of 3).emit::waterfall_tests::sampled_marks_restore_early_depth_only_when_safe_in_pixel_shaders(the fixture #227 fixes; it fails on main here too, see #216).oracle64::legacy_mul_forms_are_exactdid not finish: it goes through every float in a debug build; I stopped it after 25 minutes and ran the rest of the package without it.Gameplay, when relevant: RTX 5080, Series X profile, 2560x1440, DLSS ultra performance, no frame generation, no ray tracing.
Shader wave sizes tested, when relevant: not relevant.
Hardware dependence: may depend on the CPU. Measured on 8 cores / 16 threads. Untested on CPUs with more cores, on hybrid CPUs, and with the submitting thread on a dedicated core (dual-CCD V-Cache CPUs), where it runs at highest priority and the worker stays at the helpers' priority.
Coverage gaps: one scene (standing still, daytime), one PC. Not measured while driving or in cutscenes. Not measured with
DARNER_SUBMIT_PRIORITYorDARNER_HELPER_PRIORITYset to anything but the launcher's values. The frame times are from the experiment build described above, not from this exact commit; this commit's exe is not comparable run against run yet (it is a new build here, and its first runs still made pipelines).Checklist
main.docs/asset-policy.md.Checked for overlap
prelude,ASYNC_PRELUDES,HELPERS_RAISEDor thread priority (open and closed, 2026-12-04). #274 also changeshost.rs, in another place (the retirement queues).The implementation makes
darner-preludefollow the existing helper priority policy. The submitting thread still readsDARNER_SUBMIT_PRIORITYand can use highest priority when it has a dedicated core. Could the title and the worker comment say that the prelude now follows the other helpers? That would describe the behavior under those overrides as well as the default used for the A/B.WIP: [pr-performance] The prelude worker runs at the submitting thread's priority, like the other threads it waits forto [pr-performance] The prelude worker follows the helpers' priority, like the other threads the submitting thread waits forThanks, you are right. The worker follows the helpers' priority policy (
cores::Priority:DARNER_HELPERS_RAISED, and the number inDARNER_HELPER_PRIORITYif one is given); the submitting thread's own priority (DARNER_SUBMIT_PRIORITY, highest on a dedicated core) is not copied.Changed: the worker's comment in
host.rssays so now (d0bd297, comment only), and so do the title and the description. The A/B ran on the launcher's defaults, where the submitting thread and the helpers are both at 1; the description's coverage gaps now say that those overrides and a dedicated submit core were not measured.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.