From f12756eecf2ea791ad894cc63380ed78f22f8797 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 23 May 2026 20:16:15 +0300 Subject: 9c move Non-IO grouping policy from core stats/types into dashboard Snapshot.NonIOFamilies, Snapshot.NonIOFamiliesCount, and types.IsNonIOSyscallFamily encoded a TUI tab concept in core packages. Move this filtering into internal/tui/dashboard/nonio.go as unexported helpers so the dashboard owns its own grouping policy and Snapshot.Families remains the neutral core API. Co-Authored-By: Claude Opus 4.7 --- internal/statsengine/engine_test.go | 11 ++++++----- internal/statsengine/snapshot.go | 22 ---------------------- internal/statsengine/snapshot_test.go | 29 ----------------------------- 3 files changed, 6 insertions(+), 56 deletions(-) (limited to 'internal/statsengine') diff --git a/internal/statsengine/engine_test.go b/internal/statsengine/engine_test.go index 0500d20..6eb19e8 100644 --- a/internal/statsengine/engine_test.go +++ b/internal/statsengine/engine_test.go @@ -115,12 +115,13 @@ func TestEngineAggregatesSyscallFamilies(t *testing.T) { t.Fatalf("FS family = %+v, want count=1 bytes=4", families["FS"]) } - nonIO := familyRowsByName(snap.NonIOFamilies()) - if _, ok := nonIO["FS"]; ok { - t.Fatalf("NonIOFamilies should not include FS: %+v", nonIO["FS"]) + // Verify that non-FS families exist and FS is present in the full + // family list — Non-IO filtering has moved to the dashboard package. + if _, ok := families["Polling"]; !ok { + t.Fatalf("Families missing Polling row: %+v", families) } - if nonIO["Polling"].Count != 2 || nonIO["Process"].Count != 1 { - t.Fatalf("NonIOFamilies missing expected rows: %+v", nonIO) + if _, ok := families["Process"]; !ok { + t.Fatalf("Families missing Process row: %+v", families) } } diff --git a/internal/statsengine/snapshot.go b/internal/statsengine/snapshot.go index bec92fb..fa9c948 100644 --- a/internal/statsengine/snapshot.go +++ b/internal/statsengine/snapshot.go @@ -237,28 +237,6 @@ func (s Snapshot) FamiliesCount() int { return len(s.families) } -// NonIOFamilies returns family rows outside the file-system/fd-focused family. -func (s Snapshot) NonIOFamilies() []FamilySnapshot { - rows := make([]FamilySnapshot, 0, len(s.families)) - for _, row := range s.families { - if types.IsNonIOSyscallFamily(row.Family) { - rows = append(rows, row) - } - } - return rows -} - -// NonIOFamiliesCount returns number of non-FS syscall-family rows. -func (s Snapshot) NonIOFamiliesCount() int { - count := 0 - for _, row := range s.families { - if types.IsNonIOSyscallFamily(row.Family) { - count++ - } - } - return count -} - // TopNSyscalls returns at most n per-syscall rows in ranking order. // Callers must treat returned data as read-only. func (s Snapshot) TopNSyscalls(n int) []SyscallSnapshot { diff --git a/internal/statsengine/snapshot_test.go b/internal/statsengine/snapshot_test.go index 9b54409..d5cb7aa 100644 --- a/internal/statsengine/snapshot_test.go +++ b/internal/statsengine/snapshot_test.go @@ -124,35 +124,6 @@ func TestNilAccessorsRemainNil(t *testing.T) { } } -func TestSnapshotNonIOFamilies(t *testing.T) { - s := NewSnapshotWithFamilies( - nil, - nil, - nil, - nil, - []FamilySnapshot{ - {Family: types.FamilyFS, Name: "FS"}, - {Family: types.FamilyPolling, Name: "Polling"}, - {Family: types.FamilyProcess, Name: "Process"}, - }, - nil, - nil, - HistogramSnapshot{}, - HistogramSnapshot{}, - ) - - rows := s.NonIOFamilies() - if len(rows) != 2 { - t.Fatalf("NonIOFamilies len = %d, want 2", len(rows)) - } - if rows[0].Family == types.FamilyFS || rows[1].Family == types.FamilyFS { - t.Fatalf("NonIOFamilies included FS: %+v", rows) - } - if got := s.NonIOFamiliesCount(); got != 2 { - t.Fatalf("NonIOFamiliesCount = %d, want 2", got) - } -} - func TestTopNAccessors(t *testing.T) { s := NewSnapshot( nil, -- cgit v1.2.3