diff options
| author | dec05eba <dec05eba@protonmail.com> | 2026-08-07 13:54:08 +0200 |
|---|---|---|
| committer | dec05eba <dec05eba@protonmail.com> | 2026-08-07 13:54:08 +0200 |
| commit | fcaf4b5444a5eea6ba70694770b7e0b6ba86728b (patch) | |
| tree | 557ff247631f7db03cf2077104eab3f1b3412e22 | |
| parent | 90ac49f372f4c3d3d12f4d0d58ab0473a86821d5 (diff) | |
Faster replay ram clear by not free'ing the data immediately
| -rw-r--r-- | src/replay_buffer/replay_buffer_ram.c | 12 |
1 files 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; } |
