WIP: perf(host): raise Windows process priority, lock-free multiwait check, 2-way sync cache, and cloth skin AVX2 #2886
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
4 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2886
Loading…
Reference in a new issue
No description provided.
Delete branch "siantm/Longshot:perf/pc-sync-readback-workers-skin"
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?
Type: perf · Risk: medium · Tested on: Windows 11, RTX 4060 (621.40) · Needs: Linux build/test
Why
Three distinct CPU frame-time and tail-latency bottlenecks limit PC frame pacing (1% and 0.1% lows):
NORMAL_PRIORITY_CLASS, causing 60–124 ms frame-time spikes (11.6–15.1 FPS0.1% lows).host/nn_os_sync.c,poke_multiwait()ranInterlockedCompareExchange(&mw_waiting, 0, 0)(dirtying the shared cache line on every signal/send/release) and tookAcquireSRWLockExclusive(&mw_lock)to scanmw_watched[]whenevermw_waiting > 0, even when the signaled object is unwatched. Meanwhileobj_nockpt()'s 1-way direct-mapped thread-local cache thrashed on hash-colliding actor mutex addresses.f_81cdff40, called from 60 sites incode_hot_4.c/code_024*.c) still ran scalar lifted AArch64 loops instead of AVX2/FMA.This branch stacks on PR #2876 (
6b6f82273).What changed
Raises the Windows process priority class at boot, adds a lock-free unwatched fast path to
poke_multiwait()and 2-way associativity toobj_nockpt(), and vectorizes Havok cloth skinning (f_81cdff40) with AVX2/FMA.host/hos_thread.c):hos_boot_main_thread()setsABOVE_NORMAL_PRIORITY_CLASSat startup unlessHOS_NO_PRIORITIESorHOS_PROCESS_PRIORITY=0is set.poke_multiwait()& 2-wayobj_nockpt()cache (host/nn_os_sync.c): maintains a key-indexed 1024-bucket atomic counter array (mw_watch_buckets[1024]) undermw_lockinmw_watch_add_locked()/mw_watch_remove_locked()(preserving tombstone/spare/pre-init safety), replacesInterlockedCompareExchange(&mw_waiting, 0, 0)with__atomic_load_n(&mw_waiting, __ATOMIC_SEQ_CST), returns locklessly when unwatched, and upgradesobj_nockpt()'s 16 KB per-thread cache to 512 x 2-way set-associative with MRU promotion (gated byHOS_SYNC_FAST=0).host/oot_cloth.c,nx2/oot_patches.py,tests/test_oot_cloth.py): addshos_oot_cloth_skin(Ctx *c)computingdst[i] = B * M[indices[i]] * S[i]using dual-column YMM AVX2/FMA withhos_guest_rangevalidation, overlap guards, andHOS_WRITTEN(dst, count * 64), hooked idempotently inwork/sa/gen/code_hot_4.cunderHOS_OOT_CLOTH_AVX2and unit-tested across GCC & Clang.Measurements
Verdict: In
KokiriForest_Child(1280x720, 4 interleaved 35 s runs viaRX_VK_FRAME_TRACE=1), enabling the three changes boosts Avg FPS from59.43to62.40(+5.0%), 1% Low FPS from23.14to41.87(+80.9%, non-overlapping39.08–44.66vs20.66–25.62), and 0.1% Low FPS from13.36to31.51(+135.9%,p99_ms31.84 -> 21.09 ms,p999_ms53.91 -> 29.75 ms,max_ms93.14–123.86 -> 27.56–45.23 ms) with0warnings,0escapes, and0left-out CPU violations. Standalone C/Rust/ASM microbenchmarks show9.24x–11.50xfaster unwatchedpoke_multiwait,1.36x–1.49xfaster collidingobj_nockpt, and5.67x–6.13xfaster cloth skinning.Hardware: Windows 11, Intel(R) Core(TM) i7-9700 CPU @ 3.00GHz (8 cores / 8 logical), 32586 MB RAM, NVIDIA GeForce RTX 4060 (driver 621.40)
Scene:
KokiriForest_Child(kokiri-start),1280x720(resolution=0,quality_preset=6),vsync=0,frame_generation=0,threaded_rendering=0,HOS_FPS_MAX=1000,HOS_AUDIO=0Baseline:
PR #2876 @ 6b6f82273(Before, toggles off: this PR @ fec6ffd88withHOS_PROCESS_PRIORITY=0 HOS_SYNC_FAST=0 HOS_OOT_CLOTH_AVX2=0); PR #2876 is the immediate parent commit of this stacked branch soBeforevsAfterisolates commitfec6ffd88cleanly on identical code and runtime hardware state.Method: 4 warm interleaved runs (
BASE_1,NEW_1,NEW_2,BASE_2), 8 s settle + 35 s measure (2,110–2,327frames/run), per-frame timings read fromRX_VK_FRAME_TRACE=1(frames.csvfiltered to[start_frame, end_frame]):avg_fps = 1000 / mean(ms),1% low = 1000 / mean(slowest ceil(1%)),0.1% low = 1000 / mean(slowest ceil(0.1%)). Standalone microbenchmarks:sync_fastpath_bench(20M ops) andcloth_skin_bench(10k calls).How to reproduce:
python -I scripts/longshot_ctl.py launch work\sa\build --exe work\sa\build\longshot.exe --image work\sa\image\image.bin --romfs <romfs> --repo-save kokiri-start --profile test --ready present --headless --env HOS_FPS_MAX=1000 --env HOS_AUDIO=0 --env RX_VK_FRAME_TRACE=1comparingHOS_PROCESS_PRIORITY=0 HOS_SYNC_FAST=0 HOS_OOT_CLOTH_AVX2=0vs1 / 1 / 1.fec6ffd88fec6ffd8858.72,60.14)62.80,62.00)20.66,25.62)44.66,39.08)11.63,15.09)38.41,24.61)36.81,26.87)20.76,21.42)59.63,48.19)24.50,34.99)poke_multiwaitunwatched (ns/op)obj_nockptcolliding (ns/op)cloth_skin_bench256p (ns/call)Flags and settings
Adds
HOS_PROCESS_PRIORITY,HOS_NO_PRIORITIES, andHOS_SYNC_FAST(default enabled) alongsideHOS_OOT_CLOTH_AVX2(from PR #2876).HOS_PROCESS_PRIORITYABOVE_NORMAL_PRIORITY_CLASSat bootNORMAL_PRIORITY_CLASS1by default (0disables)23.14 -> 41.87,13.36 -> 31.51)1)HOS_NO_PRIORITIESHOS_PROCESS_PRIORITYNORMAL_PRIORITY_CLASSwhen10)HOS_SYNC_FASTpoke_multiwaitbucket check + 2-wayobj_nockptcachedirect[1024]+SRWLockscan1by default (0falls back)SRWLock& cacheline dirtying on unwatched signals and halves hash collisions1)HOS_OOT_CLOTH_AVX2f_81cdff40skinning (1by default)code_hot_4.c/code_024*.c1)Testing
Tested:
tests/run_all.pysuite (Windows 11, llvm-mingw):14 passed, 0 failed, 0 skippedin 8 s (test_oot_cloth,test_patch_hooks_defined,test_multiwait_wake,test_cv_signal_early,test_cv_signal_race,test_vcore_escape,test_vcore_fs_open,test_vcore_video_acquire,test_spin_by_role,test_thread_arg_self,test_thread_wake_cleanup,test_pool_flags,test_collect_avx2,test_doc_anchors).nx2/build.py --standalone --jobs 8: compiled in 74 s,0failed, linkedlongshot.exeandlongshot_vk.dll.RX_VK_FRAME_TRACE=1(frames.csv) benchmark (KokiriForest_Child,1280x720, 4 × 35 s runs):0warnings,0escapes,0write-back left-out CPU violations.sync_fastpath_bench(100% parity across colliding keys, tombstones,memsetre-init, unlinks) andcloth_skin_bench(max_diff <= 2.86e-06).Not tested:
hos_boot_main_threadWindows#if defined(_WIN32)branch compiles out on Linux, andnn_os_sync.c/oot_cloth.cneed Linux Clang/GCC CI verification).hos_oot_cloth_skinmath verified by unit tests &cloth_skin_bench).Must be tested:
python -I -B tests/run_all.pyon Linux, expectingtest_oot_cloth,test_multiwait_wake,test_cv_signal_early, andtest_cv_signal_raceto pass (@Beanstalk linux).python -I -B tests/run_all.pyin CI, expecting zero new failures (@Beanstalk windows).Risks
What could break: Running at
ABOVE_NORMAL_PRIORITY_CLASSgives game threads scheduling preference over normal desktop background apps;mw_watch_buckets[1024]relies onmw_watch_add_locked/mw_watch_remove_lockedstaying the sole mutators ofmw_watched[];hos_oot_cloth_skinassumesf_81cdff40's 3x4 affine struct layout.Turning it off: Runtime toggles revert every feature without rebuilding:
HOS_PROCESS_PRIORITY=0 HOS_SYNC_FAST=0 HOS_OOT_CLOTH_AVX2=0. Reverting commitfec6ffd88restores PR #2876 cleanly.Compatibility: Nothing changes for saves,
longshot_options.ini, Vulkan shader/pipeline caches, orMKWVK_API_VERSION. Existingwork/sa/gen/code_hot_4.cmust havenx2/oot_patches.pyapplied during build.Checklist
Everyone
type(scope): description) of the status line's type.main.python -I -B tests/run_all.pypasses (any failure that also fails onmainis named).third_party/untouched (a new folder with aPROVENANCE.mdinstead).When it applies
Assisted-by:/Co-Authored-By:trailers.tests/that reads changed source updated in this PR, not weakened.Tested in game: Windows 11, Intel i7-9700, RTX 4060 (driver 621.40), KokiriForest_Child (kokiri-start, 1280x720, HOS_FPS_MAX=1000, HOS_AUDIO=0, RX_VK_FRAME_TRACE=1): 4 interleaved 35 s runs (BASE_1, NEW_1, NEW_2, BASE_2); NEW vs BASE improves Avg FPS 59.43 -> 62.40 (+5.0%), 1% Low FPS 23.14 -> 41.87 (+80.9%), and 0.1% Low FPS 13.36 -> 31.51 (+135.9%) with 0 warnings, 0 escapes, 0 left-out CPU violations.
@review
Could you split these up? These are great improvements, and we need to test each individually :)
Recommendation: Request changes. The stacked diff can omit CPU-visible GPU memory updates and introduces unsynchronized accesses on rendering and host-write paths. Its measurements cover only the last commit against its parent, so they do not establish the effect of the full diff against the stated base.
The branch changes renderer memory tracking and eviction, host scheduling and decompression, synchronization, and cloth computation. The reported Windows run shows better frame pacing for the final commit on one PC, but the broader stack has correctness and portability risks and is not represented by that comparison.
Blocking (6): must change before merging.
gpu/vk/pool_flags_policy.h:21: PHYSICAL alone is treated as proof that a pool cannot be accessed by the CPU, even when its flags explicitly include CPU_CACHED. (more on the line) Do: Only exclude ranges whose flags and actual mappings establish that CPU access is impossible; preserve tracking and writeback for CPU-accessible physical pools.gpu/vk/pool_flags_policy.h:31: The backward scan can stop before an earlier overlapping CPU-accessible pool. (more on the line) Do: Account for every overlapping interval, including earlier intervals that extend past shorter intervening ones, and add this nested-overlap case to the policy test.host/nvdrv.c:217: The host-write queue length is read outside the lock while producers change it under the lock. (more on the line) Do: Take the lock before inspecting the queue length, or use a correctly synchronized publication protocol for both the length and queued ranges.gpu/vk/vk_memory.cpp:4755: The lock-free binding path accesses sieve_visited atomically, but the eviction and other binding paths access the same field as a plain bool. (more on the line) Do: Use atomic access consistently for every concurrent access to the field, or protect all accesses with the same lock.host/rx_backend.c:117: The AVX2 scan reads write marks non-atomically while game threads publish those marks with atomic stores. (more on the line) Do: Use a representation and scan protocol whose concurrent reads and writes are atomic, and exercise concurrent publication while collecting.@fixor@rebasetry first). (for the author)Should fix (5): not blocking, but worth doing before merging.
tests/test_collect_avx2.py:126: The test always compiles and executes an AVX2 binary without checking whether the running CPU supports AVX2, and it ignores the suite's selected C compiler. (more on the line) Do: Pass the suite's compiler through RUN_ALL_ARGS and gate execution of the AVX2 fixture on runtime CPU support, while retaining a baseline test.tests/test_oot_cloth.py:630: The cloth test also unconditionally executes a binary compiled for AVX2 and FMA and does not use the compiler selected by the test suite. (more on the line) Do: Use the suite's compiler argument and only execute the globally AVX2/FMA-compiled variant when the CPU supports both features.docs/development.md:741: The switch documentation still says both native zstd paths default off, and it omits the newly added host switches and other changed defaults. When: A developer following the table expects lifted decompression by default, but both native paths now run by default; the table also gives the old six-core default on machines where the code selects eight. Do: Update the switch table for every added or changed host switch, its shipped default, and its effect.gpu/vk/switches.def:387: The new RX_VK_MIRROR_SYNC_FAST and RX_VK_MIRROR_SIEVE environment switches have no rows in the renderer switch table. (more on the line) Do: Add a row for each switch with its actual default and fallback behavior.Testing before merging (2) (runs on the systems it can change; it doesn't hold the recommendation)
@fixcan do L1, L2, L3, L4, L5, L6, L7, L8, L9 and L10.Checks: Still running: 8 checks.
More: does it help, other systems, switches, what was read
Does it help: Unproven for the full pull request. The author reports average FPS 59.43 to 62.40 and 1% low 23.14 to 41.87 over two interleaved runs per side on Windows 11, i7-9700 and RTX 4060, but both sides use HEAD and the baseline disables only the final commit's switches. It therefore does not measure the two preceding commits against base
544229a260.Other systems: The pool and mirror changes affect Vulkan replay, GPU-to-CPU readback and CPU uploads across vendors and operating systems; the supplied game run covers NVIDIA on Windows only. The host changes also affect Linux and machines with fewer CPU features. Cloth collision and skinning affect gameplay beyond the measured starting scene. Saves and audio were not directly changed, though scheduling and native decompression can affect their timing.
Switches: HOS_PROCESS_PRIORITY and HOS_SYNC_FAST default on; HOS_OOT_CLOTH_AVX2 defaults on. The stacked diff also adds HOS_POOL_FLAGS, HOS_COLLECT_AVX2, RX_VK_POOL_FLAGS, RX_VK_MIRROR_SYNC_FAST and RX_VK_MIRROR_SIEVE, all default on, and changes HOS_CORES and both HOS_NATIVE_ZSTD defaults. HOS_NO_PRIORITIES is extended to process priority. The new host switches and changed defaults are absent or stale in development.md, and the two new RX_VK_MIRROR switches lack switch-table rows. The evidence does not establish that all these defaults are right across supported systems.
Reviewed:
fec6ffd885against544229a260: Read AGENTS.md, CONTRIBUTING.md and the PR template in part; docs/review-checklist.md is absent. Read the commit log and the host, renderer and patch diffs, with surrounding multiwait, pool initialization and renderer binding code. Read portions of the new cloth implementation and tests; the large cloth and test output was truncated, and the remaining changed files and full surrounding code were not all read. No recorded run files or translations were included in the diff.; nothing run (a code review).Checked and fine:
Testing: No code, tests, builds or project scripts were run, as requested. CI checks listed in the prompt were still running.
Overlaps and merge order: The branch stacks on PR #2876; its two commits are included in the stated base-to-head diff. Merge order and current status could not be verified from the supplied information.
Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.
@ -0,0 +18,4 @@// (except explicit host writes via nvn_gpu_write such as packaged textures, which are forwarded// separately). On PC it does not need eager submit-time captures or GPU-to-CPU write-backs.inline bool is_gpu_only(uint32_t flags) {return (flags & (kCpuNoAccess | kPhysical)) != 0;L1 (blocking): PHYSICAL alone is treated as proof that a pool cannot be accessed by the CPU, even when its flags explicitly include CPU_CACHED.
When: A pool initialized with PHYSICAL | CPU_CACHED is classified GPU-only; host collection skips its writes and renderer writeback can skip GPU results, so CPU and GPU can observe stale data.
Do: Only exclude ranges whose flags and actual mappings establish that CPU access is impossible; preserve tracking and writeback for CPU-accessible physical pools.
@ -0,0 +28,4 @@if (lo >= hi || pools.empty()) return false;auto it = std::upper_bound(pools.begin(), pools.end(), lo,[](uint64_t a, const auto& p) { return a < p.lo; });while (it != pools.begin() && std::prev(it)->hi > lo) --it;L2 (blocking): The backward scan can stop before an earlier overlapping CPU-accessible pool.
When: With sorted pools [0,100) CPU-accessible, [10,20) GPU-only and [30,80) GPU-only, checking [40,50) stops at the short pool ending at 20 and returns true from the last pool, overlooking the first. The renderer can then omit a required writeback.
Do: Account for every overlapping interval, including earlier intervals that extend past shorter intervening ones, and add this nested-overlap case to the policy test.
@ -384,6 +384,7 @@ SW(RX_VK_PLAY_ASK_START_FIRST, kill, bool, "on (library pipelines asked of the sSW(RX_VK_PLAY_CACHE, kill, bool, "on (what play makes goes into play cache files; needs pipelineCreationCacheControl)", "0 puts every pipeline play makes into the one pipeline cache, as before the play generations.")SW(RX_VK_PLAY_SAVE_START_MB, tune, int, "64 MB (0: any growth, as before)", "Growth of the start's pipeline cache past which it is written again in play.")SW(RX_VK_POOL_END_IMPORTED, kill, bool, "off: a pool's start and end are the game pool's", "1 answers a pool's start and end from the import's range rather than the game pool's, as before.")SW(RX_VK_POOL_FLAGS, kill, bool, "on: CPU_NO_ACCESS and PHYSICAL pools skip eager captures and GPU-to-CPU write-backs", "=0 treats every pool as CPU-accessible unified memory, as before.")L9 (blocking): The new RX_VK_MIRROR_SYNC_FAST and RX_VK_MIRROR_SIEVE environment switches have no rows in the renderer switch table.
When: Both switches are read by vk_memory.cpp and default on, but the repository's required switch table does not describe either one.
Do: Add a row for each switch with its actual default and fallback behavior.
@ -4589,6 +4752,8 @@ BufferRef gpu_buffer_bind(uint64_t gpu, uint64_t size, bool written) {Pool* p = tl.p;const uint64_t off = guest - p->lo;if (p->last_value < mem_rec_value) p->last_value = mem_rec_value;if (!std::atomic_ref<bool>(p->sieve_visited).load(std::memory_order_relaxed))L4 (blocking): The lock-free binding path accesses sieve_visited atomically, but the eviction and other binding paths access the same field as a plain bool.
When: Parallel replay can mark a pool visited while mirrors_give_back reads or clears the field under pools_mu; the lock-free reader does not hold that mutex. These mixed concurrent accesses race, so eviction can lose the visit or have undefined behavior.
Do: Use atomic access consistently for every concurrent access to the field, or protect all accesses with the same lock.
@ -171,0 +214,4 @@UNLOCK();}int hos_gpu_take_host_writes(uint64_t (*out)[2], int max) {if (!nhost_writes || max <= 0) return 0;L3 (blocking): The host-write queue length is read outside the lock while producers change it under the lock.
When: A thread executing nvn_gpu_write can increment nhost_writes while the renderer calls hos_gpu_take_host_writes. The plain concurrent accesses are a data race, and the early return can miss a queued update for the collection pass.
Do: Take the lock before inspecting the queue length, or use a correctly synchronized publication protocol for both the length and queued ranges.
@ -101,1 +114,4 @@for (uint64_t p = lo >> 12; p < p1;) {#if defined(__AVX2__)if (avx2 && wide && p + 128 <= p1) {const __m256i v0 = _mm256_loadu_si256((const __m256i *)(const void *)&a64_dirty[p]);L5 (blocking): The AVX2 scan reads write marks non-atomically while game threads publish those marks with atomic stores.
When: A game thread marks a page during collect_in's vector load. The intrinsic load and atomic store access the same bytes without a common synchronization protocol, making the scan a data race and potentially missing an upload.
Do: Use a representation and scan protocol whose concurrent reads and writes are atomic, and exercise concurrent publication while collecting.
@ -0,0 +123,4 @@with tempfile.TemporaryDirectory(prefix="collect-avx2-") as tmp:c = Path(tmp) / "fixture.c"exe = Path(tmp) / "fixture"c.write_text(fixture, encoding="utf-8")L6 (should fix): The test always compiles and executes an AVX2 binary without checking whether the running CPU supports AVX2, and it ignores the suite's selected C compiler.
When: On a supported machine without AVX2 the fixture can terminate with an illegal instruction; on a Windows setup where the configured compiler is not named clang on PATH, the suite cannot compile it.
Do: Pass the suite's compiler through RUN_ALL_ARGS and gate execution of the AVX2 fixture on runtime CPU support, while retaining a baseline test.
@ -0,0 +627,4 @@encoding="utf-8")exe = tmp / ("fixture.exe" if os.name == "nt" else "fixture")for cc in compilers:for extra_flags in ([], ["-mavx2", "-mfma"]):L7 (should fix): The cloth test also unconditionally executes a binary compiled for AVX2 and FMA and does not use the compiler selected by the test suite.
When: A supported CPU without either feature can fault when the optimized fixture runs, even though the production default build has a runtime fallback. A configured compiler outside the hard-coded PATH search is also ignored.
Do: Use the suite's compiler argument and only execute the globally AVX2/FMA-compiled variant when the CPU supports both features.
Thanks @HumanBean and BeanBot — completely agree on splitting these up and testing each change individually.
After checking against current
main(28cb22b9e), most of this stacked branch is already upstream (game/oot_cloth.c,mw_watch_buckets[256], 4-wayHOS_OBJ_CACHE, andHOS_COLLECT_VECTOR), so we are splitting the remaining unmerged pieces into clean standalone PRs directly offmain:perf/pc-phase-c-threading-parallel): rebased ontomain(28cb22b9e) with the unmerged host threading & Windows process priority changes (hos_cores=8on >=8 logical cores,vc_acquirebitmask scan + milestone wait, andHOS_PROCESS_PRIORITY; happy to splitHOS_PROCESS_PRIORITYinto its own PR as well if preferred for individual testing).perf/pc-discrete-memory-coherence): rebasing directly ontomainand addressing every BeanBot blocking finding (L1 requireCPU_NO_ACCESSinstead ofPHYSICALalone soPHYSICAL | CPU_CACHEDstays tracked, L2 full nested-interval overlap check + test, L3 locked/synchronized host-write queue length inhost/nvdrv.c, L4 consistent atomicsieve_visitedacross all paths, L9gpu/vk/switches.defrows forRX_VK_MIRROR_SYNC_FASTandRX_VK_MIRROR_SIEVE, and dropping L5/L6HOS_COLLECT_AVX2sincemainalready hasHOS_COLLECT_VECTOR).Closing #2886 as superseded by
main(28cb22b9e) + #2876 / #2858.Tested on this PC, one change at a time: RTX 3090 / NVIDIA 620.70.06 / Linux (CachyOS 7.3.3), 24 threads, 32 GB.
Short version: on this PC none of the changes clearly moves fps, 1 % lows or hitches in Kokiri Forest. The full set is +0.6 % (within the runs' spread). The faster
mirror_syncscan is the only one that leans positive (+1.4 %), and that is still inside the spread. Several parts of the stack are already onmainin another form (list below).How it was tested
mainand conflicts in about 14 files. I ported the partsmaindoesn't have ontomain@46291934, each as its own patch (attached), and built them together into one game with every switch, so a single build serves every variant.T2886_VC_POLL=1, which puts the 1 ms poll back. It is not in the patches.dev.py ab, Kokiri Forest (child), 1920x1080 output, Render resolution 100 %, upscaler Off (checked in each log:upscaler: Off ... 1920x1080 -> 1920x1080), V-Sync and frame generation off, uncapped (HOS_FPS_MAX=1000).HOS_POOL_FLAGS=0 RX_VK_POOL_FLAGS=0 RX_VK_MIRROR_SYNC_FAST=0 RX_VK_MIRROR_SIEVE=0 HOS_CORES=6 T2886_VC_POLL=1. Each change was measured alone against Off: Off with only that change's switches unset.nvidia-smifor other games before each comparison.The whole port against
mainmainCheck that Off behaves as
main:main157.0 / 156.7 fps, Off 157.4 / 156.7. The same.The spread across all 28 runs is 155.9–160.3 fps: a run settles a little high or low whatever it runs, so a ±1 % difference from 2 pairs is noise.
Each change alone
2886-1-pool-flags.patch)CPU_NO_ACCESS/PHYSICALpools out of the write-mark collection, eager captures and write-backspool flags skipped 47 write-backs (46.5 MB in GPU-only pools)per 600 submits) but buys no frame time here. It still has BeanBot's blocking findings (PHYSICALwithCPU_CACHED, the overlap scan, the races).mirror_syncscan (2886-2-mirror-sync-fast.patch)main's 64-bit generations, since the PR's 32-bit compare no longer fits.2886-3-mirror-sieve.patch)HOS_CORES8 on 8+ thread PCs (2886-4-cores8.patch)2886-5-vcore-wait.patch)vc_acquirescans only the allowed cores and sleeps until the slice, starvation or escape deadline instead of waking every 1 ms2886-6-process-priority.patch)ABOVE_NORMAL_PRIORITY_CLASSat start#ifdef _WIN32, so on Linux it does nothing. The PR's Windows numbers (1 % low 23 → 42 on an i7-9700) would be the thing to confirm on a Windows PC: that's where the PR's gain would come from, if anywhere.Already on
main(not ported, nothing to measure)HOS_COLLECT_AVX2(AVX2 write-mark scan):mainalready walks the marks with vector loads (#936,HOS_COLLECT_VECTOR).HOS_NATIVE_ZSTD,_FRAMES): already the default onmain, with a per-GPU policy (#1875).HOS_OOT_CLOTH_AVX2, capsule, sphere and skinning):mainhasHOS_NATIVE_CLOTH(#2036), bit-exact host kernels for the solver passes, collisions and skinning.nx2/oot_patches.py, which these hooks went through, no longer exists.poke_multiwait(part ofHOS_SYNC_FAST):mainhas the same per-key bucket fast path.obj_nockptcache (the rest ofHOS_SYNC_FAST):mainhasHOS_OBJ_CACHE, 16384 entries, 4-way (#1781).About the patches
main@46291934.MKWVK_API_VERSIONto 57 for the newgpu_pools_flagshost slot.switches.defrow (RX_VK_MIRROR_SYNC_FASTandRX_VK_MIRROR_SIEVEhad none).test_mem_check,test_msync_pass,test_wb_learnandtest_capture_copy_runs, which readmirror_sync's source and expect its old shape (patch 2 splits it intomirror_sync_plainandmirror_sync_fast);test_direct_buffer_writes(sieve_markis not in its extracted copy); andtest_capture_pool_refresh(its stand-in host has noversionorgpu_pools_flags).test_vcore_escapepasses onmainand fails with the patch. Its model counts 1 ms looks; the PR had rewritten this test for it.Recommendation
Split the stack as asked above, rebased on current
main, keeping only these: pool flags (with BeanBot's findings fixed), themirror_syncscan, SIEVE, cores 8, the vcore wait and the Windows priority. On this RTX 3090 / Linux PC none of them is a measurable win; themirror_syncscan is the only one worth a longer run. The likely places they could matter are Windows (priority), low-VRAM cards (SIEVE, pool flags) and CPUs with fewer cores. Those want the Test Farm or a tester with that hardware.@HumanBean thank you. Porting each piece onto
mainand measuring it alone, with "Off" checked againstmainfirst, is the test this stack needed and that I didn't do.Your numbers say none of these changes is a measurable win on the RTX 3090 / Linux PC. The full set is +0.6 % against
main(median 157.9 vs 156.9 fps), inside the 155.9–160.3 fps spread of your 28 runs. The 1 % lows (140.1 / 134.0 vs 139.0 / 137.2) and worst frames don't favour it either. My Windows numbers for this stack (1 % low 23 → 42) are not reproduced there, and I won't argue with that.Each piece, against your table:
CPU_NO_ACCESSout of collection, captures, write-backs)maintoday with BeanBot's L1 (PHYSICAL | CPU_CACHED) and L2 (nested overlap, whichf595bb3had not fixed) done. Your run says it buys nothing on a 24 GB card, so #2858 has to show a gain on a low-VRAM card or I take the pool flags out of it too.mirror_syncscanRX_VK_MIRROR_SYNC_FAST) for the longer run you suggest. It's the only piece that leans positive.HOS_CORES8f439f2bb9) before your results were set against it.HOS_COLLECT_AVX2, native zstd default, cloth AVX2, lock-free multiwait, 2-way obj cachemainin another formFor 4–6 I haven't reverted anything on one neutral result. Our rule changes a shipped default only when a reviewer asks or ≥ 2 systems show it slower, and yours is neutral, not slower. But I've said on #2876 that its merged numbers are a single-PC result your run didn't reproduce, and that it needs the farm on 6–8-thread CPUs, Steam Deck, and Windows with background load.
This PR was closed on 30 Nov as superseded, and I'm leaving it as it is. Proposal: of its parts, only #1 and #2 continue, in #2858, each on the condition above. Everything else in it is dropped.
Pull request closed