From b4935194b7cdbb9854d7716bd3ec70883358f03a Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Tue, 10 Mar 2026 19:08:42 +0200 Subject: task 433: lock in pair recycle safety --- internal/flamegraph/livetrie_test.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'internal/flamegraph') diff --git a/internal/flamegraph/livetrie_test.go b/internal/flamegraph/livetrie_test.go index 53bdf1f..5d4ce47 100644 --- a/internal/flamegraph/livetrie_test.go +++ b/internal/flamegraph/livetrie_test.go @@ -48,6 +48,23 @@ func TestLiveTrieIngestIsAdditive(t *testing.T) { } } +func TestLiveTrieIngestCopiesBeforeRecycle(t *testing.T) { + lt := NewLiveTrie([]string{"comm", "path"}, "count") + + pair := newTestPair("svc", 42, 1001, "/tmp/a", 1, 2, 3) + lt.Ingest(pair) + pair.Recycle() + + snap := decodeLiveSnapshot(t, lt) + leaf := findSnapshotPath(t, &snap, "svc", "/tmp", "/a") + if got, want := leaf.Value, uint64(1); got != want { + t.Fatalf("leaf value after recycle = %d, want %d", got, want) + } + if got, want := leaf.Total, uint64(1); got != want { + t.Fatalf("leaf total after recycle = %d, want %d", got, want) + } +} + func TestLiveTrieCommTracepointPathAggregatesSameSyscallAcrossPaths(t *testing.T) { lt := NewLiveTrie([]string{"comm", "tracepoint", "path"}, "count") lt.AddRecord(IterRecord{ -- cgit v1.2.3