diff options
| author | Paul Buetow <paul@buetow.org> | 2026-05-12 23:18:18 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-05-12 23:18:18 +0300 |
| commit | d199899dc1460d9dd72c6fca343f0030d632a635 (patch) | |
| tree | d59a43f2c25727ca296b74c8ca5b7387b56e70c6 /internal | |
| parent | 119c679dd16d6a3c89b9d37665c44815956b6f82 (diff) | |
add DefaultTopN constant to statsengine and replace hard-coded 64 capacity values
Introduces statsengine.DefaultTopN = 64 as the canonical named constant for
the top-N capacity used when constructing an Engine. Removes the local
defaultEngineCapacity constant from runtime_builder.go and updates all
call sites to reference statsengine.DefaultTopN instead of bare 64.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/bench_pipeline_test.go | 2 | ||||
| -rw-r--r-- | internal/runtime_builder.go | 4 | ||||
| -rw-r--r-- | internal/statsengine/engine.go | 12 |
3 files changed, 13 insertions, 5 deletions
diff --git a/internal/bench_pipeline_test.go b/internal/bench_pipeline_test.go index 7967e3a..bb6404a 100644 --- a/internal/bench_pipeline_test.go +++ b/internal/bench_pipeline_test.go @@ -197,7 +197,7 @@ func benchmarkPipelineTUIParquet(b *testing.B, mix benchutil.EventMix, events, n el := mustNewEventLoop(b, eventLoopConfig{}) preseedBenchComms(el, numThreads) - engine := statsengine.NewEngine(64) + engine := statsengine.NewEngine(statsengine.DefaultTopN) streamBuf := streamrow.NewRingBuffer() streamSeq := streamrow.NewSequencer(0) liveTrie := flamegraph.NewLiveTrie([]string{"comm", "tracepoint", "path"}, "count") diff --git a/internal/runtime_builder.go b/internal/runtime_builder.go index bc1c228..17a69c6 100644 --- a/internal/runtime_builder.go +++ b/internal/runtime_builder.go @@ -7,8 +7,6 @@ import ( "ior/internal/streamrow" ) -const defaultEngineCapacity = 64 - // runtimeComponents holds the freshly allocated trace-session components // produced by RuntimeBuilder.Build. All fields are non-nil after a successful // build. The caller is responsible for wiring these into the runtime bindings @@ -41,7 +39,7 @@ func newRuntimeBuilder(cfg flags.Config) RuntimeBuilder { // concurrent trace sessions. func (b RuntimeBuilder) Build() runtimeComponents { return runtimeComponents{ - engine: statsengine.NewEngine(defaultEngineCapacity), + engine: statsengine.NewEngine(statsengine.DefaultTopN), streamBuf: streamrow.NewRingBuffer(), streamSeq: streamrow.NewSequencer(0), liveTrie: flamegraph.NewLiveTrie(b.cfg.CollapsedFields, b.cfg.CountField), diff --git a/internal/statsengine/engine.go b/internal/statsengine/engine.go index 6681c66..78dbe65 100644 --- a/internal/statsengine/engine.go +++ b/internal/statsengine/engine.go @@ -9,7 +9,17 @@ import ( "ior/internal/types" ) -const trendWindowSlots = 20 +const ( + // trendWindowSlots is the number of slots used for trend detection in ring + // time series. Two consecutive windows of this size are compared to detect + // rising, falling, or stable throughput/latency trends. + trendWindowSlots = 20 + + // DefaultTopN is the default maximum number of top entries tracked per + // category (files, processes). It is exported so callers can use it as the + // standard capacity when constructing a new Engine via NewEngine. + DefaultTopN = 64 +) // Engine aggregates streaming syscall data into immutable snapshots. type Engine struct { |
