summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/trace/Ring.zig13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/trace/Ring.zig b/src/trace/Ring.zig
index 47b490b..b92ae61 100644
--- a/src/trace/Ring.zig
+++ b/src/trace/Ring.zig
@@ -112,7 +112,12 @@ fn futexWake(word: *const std.atomic.Value(u32)) void {
pub fn emit(r: *Ring, ev: Event, payload: []const u8) void {
const h = r.hdr;
const need = record_overhead + std.mem.alignForward(usize, payload.len, 8);
- std.debug.assert(need <= h.capacity);
+ // A record the ring could never hold is dropped, not waited for: the
+ // caller splits large payloads (a `mem_write` by address).
+ if (need > h.capacity) {
+ _ = h.dropped.fetchAdd(1, .monotonic);
+ return;
+ }
var at = h.head.load(.monotonic);
while (true) {
if (at + need - h.tail.load(.acquire) > h.capacity) {
@@ -240,6 +245,12 @@ test "a second mapping sees the first's events; a full lossy ring drops" {
for (0..100) |i| a.emit(.{ .kind = .step, .a = .{ i, 0, 0, 0, 0, 0 } }, "");
try std.testing.expectEqual(4096 / record_overhead, 100 - a.hdr.dropped.load(.monotonic));
try std.testing.expectEqual(@as(u64, 0), b.peek().?.ev.a[0]);
+ // One too large for the ring at all is dropped too, lossy or not.
+ a.hdr.lossy.store(0, .monotonic);
+ const dropped = a.hdr.dropped.load(.monotonic);
+ var big: [4096]u8 = undefined;
+ a.emit(.{ .kind = .mem_write }, &big);
+ try std.testing.expectEqual(dropped + 1, a.hdr.dropped.load(.monotonic));
}
test "producers on other threads, a stop and a resume" {