[perf][LOW] CRAFTER_TIMING frame-time history uses erase(begin()) every frame #44

Closed
opened 2026-06-16 16:51:30 +02:00 by jorijnvdgraaf · 0 comments

Subsystem: Window / swapchain / frame loop (timing builds only)
Location: implementations/Crafter.Graphics-Window.cpp:660-665
Impact: LOW · Effort: Small

Problem

frameTimes.erase(frameTimes.begin()) memmoves ~100 elements left every frame once full. Compiled only in CRAFTER_TIMING builds.

Proposed fix

Fixed-size ring buffer (std::array<nanoseconds,100> + head). LogTiming does order-independent sum/avg/min/max, so a ring works. Keep updateTimings as a capacity-reused vector.

Note

The "skews measurement" framing is exaggerated — ~99×8 bytes, L1-resident, single-digit ns, dwarfed by the clock::now() calls already in the timing path.

**Subsystem:** Window / swapchain / frame loop (timing builds only) **Location:** `implementations/Crafter.Graphics-Window.cpp:660-665` **Impact:** LOW · **Effort:** Small ### Problem `frameTimes.erase(frameTimes.begin())` memmoves ~100 elements left every frame once full. Compiled only in `CRAFTER_TIMING` builds. ### Proposed fix Fixed-size ring buffer (`std::array<nanoseconds,100>` + head). `LogTiming` does order-independent sum/avg/min/max, so a ring works. Keep `updateTimings` as a capacity-reused vector. ### Note The "skews measurement" framing is exaggerated — ~99×8 bytes, L1-resident, single-digit ns, dwarfed by the `clock::now()` calls already in the timing path.
Sign in to join this conversation.
No milestone
No project
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.

Dependencies

No dependencies set.

Reference
Catcrafts/Crafter.Graphics#44
No description provided.