summaryrefslogtreecommitdiff
path: root/internal/ior_parquet_sink.go
AgeCommit message (Collapse)Author
2026-05-19t6 stabilize family recording integrationPaul Buetow
2026-05-13refactor: break down functions exceeding 50 lines into smaller helpersPaul Buetow
Split 22 production files across the codebase — event loop, TUI models, probe manager, dashboard, export, flag parsing, code generation, and ioworkload scenarios — so that no function body exceeds 50 lines. Each extracted helper carries its own comment explaining its role. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-13fix: stop BPF ring-buffer polling goroutine on trace end to prevent leakPaul Buetow
setupEventChannel now returns the *bpf.RingBuffer handle alongside the event channel. Both callers (runTraceWithContext, runHeadlessParquet) defer rb.Stop() so the libbpfgo polling goroutine and C ring_buffer struct are released promptly when the trace context is cancelled, rather than waiting for bpfModule.Close() to eventually call rb.Close(). rb.Stop() and rb.Close() are both idempotent, so the double-call from the defer and from bpfModule.Close() is safe. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-13fix: log swallowed defer mgr.Close errors for BPF resourcesPaul Buetow
Wrap the bare `defer mgr.Close()` calls in runTraceWithContext (ior.go) and runHeadlessParquet (ior_parquet_sink.go) in a closure that checks the returned error and logs it via logln, so BPF probe-detach failures and map-cleanup errors are no longer silently discarded. bpfModule.Close() has no return value and is unchanged. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-13replace package-level test doubles in ior.go with constructor injection (DIP)Paul Buetow
Introduce runnerDeps struct to bundle all injectable function dependencies (getEUID, runTrace, runParquet, runTraceWithContext, runTUI*) that were previously package-level vars overridden in tests. The modeRegistry now carries a runnerDeps instance and passes it to each handler's run() method, eliminating global state mutation in tests. - Add runnerDeps struct and defaultRunnerDeps() constructor in ior_mode_registry.go - Convert modeRegistry from a []modeHandler slice type to a struct with handlers + deps fields; add newModeRegistry(deps) constructor - Update modeHandler.run() signature to accept runnerDeps; handlers call deps.getEUID / deps.runTrace etc. instead of globals - Update SetTUIRunners to write into defaultRegistry.deps instead of package-level vars - Add dispatchRunWithDeps helper for test isolation without global mutation - Remove root-privilege check from runTraceWithContext and runHeadlessParquet; each mode handler owns the EUID gate via deps.getEUID - Rewrite ior_mode_test.go: replace save/restore patterns with stubDeps() helper and dispatchRunWithDeps; add three new root-privilege tests replacing the removed TestRunTraceWithContextRequiresRoot Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-24fix task 38: plug profiling fd leak on setup failure pathsPaul Buetow
runTraceWithContext and runHeadlessParquet opened cpu/mem/exec-trace profile files via setupProfiling, then relied on the shutdown watcher goroutine (registered later) to close them. If any intervening step (newEventLoop, recorder.Start) returned an error, the watcher was never registered and the profile fds leaked until process exit. Add a defer profiling.stop(logln) immediately after setupProfiling so the fds are released on every return path. profiling.stop is idempotent via sync.Once so the watcher and defer can both run harmlessly. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-03-18refactor: split ior.go mega-file into focused files (task 427)Paul Buetow
ior.go had 763 lines covering 9+ concerns. Follow the eventloop_*.go pattern and extract into three focused files: - ior_bpfsetup.go: libbpfTracepoint{Program,Module} adapter types, setupBPFModule, setupBPFModuleError, setupEventChannel - ior_profiling.go: profilingControl type, setupProfiling, profilingFilesForMode, stop() - ior_parquet_sink.go: headlessParquetSink type, runHeadlessParquet, isHeadlessParquetMode, hasHeadlessParquetContentFilters, headlessParquetTraceConfig; inline parquetMetadata one-liner ior.go shrinks from 763 → 453 lines, retaining entry, dispatch, TUI wiring, and core trace execution. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>