summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-rw-r--r--internal/flamegraph/livetrie_test.go17
-rw-r--r--internal/ior.go2
2 files changed, 19 insertions, 0 deletions
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{
diff --git a/internal/ior.go b/internal/ior.go
index ad46feb..668dda1 100644
--- a/internal/ior.go
+++ b/internal/ior.go
@@ -211,6 +211,8 @@ func tuiTraceStarterFromRunTrace(
engine.Ingest(ep)
streamEvents <- eventstream.NewStreamEvent(ep.EnterEv.GetTime(), ep)
liveTrie.Ingest(ep)
+ // Both downstream consumers snapshot the pair synchronously, so
+ // the pooled pair can be recycled immediately afterwards.
ep.Recycle()
}
el.warningCb = func(message string) {