From fcaf4b5444a5eea6ba70694770b7e0b6ba86728b Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 7 Aug 2026 13:54:08 +0200 Subject: Faster replay ram clear by not free'ing the data immediately --- src/replay_buffer/replay_buffer_ram.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/replay_buffer/replay_buffer_ram.c b/src/replay_buffer/replay_buffer_ram.c index 39f31b1..a148a20 100644 --- a/src/replay_buffer/replay_buffer_ram.c +++ b/src/replay_buffer/replay_buffer_ram.c @@ -95,14 +95,14 @@ static bool gsr_replay_buffer_ram_append(gsr_replay_buffer *replay_buffer, const return true; } +/* + The packets are not free'd here because that takes seconds when the replay buffer holds several gigabytes of data, + which would block the thread that appends to the replay buffer for that long. The packets are instead left in place + where they are no longer reachable and gsr_replay_buffer_ram_append free's them one by one as it overwrites them, + which it already does when the ring buffer wraps around. +*/ static void gsr_replay_buffer_ram_clear(gsr_replay_buffer *replay_buffer) { gsr_replay_buffer_ram *self = (gsr_replay_buffer_ram*)replay_buffer; - for(size_t i = 0; i < self->num_packets; ++i) { - if(self->packets[i]) { - gsr_av_packet_ram_unref(self->packets[i]); - self->packets[i] = NULL; - } - } self->num_packets = 0; self->index = 0; } -- cgit v1.2.3