perf(victory-gpu): use RwLock for early pipeline tracking and avoid Call string formatting #416

Manually merged
github merged 1 commit from github-bot/gh-416 into main 2026-11-26 18:56:35 +00:00 AGit
Owner

@⁠Lewandox on GitHub · 2026-11-26 18:00 UTC · original
Lewandox:perf/victory-gpu-pipeline-library → main · +104 −18 · 1 files · 2 commits · merged 2026-11-26 18:52 UTC

Summary

Removes unnecessary heap allocations and mutex contention on the hot pipeline-library lookup/creation path while keeping identical removal_note() diagnostics on device removal.

Changes

  1. USED (wanted_early / note_used) — RwLock + zero-allocation check:

    • Switched USED from Mutex<Option<HashSet<String>>> to RwLock<Option<HashSet<String>>> with lazy initialization helper ensure_used().
    • wanted_early(key) now takes a shared read lock instead of an exclusive mutex.
    • note_used(key) checks membership and the EARLY_MAX cap under a shared read lock first, returning immediately with zero write lock and zero key.to_owned() heap allocation once a pipeline key has been seen.
  2. Call / CALLS — deferred string formatting & inline pipeline names:

    • Stored thread-local LABEL as Arc<str> instead of cloning a heap String on every call().
    • Introduced compact CallName (Inline([u8; 32], u8) / Heap(String)) so 32-byte pipeline hash keys do not allocate on the heap during call("load" | "make" | "store", name).
    • Deferred format!("{name} {label}") so formatting only happens inside removal_note() if a device removal actually occurs.
  3. Tests:

    • Added unit tests for CallName inline/heap storage, Call formatting in removal_note(), and wanted_early / note_used behavior.

Verification

  • cargo test -p victory-gpu --lib pipeline::library::tests (default and --features diagnostics)
  • cargo xtask policy
**@⁠Lewandox** on GitHub · 2026-11-26 18:00 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/416) `Lewandox:perf/victory-gpu-pipeline-library` → `main` · +104 −18 · 1 files · 2 commits · merged 2026-11-26 18:52 UTC ## Summary Removes unnecessary heap allocations and mutex contention on the hot pipeline-library lookup/creation path while keeping identical `removal_note()` diagnostics on device removal. ### Changes 1. **`USED` (`wanted_early` / `note_used`) — `RwLock` + zero-allocation check**: - Switched `USED` from `Mutex<Option<HashSet<String>>>` to `RwLock<Option<HashSet<String>>>` with lazy initialization helper `ensure_used()`. - `wanted_early(key)` now takes a shared read lock instead of an exclusive mutex. - `note_used(key)` checks membership and the `EARLY_MAX` cap under a shared read lock first, returning immediately with zero write lock and zero `key.to_owned()` heap allocation once a pipeline key has been seen. 2. **`Call` / `CALLS` — deferred string formatting & inline pipeline names**: - Stored thread-local `LABEL` as `Arc<str>` instead of cloning a heap `String` on every `call()`. - Introduced compact `CallName` (`Inline([u8; 32], u8)` / `Heap(String)`) so 32-byte pipeline hash keys do not allocate on the heap during `call("load" | "make" | "store", name)`. - Deferred `format!("{name} {label}")` so formatting only happens inside `removal_note()` if a device removal actually occurs. 3. **Tests**: - Added unit tests for `CallName` inline/heap storage, `Call` formatting in `removal_note()`, and `wanted_early` / `note_used` behavior. ## Verification - `cargo test -p victory-gpu --lib pipeline::library::tests` (default and `--features diagnostics`) - `cargo xtask policy`
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 18:03:28 +00:00
github manually merged commit 8335d5c54c into main 2026-11-26 18:56:35 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.