Skip to content

feat: add bounded CPU profiling - #182

Merged
MrAlders0n merged 3 commits into
devfrom
feat/bounded-cpu-profiling
Sep 30, 2026
Merged

MrAlders0n merged 3 commits into
devfrom
feat/bounded-cpu-profiling

Conversation

@MrAlders0n

Copy link
Copy Markdown
Member

What this PR does

Production CPU hotspots cannot currently be inspected without a custom build. Add opt-in CPU samples written to a private directory, with no HTTP profiling endpoint.

Capture for 30 seconds every 30 minutes, with additional route-maintenance requests and a five-minute cooldown. A fixed deadline within 72 hours survives restarts. File and directory budgets stop collection before it grows without bound. Shutdown finalizes an active profile; recorder failures leave ingest running.

Profiles include UTC timestamps, process CPU and pool counters. Background task labels distinguish maintenance work. PROFILING.md describes a short pilot before a longer session and correlation with separate host/database diagnostics. Profiling is disabled by default and supported on Linux/macOS.

Type of change

  • New feature
  • Tests
  • Docs / config

Checklist

  • go build ./... passes
  • gofmt -l . is empty
  • go vet ./... passes
  • go test ./... passes with local PostgreSQL enabled
  • Tests cover scheduling, expiry, permissions, disk bounds, active cancellation and task behavior
  • No schema, API, Swagger or dependency changes
  • I have read CONTRIBUTING.md

Testing notes

Race checks passed for profiling, background tasks and Beacon startup. Linux and Windows builds passed; unsupported profiling platforms return an explicit configuration error. govulncheck found no reachable vulnerabilities.

A local 45,000-message replay with profiling enabled and the matching disabled run both stored 5,000/5,000 observations and delivered 15,000/15,000 live hearings, with zero drops, ingest errors, reconnects or lag notices. The enabled run produced a readable 30-second profile and pool metadata. Beacon CPU was 8.35 seconds enabled versus 8.10 disabled in this single pair; production overhead still needs the documented pilot.

No production deployment or capture session has been started.

@MrAlders0n
MrAlders0n requested a review from 446564 as a code owner September 29, 2026 12:53
@MrAlders0n
MrAlders0n requested review from n30nex and removed request for 446564 September 30, 2026 11:49
@MrAlders0n
MrAlders0n merged commit 5cf0601 into dev Sep 30, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant