Skip to content

perf(detection): charge the scan budget per pass and cut monitor overhead - #113

Merged
rennf93 merged 2 commits into
masterfrom
perf/detection-cpu
Oct 16, 2026
Merged

rennf93 merged 2 commits into
masterfrom
perf/detection-cpu

Conversation

@rennf93

@rennf93 rennf93 commented Oct 16, 2026

Copy link
Copy Markdown
Member

Closes #112

Port of the reference fix in Guard-Core/guard-core#173. timeExhausted now reads only the monotonic clock per pattern and charges the CPU clock at 2 ms slice boundaries (the slice lives on the request budget, so it spans passes), with the final charge when the pass closes, so the budget lag is at most one slice plus one pattern. The performance monitor skips the sanitized anomaly copy when no callback is registered. Tests cover the clock reads per pass and a long pass stopping within one slice of the budget; coverage stays covered-or-waived 100% with no new waivers. On a ~1 KB JSON-like value plus 10 short header values detection went from 5.60 ms to 5.43 ms of CPU.

…attern

The per-request scan time budget read the thread CPU clock around every pattern. It now charges per pass: one read when a pass opens, one at each 2 ms wall-clock slice boundary and one when the pass closes. The per-pattern check reads only a cheap monotonic clock and compares the charged total, so the budget lags the true spend by at most one slice plus one pattern.
@github-actions github-actions Bot added area: engine Touches guardcore/ (engine package) tests Test suite changes labels Oct 16, 2026
@rennf93
rennf93 merged commit c199bf1 into master Oct 16, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: engine Touches guardcore/ (engine package) tests Test suite changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Scan time budget reads the CPU clock on every pattern check

1 participant