PR #2607 (RemapQueue::record burst compaction) causes 15–25× regression in opening or noting guards and severe frame-time stutters #3666

Open
opened 2026-11-30 03:25:48 +00:00 by foxhelperfriend · 4 comments
foxhelperfriend commented 2026-11-30 03:25:48 +00:00 (Migrated from github.com)
Contributor

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by foxhelperfriend on 2026-11-30T03:25:48Z.


Summary

Commit 2fe2d4cc (merged as PR #2607 / d052b34d, shipped in v2026.11.29.05 / main) introduces an O(N² log N) contention pathology under the global REMAPPED mutex once RemapQueue reaches REMAP_LIMIT (32,768).

Because land::Notes::flush() → watch::landed_beside() → descriptor::host::remapped_ranges() acquires REMAPPED.lock() and calls RemapQueue::record(), all landing threads pile up behind that mutex. On an RTX 4080 SUPER + Ryzen 7 7800X3D (Series S), this regresses opening or noting guards by 15–25× (0.7–1.2 ms → 13.8–22.6 ms), slows merging what was fetched by 3–4.5×, and causes a 3–4× spike in >100 ms frame hitches.

Root Cause

In crates/victory-gpu/src/descriptor/host.rs, RemapQueue::record():

  • Previously (716a0c99), when self.ranges.len() == REMAP_LIMIT (32,768), record() did an O(1) pop_front() + push_back().
  • In PR #2607, whenever self.ranges.len() == limit and unpub_len > 0, record() allocates a new Vec, drains the entire unpublished suffix (up to 32,768 entries), runs join(&mut unpub) (sort_unstable + dedup_by), and pushes the ranges back.
  • When needed > limit, it only drops drop_n = needed - limit entries — leaving self.ranges.len() still equal to limit with zero headroom/hysteresis.
  • As a result, once the queue fills up during gameplay, every single subsequent record() call re-allocates, drains, sorts, and re-pushes up to 32,768 entries while holding the global REMAPPED mutex, and unpub_len grows toward 32,768 on every call.

A/B/A Benchmarks

Tested on 716a0c99 vs. 716a0c99 + cherry-picked 2fe2d4cc (and v2026.11.29.05) vs. reverting 2fe2d4cc back to 716a0c99:

Build opening or noting guards merging what was fetched copying back p95 frame time >100 ms resets/min
Pure 716a0c99 (10 runs, 3,100+ s) 0.6 – 1.2 ms 2.0 – 2.9 ms ~11 – 13 ms 55 – 68 ms 3 – 14 / min
v2026.11.29.05 (includes PR #2607, 5 runs) 10.3 – 19.8 ms 6.0 – 8.0 ms ~18 – 22 ms 60 – 72 ms 22 – 44 / min
716a0c99 + cherry-pick PR #2607 (6 runs) 8.8 – 22.6 ms 5.9 – 11.0 ms 19.7 – 20.0 ms 72 – 97 ms 20 – 65 / min
Reverted back to 716a0c99 (verified 10 min in) 0.9 ms (0.4–2.4 ms) 2.4 ms 10.7 ms 73.4 ms (7k draws) Cut ~50%

System: RTX 4080 SUPER | Ryzen 7 7800X3D | Windows 11 (Build 26200) | Series S

(No crash occurred, so no crash log applies.)

--- 1. Pure 716a0c99 (BEFORE PR #2607) ---
INFO victory_gpu::frame_times: frame times: 22 frames, median 46.0 ms, p95 56.4, p99 61.1, longest 61.1; 4 over 50 ms, 0 over 100 ms
INFO victory_gpu::land: landing per frame (VICTORY_LAND=1, 3 threads): which pieces to fetch 0.17 ms, then the fetches (the relay's line); looking through copies in the PC's memory 0.00 ms beside them and 0.00 ms more; merging what was fetched 2.47 ms (5.79 ms on all threads, 50 jobs), merging the others 0.00 ms (0.00 on all threads); of the threads' time 1.52 ms waiting for the title's bytes going in, 1.45 ms opening or noting guards; then ranges done with 0.15 ms, read-backs and lists 3.30, the title told 0.02, the rest 4.17

--- 2. 716a0c99 + PR #2607 (2fe2d4cc, identical switches) ---
INFO victory_gpu::frame_times: frame times: 16 frames, median 58.2 ms, p95 104.1, p99 108.2, longest 108.2; 10 over 50 ms, 3 over 100 ms
INFO victory_gpu::host: the relay per frame (VICTORY_RELAY=1): 21.1 flights landed in 11.2 landings by the thread that copies back, beside the submitting thread; that thread waited 12.3 ms for the card with nothing to land and 2.4 ms for fetches of card copies' pieces, and was 25.1 ms landing in all
INFO victory_gpu::land: landing per frame (VICTORY_LAND=1, 3 threads): which pieces to fetch 0.18 ms, then the fetches (the relay's line); looking through copies in the PC's memory 0.00 ms beside them and 0.00 ms more; merging what was fetched 10.60 ms (24.97 ms on all threads, 56 jobs), merging the others 0.00 ms (0.00 on all threads); of the threads' time 0.41 ms waiting for the title's bytes going in, 21.70 ms opening or noting guards; then ranges done with 0.13 ms, read-backs and lists 3.82, the title told 0.03, the rest 3.99

--- 3. Reverted PR #2607 back to pure 716a0c99 (even after 10M+ queue evictions) ---
INFO victory_gpu::land: landing per frame (VICTORY_LAND=1, 3 threads): which pieces to fetch 0.19 ms, then the fetches (the relay's line); looking through copies in the PC's memory 0.00 ms beside them and 0.00 ms more; merging what was fetched 2.77 ms (6.86 ms on all threads, 65 jobs), merging the others 0.00 ms (0.00 on all threads); of the threads' time 1.59 ms waiting for the title's bytes going in, 1.26 ms opening or noting guards; then ranges done with 0.13 ms, read-backs and lists 3.14, the title told 0.03, the rest 4.85
INFO victory_gpu::host: textures picked by index, the queue: ... 12497471 ranges of memory mapped, unmapped or written under texture views (10131754 evicted from history), 430683 slots made due by them

Suggested Fix

  1. Keep the O(1) *cursor = latest; fix in HostHeap::refresh_remapped() (that part is cheap).
  2. In RemapQueue::record(), avoid running O(N log N) compaction on every call at len == limit:
    • Track a compaction cooldown/threshold (e.g., only compact after at least limit / 8 or limit / 4 new unpublished records since the last compaction attempt), and/or
    • If compaction does not free meaningful slack (or when needed > limit), fall back to O(1) pop_front() until the next publish/threshold rather than leaving len == limit and re-sorting the whole unpublished tail on the very next call.

GPU: RTX 4080 SUPER | CPU: Ryzen 7 7800X3D | OS: Windows 11 (Build 26200)
GPU ver: 610.88

.logs

1-pure-716a0c99-before-pr2607.log
2-with-pr2607-regression.log
3-reverted-to-716a0c99-fixed.log

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:6688174000 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/3666). Originally posted by [foxhelperfriend](https://github.com/foxhelperfriend) on 2026-11-30T03:25:48Z. --- ### Summary Commit `2fe2d4cc` (merged as PR #2607 / `d052b34d`, shipped in `v2026.11.29.05` / `main`) introduces an O(N² log N) contention pathology under the global `REMAPPED` mutex once `RemapQueue` reaches `REMAP_LIMIT` (`32,768`). Because `land::Notes::flush()` → `watch::landed_beside()` → `descriptor::host::remapped_ranges()` acquires `REMAPPED.lock()` and calls `RemapQueue::record()`, all landing threads pile up behind that mutex. On an RTX 4080 SUPER + Ryzen 7 7800X3D (Series S), this regresses `opening or noting guards` by **15–25×** (`0.7–1.2 ms` → `13.8–22.6 ms`), slows `merging what was fetched` by **3–4.5×**, and causes a **3–4× spike in `>100 ms` frame hitches**. ### Root Cause In `crates/victory-gpu/src/descriptor/host.rs`, `RemapQueue::record()`: - Previously (`716a0c99`), when `self.ranges.len() == REMAP_LIMIT` (`32,768`), `record()` did an O(1) `pop_front()` + `push_back()`. - In PR #2607, whenever `self.ranges.len() == limit` and `unpub_len > 0`, `record()` allocates a new `Vec`, drains the entire unpublished suffix (up to `32,768` entries), runs `join(&mut unpub)` (`sort_unstable` + `dedup_by`), and pushes the ranges back. - When `needed > limit`, it only drops `drop_n = needed - limit` entries — leaving `self.ranges.len()` **still equal to `limit`** with zero headroom/hysteresis. - As a result, once the queue fills up during gameplay, **every single subsequent `record()` call** re-allocates, drains, sorts, and re-pushes up to `32,768` entries while holding the global `REMAPPED` mutex, and `unpub_len` grows toward `32,768` on every call. ### A/B/A Benchmarks Tested on `716a0c99` vs. `716a0c99` + cherry-picked `2fe2d4cc` (and `v2026.11.29.05`) vs. reverting `2fe2d4cc` back to `716a0c99`: | Build | `opening or noting guards` | `merging what was fetched` | `copying back` | `p95` frame time | `>100 ms` resets/min | | --- | --- | --- | --- | --- | --- | | Pure `716a0c99` (10 runs, 3,100+ s) | `0.6 – 1.2 ms` | `2.0 – 2.9 ms` | `~11 – 13 ms` | `55 – 68 ms` | `3 – 14 / min` | | `v2026.11.29.05` (includes PR #2607, 5 runs) | `10.3 – 19.8 ms` | `6.0 – 8.0 ms` | `~18 – 22 ms` | `60 – 72 ms` | `22 – 44 / min` | | `716a0c99` + cherry-pick PR #2607 (6 runs) | `8.8 – 22.6 ms` | `5.9 – 11.0 ms` | `19.7 – 20.0 ms` | `72 – 97 ms` | `20 – 65 / min` | | Reverted back to `716a0c99` (verified 10 min in) | **`0.9 ms`** (`0.4–2.4 ms`) | **`2.4 ms`** | **`10.7 ms`** | **`73.4 ms`** (`7k` draws) | Cut ~50% | # System: RTX 4080 SUPER | Ryzen 7 7800X3D | Windows 11 (Build 26200) | Series S # (No crash occurred, so no crash log applies.) --- 1. Pure 716a0c99 (BEFORE PR #2607) --- INFO victory_gpu::frame_times: frame times: 22 frames, median 46.0 ms, p95 56.4, p99 61.1, longest 61.1; 4 over 50 ms, 0 over 100 ms INFO victory_gpu::land: landing per frame (VICTORY_LAND=1, 3 threads): which pieces to fetch 0.17 ms, then the fetches (the relay's line); looking through copies in the PC's memory 0.00 ms beside them and 0.00 ms more; merging what was fetched 2.47 ms (5.79 ms on all threads, 50 jobs), merging the others 0.00 ms (0.00 on all threads); of the threads' time 1.52 ms waiting for the title's bytes going in, 1.45 ms opening or noting guards; then ranges done with 0.15 ms, read-backs and lists 3.30, the title told 0.02, the rest 4.17 --- 2. 716a0c99 + PR #2607 (2fe2d4cc, identical switches) --- INFO victory_gpu::frame_times: frame times: 16 frames, median 58.2 ms, p95 104.1, p99 108.2, longest 108.2; 10 over 50 ms, 3 over 100 ms INFO victory_gpu::host: the relay per frame (VICTORY_RELAY=1): 21.1 flights landed in 11.2 landings by the thread that copies back, beside the submitting thread; that thread waited 12.3 ms for the card with nothing to land and 2.4 ms for fetches of card copies' pieces, and was 25.1 ms landing in all INFO victory_gpu::land: landing per frame (VICTORY_LAND=1, 3 threads): which pieces to fetch 0.18 ms, then the fetches (the relay's line); looking through copies in the PC's memory 0.00 ms beside them and 0.00 ms more; merging what was fetched 10.60 ms (24.97 ms on all threads, 56 jobs), merging the others 0.00 ms (0.00 on all threads); of the threads' time 0.41 ms waiting for the title's bytes going in, 21.70 ms opening or noting guards; then ranges done with 0.13 ms, read-backs and lists 3.82, the title told 0.03, the rest 3.99 --- 3. Reverted PR #2607 back to pure 716a0c99 (even after 10M+ queue evictions) --- INFO victory_gpu::land: landing per frame (VICTORY_LAND=1, 3 threads): which pieces to fetch 0.19 ms, then the fetches (the relay's line); looking through copies in the PC's memory 0.00 ms beside them and 0.00 ms more; merging what was fetched 2.77 ms (6.86 ms on all threads, 65 jobs), merging the others 0.00 ms (0.00 on all threads); of the threads' time 1.59 ms waiting for the title's bytes going in, 1.26 ms opening or noting guards; then ranges done with 0.13 ms, read-backs and lists 3.14, the title told 0.03, the rest 4.85 INFO victory_gpu::host: textures picked by index, the queue: ... 12497471 ranges of memory mapped, unmapped or written under texture views (10131754 evicted from history), 430683 slots made due by them ### Suggested Fix 1. Keep the O(1) `*cursor = latest;` fix in `HostHeap::refresh_remapped()` (that part is cheap). 2. In `RemapQueue::record()`, avoid running O(N log N) compaction on every call at `len == limit`: - Track a compaction cooldown/threshold (e.g., only compact after at least `limit / 8` or `limit / 4` new unpublished records since the last compaction attempt), and/or - If compaction does not free meaningful slack (or when `needed > limit`), fall back to O(1) `pop_front()` until the next publish/threshold rather than leaving `len == limit` and re-sorting the whole unpublished tail on the very next call. GPU: RTX 4080 SUPER | CPU: Ryzen 7 7800X3D | OS: Windows 11 (Build 26200) GPU ver: 610.88 ### .logs [1-pure-716a0c99-before-pr2607.log](https://github.com/user-attachments/files/35592258/1-pure-716a0c99-before-pr2607.log) [2-with-pr2607-regression.log](https://github.com/user-attachments/files/35592257/2-with-pr2607-regression.log) [3-reverted-to-716a0c99-fixed.log](https://github.com/user-attachments/files/35592259/3-reverted-to-716a0c99-fixed.log)
github-actions[bot] commented 2026-11-30 03:25:56 +00:00 (Migrated from github.com)
Author
Contributor

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by github-actions[bot] on 2026-11-30T03:25:56Z.


Please attach both logs from the run that went wrong. Without them we can only guess. Paste %LOCALAPPDATA% into the address bar of File Explorer to get there.

  1. The play log, in %LOCALAPPDATA%\victory\logs\: the newest victory-nvidia-play-<date>-<time>-<number>.log (from victory.exe) or victory-nvidia-<date>-<time>.log (from the script launcher). The window shows its path at the start, on the line Log: ....
  2. The crash log: %LOCALAPPDATA%\VIctory\data\7952987A\crashes.log, and, if there is one from that run, the newest victory-<date>-<time>-<number>.crash.log in %LOCALAPPDATA%\VIctory\data\7952987A\temp\.

Also say which GPU, Windows version (10 or 11)

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7267886806 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/3666#issuecomment-7267886806). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-30T03:25:56Z. --- Please attach both logs from the run that went wrong. Without them we can only guess. Paste `%LOCALAPPDATA%` into the address bar of File Explorer to get there. 1. The play log, in `%LOCALAPPDATA%\victory\logs\`: the newest `victory-nvidia-play-<date>-<time>-<number>.log` (from `victory.exe`) or `victory-nvidia-<date>-<time>.log` (from the script launcher). The window shows its path at the start, on the line `Log: ...`. 2. The crash log: `%LOCALAPPDATA%\VIctory\data\7952987A\crashes.log`, and, if there is one from that run, the newest `victory-<date>-<time>-<number>.crash.log` in `%LOCALAPPDATA%\VIctory\data\7952987A\temp\`. Also say which GPU, Windows version (10 or 11)
foxhelperfriend commented 2026-11-30 03:34:26 +00:00 (Migrated from github.com)
Author
Contributor

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by foxhelperfriend on 2026-11-30T03:34:26Z.


Please attach both logs from the run that went wrong. Without them we can only guess. Paste %LOCALAPPDATA% into the address bar of File Explorer to get there.

  1. The play log, in %LOCALAPPDATA%\victory\logs\: the newest victory-nvidia-play-<date>-<time>-<number>.log (from victory.exe) or victory-nvidia-<date>-<time>.log (from the script launcher). The window shows its path at the start, on the line Log: ....
  2. The crash log: %LOCALAPPDATA%\VIctory\data\7952987A\crashes.log, and, if there is one from that run, the newest victory-<date>-<time>-<number>.crash.log in %LOCALAPPDATA%\VIctory\data\7952987A\temp\.

Also say which GPU, Windows version (10 or 11)

Play log excerpt can be found in original post, as well as system info.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7268008245 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/3666#issuecomment-7268008245). Originally posted by [foxhelperfriend](https://github.com/foxhelperfriend) on 2026-11-30T03:34:26Z. --- > Please attach both logs from the run that went wrong. Without them we can only guess. Paste `%LOCALAPPDATA%` into the address bar of File Explorer to get there. > > 1. The play log, in `%LOCALAPPDATA%\victory\logs\`: the newest `victory-nvidia-play-<date>-<time>-<number>.log` (from `victory.exe`) or `victory-nvidia-<date>-<time>.log` (from the script launcher). The window shows its path at the start, on the line `Log: ...`. > 2. The crash log: `%LOCALAPPDATA%\VIctory\data\7952987A\crashes.log`, and, if there is one from that run, the newest `victory-<date>-<time>-<number>.crash.log` in `%LOCALAPPDATA%\VIctory\data\7952987A\temp\`. > > Also say which GPU, Windows version (10 or 11) Play log excerpt can be found in original post, as well as system info.
foxhelperfriend commented 2026-11-30 04:26:37 +00:00 (Migrated from github.com)
Author
Contributor

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by foxhelperfriend on 2026-11-30T04:26:37Z.


System info can be seen in original post (GPU: RTX 4080 SUPER - Ver 610.88 | CPU: Ryzen 7 7800X3D | OS: Windows 11 (Build 26200)

1-pure-716a0c99-before-pr2607.log
2-with-pr2607-regression.log
3-reverted-to-716a0c99-fixed.log

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7268780078 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/3666#issuecomment-7268780078). Originally posted by [foxhelperfriend](https://github.com/foxhelperfriend) on 2026-11-30T04:26:37Z. --- System info can be seen in original post (GPU: RTX 4080 SUPER - Ver 610.88 | CPU: Ryzen 7 7800X3D | OS: Windows 11 (Build 26200) [1-pure-716a0c99-before-pr2607.log](https://github.com/user-attachments/files/35592227/1-pure-716a0c99-before-pr2607.log) [2-with-pr2607-regression.log](https://github.com/user-attachments/files/35592228/2-with-pr2607-regression.log) [3-reverted-to-716a0c99-fixed.log](https://github.com/user-attachments/files/35592229/3-reverted-to-716a0c99-fixed.log)
HQasper commented 2026-11-30 14:30:42 +00:00 (Migrated from github.com)
Author
Contributor

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by HQasper on 2026-11-30T14:30:42Z.


The same regression, measured on an RTX 5090 + Ryzen 9 9950X3D (driver 621.24, Windows 11 26300), on 41adb551 plus local commits. The scene is the opening from one save: Series X profile, 1440p, DLSS Quality, ray tracing off. The figure is frames over 50 ms in the first 60 s after the world appears. Runs are 170 s, interleaved, one number per run.

Bisection (builds reverting groups of the commits between f72cec77 and 41adb551):

Build Frames > 50 ms on the way in
f72cec77-based (before #2607) 43, 40
41adb551-based 75, 82, 71, 88, 83, 83
41adb551-based, 2fe2d4cc reverted 68, 57
41adb551-based, 2fe2d4cc and 5c604fec reverted 53, 47

The steady frame rate after the way in did not change within the spread. #2607 still does what it set out to do: the "evicted from history" count was 1.56 M with it against 2.65-2.69 M without.

A fix along the lines of #3877. Once a compaction of the full queue frees less than an eighth of it, it is not retried until the next snapshot moves the published mark; records evict in O(1) meanwhile. Four runs each, interleaved:

Frames > 50 ms on the way in Steady fps 1 % low 0.1 % low
41adb551-based 82 (74, 95, 75, 82) 38.5 25.5 20.8
with the fix 48 (50, 47, 52, 44) 38.5 26.0 22.5

Patch: HQasper/VIctory-NVIDIA#9 (fork draft, one commit on 41adb551). It overlaps #3877, #3733 and #3730, so I am not opening another PR; these numbers are in support of fixing it.

🤖 Generated with Claude Code

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:comment:7281489119 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/issues/3666#issuecomment-7281489119). Originally posted by [HQasper](https://github.com/HQasper) on 2026-11-30T14:30:42Z. --- The same regression, measured on an RTX 5090 + Ryzen 9 9950X3D (driver 621.24, Windows 11 26300), on 41adb551 plus local commits. The scene is the opening from one save: Series X profile, 1440p, DLSS Quality, ray tracing off. The figure is frames over 50 ms in the first 60 s after the world appears. Runs are 170 s, interleaved, one number per run. **Bisection** (builds reverting groups of the commits between f72cec77 and 41adb551): | Build | Frames > 50 ms on the way in | |---|---| | f72cec77-based (before #2607) | 43, 40 | | 41adb551-based | 75, 82, 71, 88, 83, 83 | | 41adb551-based, 2fe2d4cc reverted | 68, 57 | | 41adb551-based, 2fe2d4cc and 5c604fec reverted | 53, 47 | The steady frame rate after the way in did not change within the spread. #2607 still does what it set out to do: the "evicted from history" count was 1.56 M with it against 2.65-2.69 M without. **A fix along the lines of #3877.** Once a compaction of the full queue frees less than an eighth of it, it is not retried until the next snapshot moves the published mark; records evict in O(1) meanwhile. Four runs each, interleaved: | | Frames > 50 ms on the way in | Steady fps | 1 % low | 0.1 % low | |---|---|---|---|---| | 41adb551-based | 82 (74, 95, 75, 82) | 38.5 | 25.5 | 20.8 | | with the fix | 48 (50, 47, 52, 44) | 38.5 | 26.0 | 22.5 | Patch: HQasper/VIctory-NVIDIA#9 (fork draft, one commit on 41adb551). It overlaps #3877, #3733 and #3730, so I am not opening another PR; these numbers are in support of fixing it. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
trustno1-coder/VIctory-NVIDIA#3666
No description provided.