perf(device): pop retired deletions off the front in O(ready) (#116)
ReclaimDeletions ran an O(n) walk + survivor compaction over the whole deletion queue every frame. frameCounter is monotonic, so retireAfter is non-decreasing down the queue and the entries ready to reclaim are always a contiguous prefix. Switch deletionQueue from std::vector to std::deque and pop the ready prefix off the front, stopping at the first entry still in flight — O(ready) instead of O(queue). Resolves #116 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
9d9f9d9d2c
commit
2460a66296
2 changed files with 20 additions and 15 deletions
|
|
@ -320,7 +320,11 @@ export namespace Crafter {
|
|||
// Zero until set, which only makes ReclaimDeletions more eager — and it
|
||||
// is never called before a Window (which sets this) starts rendering.
|
||||
inline static std::uint8_t framesInFlight = 0;
|
||||
inline static std::vector<PendingDeletion> deletionQueue;
|
||||
// A deque, not a vector: frameCounter is monotonic, so retireAfter is
|
||||
// non-decreasing down the queue and the entries ready to reclaim are
|
||||
// always a prefix. ReclaimDeletions pops that prefix off the front in
|
||||
// O(ready) instead of walking and compacting the whole queue.
|
||||
inline static std::deque<PendingDeletion> deletionQueue;
|
||||
// Tag {buffer, memory} for deletion after framesInFlight more frames.
|
||||
// A VK_NULL_HANDLE buffer is ignored (nothing to free).
|
||||
static void EnqueueDeletion(VkBuffer buffer, VkDeviceMemory memory);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue