querylog: the writer queue defaults to 1024 entries, and a live stream allocates its ring on subscribe instead of at boot

This commit is contained in:
2026-10-21 22:38:53 +02:00
parent 0cafd770c1
commit d951d03b7d
12 changed files with 234 additions and 129 deletions
+2 -2
View File
@@ -268,7 +268,7 @@ pub const Entry = struct {
/// The memory budget the queue is allowed to occupy. `Entry` travels by value,
/// so the composition root allocates `query_log_buffer_max` of them in full at
/// boot (`app.zig`) and the SSE hub embeds a ring of them per subscriber.
/// boot (`app.zig`), and each live SSE subscriber holds a ring of them.
const queue_budget_bytes = 64 * 1024 * 1024;
/// The ceiling `config/validate.zig` enforces on `logging.query_log_buffer_max`,
@@ -1335,7 +1335,7 @@ test "the entry queue's worst case stays inside its byte budget" {
// The shipped default has to be comfortably inside the budget, or the
// out-of-the-box configuration is the one that spends it. At the widths
// above it costs about 17 MiB, roughly a quarter of the ceiling.
// above it costs under 2 MiB.
const default_max: usize = (model.Logging{}).query_log_buffer_max;
try testing.expect(default_max <= query_log_buffer_max);
try testing.expect(default_max * @sizeOf(Entry) <= queue_budget_bytes / 2);