perf(gpu): avoid Vec allocation in watch::pieces and reuse shard read locks in parts_written #58

Merged
ahmetbagci8 merged 1 commit from upstream-pr/58 into main 2026-12-01 18:40:52 +00:00
ahmetbagci8 commented 2026-12-01 18:37:59 +00:00 (Migrated from github.com)

Imported from edsuuu/VI-BR-PORT. Originally posted by ahmetbagci8 on 2026-12-01T18:37:59Z.


Part of #27.

Summary

Eliminates hot-path heap allocations and redundant shard \RwLock\ acquisitions in \ ictory_gpu:⌚

  1. **Zero-allocation \pieces(first, last)**: Returns \Option<impl Iterator<Item = (usize, usize)>>\ backed by a \Range\ instead of allocating a \Vec<(usize, usize)>\ on every \Notes::each\ / \Held::range\ lookup.
  2. **Shard read-lock reuse in \parts_written\ / \Notes::parts_since_many**:
    • Returns \Vec::new()\ early when \pages\ is empty, avoiding acquiring the global \journal()\ lock.
    • Reuses the active shard's \RwLockReadGuard\ across consecutive pages in the same 1024-page shard, dropping the previous guard before acquiring the next shard so at most one shard lock is held at a time.

Verification

  • \cargo test -p victory-gpu --lib watch::\ (51 passed, 0 failed)
  • \cargo clippy -p victory-gpu --tests -- -D warnings\ (clean)
  • \cargo test -p xtask english\ (5 passed)
<!-- greyfinch-sync:edsuuu/VI-BR-PORT:issue:5592091590 --> Imported from [edsuuu/VI-BR-PORT](https://github.com/edsuuu/VI-BR-PORT/pull/58). Originally posted by [ahmetbagci8](https://github.com/ahmetbagci8) on 2026-12-01T18:37:59Z. --- Part of #27. ### Summary Eliminates hot-path heap allocations and redundant shard \RwLock\ acquisitions in \ ictory_gpu::watch\: 1. **Zero-allocation \pieces(first, last)\**: Returns \Option<impl Iterator<Item = (usize, usize)>>\ backed by a \Range<usize>\ instead of allocating a \Vec<(usize, usize)>\ on every \Notes::each\ / \Held::range\ lookup. 2. **Shard read-lock reuse in \parts_written\ / \Notes::parts_since_many\**: - Returns \Vec::new()\ early when \pages\ is empty, avoiding acquiring the global \journal()\ lock. - Reuses the active shard's \RwLockReadGuard\ across consecutive pages in the same 1024-page shard, dropping the previous guard before acquiring the next shard so at most one shard lock is held at a time. ### Verification - \cargo test -p victory-gpu --lib watch::\ (51 passed, 0 failed) - \cargo clippy -p victory-gpu --tests -- -D warnings\ (clean) - \cargo test -p xtask english\ (5 passed)
Sign in to join this conversation.
No reviewers
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
edsuuu/VI-BR-PORT!58
No description provided.