feat: add bounded CPU profiling - #182
Merged
Merged
Conversation
# Conflicts: # cmd/beacon/main.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.mddescribes 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
Checklist
go build ./...passesgofmt -l .is emptygo vet ./...passesgo test ./...passes with local PostgreSQL enabledTesting notes
Race checks passed for profiling, background tasks and Beacon startup. Linux and Windows builds passed; unsupported profiling platforms return an explicit configuration error.
govulncheckfound 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.