VSP-19: Placed-view table (Views) bounded shapes, hash indexes, and sliced idle eviction #25

Closed
github-bot wants to merge 0 commits from github-bot/gh-25 into main AGit
Owner

@⁠adriaespii on GitHub · 2026-11-30 20:30 UTC · original
adriaespii:vsp-19-views-idle-eviction → main · +25 −8 · 1 files · 66 commits · closed without merging

Summary

  • Claimed Task ID: VSP-19 (linked Task Claim issue: #24, roadmap task: #12, related: #5)
  • What this PR changes:
    • Switches Views::index and Views::shape_index in crates/vesper-gpu/src/descriptor.rs from BTreeMap to HashMap (deriving Hash on View) for O(1) lookups and lower per-entry overhead.
    • Caps inline placed-view shapes at PLACED_SHAPE_CAP = 262_144 so shapes / shape_index stay bounded, overflowing any additional shapes cleanly into the evictable table.
    • Adds sliced idle eviction (SWEEP_SLICE = 4096, IDLE_EVICT_FRAMES = 1_800, EVICT_HIGH_WATER = 65_536, periodic sweep every SWEEP_PERIOD_FRAMES = 16 from sync_heaps and on-demand when free is empty) for resource-less entries (View::Placed and View::Constant) only; resource-backed views (Shader/Unordered) and samplers are never evicted.
    • Tracks last_used: AtomicU64 per slot updated lock-free under VIEWS.read() on lookup_entry / entry_of (skipping redundant stores within the same frame), increments generation + marks live = false / retired = true on eviction so stale handles always resolve to None, and tracks RETIRED_TOTAL / RETIRED_READS counters.
    • Adds 3 unit tests in descriptor::tests: placed_shape_cap_bounds_shapes_and_falls_back_to_table, idle_eviction_retires_stale_placed_views_and_reuses_slots, and idle_eviction_never_retires_resource_views_or_samplers.

AI Assistance Disclosure

  • No AI coding tools were used
  • AI coding tools were used (specify model/tool and what you manually verified): Assisted by Antigravity (Gemini) for design, implementation, and unit tests. Manually verified by running all local build/lint/test commands and live Series X 1440p HW RT gameplay sessions on RX 9070 + Ryzen 5 7600 + 32 GB RAM (including catching and fixing an initial too-low shape cap / idle threshold that caused 12 retired reads before tuning to 262,144 shapes / 1,800 frames / 65,536 high-water with 0 retired reads and clean visuals).

Benchmark Comparison (Required for perf / GPU / memory changes)

Hardware: AMD Ryzen 5 7600 (6C/12T) / 32 GB DDR5-6000 / AMD Radeon RX 9070 16 GB (driver 32.0.32029.2010) / Windows 11 Pro build 26300
Profile: scripts\launch.cmd [1] Series X — 1440p Native (2560x1440, VESPER_RENDER_SCALE=1.0, HW RT)

Metric Before (main 7b7e556) After (this PR)
p50 FPS / ms 14.83 FPS / 67.434 ms 29.41 FPS / 33.998 ms
p95 Frame Time (ms) 658.237 ms 99.944 ms
p99 ms (1% Low FPS) 1028.092 ms (0.97 FPS) 159.586 ms (6.27 FPS)
Frames >100 ms (%) 26.96% 5.01%
Max >100 ms Streak (s) 76.42 s 4.24 s
Peak Private RAM (MB) 31,259 MB (24 MB free min) 30,720 MB (410 MB free min)
retired_reads — 0

(Note: After run duration was 127.05 s / 2,874 gameplay frames vs. 230.64 s / 1,135 gameplay frames Before; dropped_pso=0, dropped_ind=0, steady-state visuals clean.)

Local Verification Results

  • cargo xtask policy: 316 files ok
  • cargo test -p xtask --locked: 9 passed, 0 failed
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: 0 warnings, 0 errors
  • cargo test -p vesper-gpu --locked -- --test-threads=1: 541 passed, 0 failed, 35 ignored
  • cargo test -p vesper-gpu --features diagnostics --locked descriptor::tests -- --test-threads=1: 13 passed, 0 failed
  • cargo test --workspace --locked -- --test-threads=1: all crates pass except 2 pre-existing WARP 8-bit unorm rounding tests in untouched vesper-shader (emit::valu_tests::normalized_buffer_formats_load_correctly_rounded_quotients and normalized_codes_truncate_back_to_themselves on Win11 build 26300).

Mandatory Verification Checklist

  • Diff obeys AGENTS.md, stays inside claimed VSP-19 files (crates/vesper-gpu/src/descriptor.rs only), and avoids the Maintainer Active Queue (ROADMAP.md)
  • cargo xtask policy and cargo test -p xtask --locked pass cleanly
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings passes with 0 warnings
  • cargo test -p vesper-gpu --locked -- --test-threads=1 and diagnostics descriptor::tests pass (plus workspace tests noted above)
  • Safety gates remain enabled (VESPER_WAIT_RESIDENT=textures, indirect clamping intact) and steady-state visuals are verified clean
  • Contains zero proprietary assets, keys, dumps, screenshots, or third-party studio/franchise names
  • Ready for 3 independent peer reviews (peer-review-gate) before maintainer review
**@⁠adriaespii** on GitHub · 2026-11-30 20:30 UTC · [original](https://github.com/monte-alt/vesper/pull/25) `adriaespii:vsp-19-views-idle-eviction` → `main` · +25 −8 · 1 files · 66 commits · closed without merging ## Summary - **Claimed Task ID:** `VSP-19` (linked Task Claim issue: #24, roadmap task: #12, related: #5) - **What this PR changes:** - Switches `Views::index` and `Views::shape_index` in `crates/vesper-gpu/src/descriptor.rs` from `BTreeMap` to `HashMap` (deriving `Hash` on `View`) for O(1) lookups and lower per-entry overhead. - Caps inline placed-view shapes at `PLACED_SHAPE_CAP = 262_144` so `shapes` / `shape_index` stay bounded, overflowing any additional shapes cleanly into the evictable table. - Adds sliced idle eviction (`SWEEP_SLICE = 4096`, `IDLE_EVICT_FRAMES = 1_800`, `EVICT_HIGH_WATER = 65_536`, periodic sweep every `SWEEP_PERIOD_FRAMES = 16` from `sync_heaps` and on-demand when `free` is empty) for resource-less entries (`View::Placed` and `View::Constant`) only; resource-backed views (`Shader`/`Unordered`) and samplers are never evicted. - Tracks `last_used: AtomicU64` per slot updated lock-free under `VIEWS.read()` on `lookup_entry` / `entry_of` (skipping redundant stores within the same frame), increments `generation` + marks `live = false` / `retired = true` on eviction so stale handles always resolve to `None`, and tracks `RETIRED_TOTAL` / `RETIRED_READS` counters. - Adds 3 unit tests in `descriptor::tests`: `placed_shape_cap_bounds_shapes_and_falls_back_to_table`, `idle_eviction_retires_stale_placed_views_and_reuses_slots`, and `idle_eviction_never_retires_resource_views_or_samplers`. ## AI Assistance Disclosure - [ ] No AI coding tools were used - [x] AI coding tools were used (specify model/tool and what you manually verified): Assisted by Antigravity (Gemini) for design, implementation, and unit tests. Manually verified by running all local build/lint/test commands and live Series X 1440p HW RT gameplay sessions on RX 9070 + Ryzen 5 7600 + 32 GB RAM (including catching and fixing an initial too-low shape cap / idle threshold that caused 12 retired reads before tuning to 262,144 shapes / 1,800 frames / 65,536 high-water with 0 retired reads and clean visuals). ## Benchmark Comparison (Required for perf / GPU / memory changes) Hardware: AMD Ryzen 5 7600 (6C/12T) / 32 GB DDR5-6000 / AMD Radeon RX 9070 16 GB (driver 32.0.32029.2010) / Windows 11 Pro build 26300 Profile: `scripts\launch.cmd` `[1]` **Series X — 1440p Native** (`2560x1440`, `VESPER_RENDER_SCALE=1.0`, HW RT) | Metric | Before (`main` `7b7e556`) | After (this PR) | |---|---:|---:| | p50 FPS / ms | 14.83 FPS / 67.434 ms | 29.41 FPS / 33.998 ms | | p95 Frame Time (ms) | 658.237 ms | 99.944 ms | | p99 ms (1% Low FPS) | 1028.092 ms (0.97 FPS) | 159.586 ms (6.27 FPS) | | Frames >100 ms (%) | 26.96% | 5.01% | | Max >100 ms Streak (s) | 76.42 s | 4.24 s | | Peak Private RAM (MB) | 31,259 MB (24 MB free min) | 30,720 MB (410 MB free min) | | `retired_reads` | — | 0 | *(Note: After run duration was 127.05 s / 2,874 gameplay frames vs. 230.64 s / 1,135 gameplay frames Before; `dropped_pso=0`, `dropped_ind=0`, steady-state visuals clean.)* ## Local Verification Results - `cargo xtask policy`: **316 files ok** - `cargo test -p xtask --locked`: **9 passed, 0 failed** - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`: **0 warnings, 0 errors** - `cargo test -p vesper-gpu --locked -- --test-threads=1`: **541 passed, 0 failed, 35 ignored** - `cargo test -p vesper-gpu --features diagnostics --locked descriptor::tests -- --test-threads=1`: **13 passed, 0 failed** - `cargo test --workspace --locked -- --test-threads=1`: all crates pass except 2 pre-existing WARP 8-bit unorm rounding tests in untouched `vesper-shader` (`emit::valu_tests::normalized_buffer_formats_load_correctly_rounded_quotients` and `normalized_codes_truncate_back_to_themselves` on Win11 build 26300). ## Mandatory Verification Checklist - [x] Diff obeys `AGENTS.md`, stays inside claimed `VSP-19` files (`crates/vesper-gpu/src/descriptor.rs` only), and avoids the Maintainer Active Queue (`ROADMAP.md`) - [x] `cargo xtask policy` and `cargo test -p xtask --locked` pass cleanly - [x] `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings` passes with 0 warnings - [x] `cargo test -p vesper-gpu --locked -- --test-threads=1` and diagnostics `descriptor::tests` pass (plus workspace tests noted above) - [x] Safety gates remain enabled (`VESPER_WAIT_RESIDENT=textures`, indirect clamping intact) and steady-state visuals are verified clean - [x] Contains zero proprietary assets, keys, dumps, screenshots, or third-party studio/franchise names - [x] Ready for **3 independent peer reviews** (`peer-review-gate`) before maintainer review
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 20:32:34 +00:00
Author
Owner

@⁠monte-alt on GitHub · 2026-11-30 20:58 UTC · original

thank you for testing this. reusing a slot clears the retired flag. reading the old handle after that can fail without counting a retired read. can you test that case and repeat both drives on the same route for the same duration?

**@⁠monte-alt** on GitHub · 2026-11-30 20:58 UTC · [original](https://github.com/monte-alt/vesper/pull/25#issuecomment-7291724610) thank you for testing this. reusing a slot clears the retired flag. reading the old handle after that can fail without counting a retired read. can you test that case and repeat both drives on the same route for the same duration?
github-bot force-pushed github-bot/gh-25 from af5866b865 to 2f3f7f7433 2026-11-30 23:26:19 +00:00 Compare
Author
Owner

@⁠adriaespii on GitHub · 2026-11-30 23:23 UTC · original

@⁠monte-alt Good catch, thank you! Fixed in the latest commit (rebased onto main): ViewEntry now keeps a small fixed ring of recently retired generations (retired_gens: [u32; 4]) that persists across slot reuse and forget(), so any stale read of an idle-retired generation still increments RETIRED_READS even after the slot is recycled for a newer view. Added an explicit post-reuse assertion for this case in descriptor::tests::idle_eviction_retires_stale_placed_views_and_reuses_slots (all 13 descriptor::tests, xtask policy, and clippy -D warnings pass). I will re-run both Before (main) and After (this PR) drives on the exact same route and duration and update the benchmark table once captured.

**@⁠adriaespii** on GitHub · 2026-11-30 23:23 UTC · [original](https://github.com/monte-alt/vesper/pull/25#issuecomment-7295055363) @⁠monte-alt Good catch, thank you! Fixed in the latest commit (rebased onto `main`): `ViewEntry` now keeps a small fixed ring of recently retired generations (`retired_gens: [u32; 4]`) that persists across slot reuse and `forget()`, so any stale read of an idle-retired generation still increments `RETIRED_READS` even after the slot is recycled for a newer view. Added an explicit post-reuse assertion for this case in `descriptor::tests::idle_eviction_retires_stale_placed_views_and_reuses_slots` (all 13 `descriptor::tests`, `xtask policy`, and `clippy -D warnings` pass). I will re-run both Before (`main`) and After (this PR) drives on the exact same route and duration and update the benchmark table once captured.
Author
Owner

@⁠adriaespii on GitHub · 2026-12-01 00:17 UTC · original · edited 2026-12-01 13:53 UTC

@⁠monte-alt Here are the same-route, matched-duration runs on v0.9.0 (Series X 1440p Native + HW RT, Ryzen 5 7600 / 32 GB / RX 9070):

Metric Before (origin/main 37555a4) After (PR #25 2f3f7f7)
Gameplay Duration / Frames 166.75 s / 3,720 frames 180.13 s / 1,885 frames
Draws (median) 3,979 3,775
p50 FPS / ms 29.19 FPS / 34.26 ms 19.72 FPS / 50.70 ms
prep p50 ms 16.07 ms 21.99 ms
p95 Frame Time (ms) 68.55 ms 150.03 ms
p99 ms (1% Low FPS) 138.01 ms (7.25 FPS) 661.28 ms (1.51 FPS)
Frames >100 ms (%) 2.10% (78 frames) 20.05% (378 frames)
Max >100 ms Streak (s) 3.32 s 4.60 s
Free RAM min / median (MB) 883 MB / 1,427 MB 61 MB / 926 MB
retired / retired_reads — 0 / 0

Honest notes on these two runs:

  • Cache order caveat: The After run was executed first right after rebasing onto v0.9.0 (cold v0.9.0 pipeline cache, compiling pipelines during the run and pushing free RAM down to 61 MB), whereas Before ran second with the v0.9.0 pipeline library already warm on disk.
  • Eviction threshold: Over this ~3-minute stretch with PLACED_SHAPE_CAP = 262_144 and EVICT_HIGH_WATER = 65_536, overflow never crossed the high-water mark (retired = 0, retired_reads = 0, visuals completely clean).
  • I can repeat a warm-cache After run (or a longer 10-minute city drive so eviction actively fires with the new retired_gens ring) if you want warm-vs-warm numbers before review.
**@⁠adriaespii** on GitHub · 2026-12-01 00:17 UTC · [original](https://github.com/monte-alt/vesper/pull/25#issuecomment-7296159264) · edited 2026-12-01 13:53 UTC @⁠monte-alt Here are the same-route, matched-duration runs on `v0.9.0` (`Series X 1440p Native + HW RT`, Ryzen 5 7600 / 32 GB / RX 9070): | Metric | Before (`origin/main` `37555a4`) | After (`PR #25` `2f3f7f7`) | |---|---:|---:| | Gameplay Duration / Frames | 166.75 s / 3,720 frames | 180.13 s / 1,885 frames | | Draws (median) | 3,979 | 3,775 | | p50 FPS / ms | 29.19 FPS / 34.26 ms | 19.72 FPS / 50.70 ms | | prep p50 ms | 16.07 ms | 21.99 ms | | p95 Frame Time (ms) | 68.55 ms | 150.03 ms | | p99 ms (1% Low FPS) | 138.01 ms (7.25 FPS) | 661.28 ms (1.51 FPS) | | Frames >100 ms (%) | 2.10% (78 frames) | 20.05% (378 frames) | | Max >100 ms Streak (s) | 3.32 s | 4.60 s | | Free RAM min / median (MB) | 883 MB / 1,427 MB | 61 MB / 926 MB | | `retired` / `retired_reads` | — | 0 / 0 | **Honest notes on these two runs:** - **Cache order caveat:** The `After` run was executed first right after rebasing onto `v0.9.0` (cold `v0.9.0` pipeline cache, compiling pipelines during the run and pushing free RAM down to 61 MB), whereas `Before` ran second with the `v0.9.0` pipeline library already warm on disk. - **Eviction threshold:** Over this ~3-minute stretch with `PLACED_SHAPE_CAP = 262_144` and `EVICT_HIGH_WATER = 65_536`, overflow never crossed the high-water mark (`retired = 0`, `retired_reads = 0`, visuals completely clean). - I can repeat a warm-cache `After` run (or a longer 10-minute city drive so eviction actively fires with the new `retired_gens` ring) if you want warm-vs-warm numbers before review.
github-bot force-pushed github-bot/gh-25 from 2f3f7f7433 to 146eead77e 2026-12-01 15:10:50 +00:00 Compare
github-bot closed this pull request 2026-12-05 07:57:33 +00:00

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.