Repository navigation
perf(linux): the status parser finds each line's end with memchr, not a byte loop (#2980) - #3020
Merged
Merged
Conversation
… a byte loop (#2980) The scan was about a tenth of the sampler's user-space CPU over many processes. Same machine, same benchmark build, 10 repetitions of 0.5 s: BM_ProcessProbe_EnumerateSynthetic/5000 70.3 -> 65.3 ms median (CV 4.6% -> 1.6%), ...SyntheticRebuild/5000 104 -> 98.2 ms (CV 2.8% -> 1.2%). The early exit, the bounds and the truncated-line handling are as before. Fixes #2980 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
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.
Description
Fixes #2980
LinuxProcessProbe's status parser (applyStatus()) found each line's end with a byte-at-a-time loop on every process, every sample. The issue's profile put that at about a tenth of the sampler's user-space CPU over many processes. It now usesstd::memchr. Everything else stays as it was: the early exit once every field is found, the bounds, the whole-line rule for VmHWM, RssAnon, VmSwap and Cpus_allowed_list, numeric overflow checks, effective/real UID, and variable-width affinity. Every metric is still sampled at the Settings interval.Measured on the same machine (WSL Ubuntu 26.04, 10 CPUs), the same
benchmark-preset build, before and after the change, 10 repetitions of 0.5 s:BM_ProcessProbe_EnumerateSynthetic/5000BM_ProcessProbe_EnumerateSyntheticRebuild/5000As the issue notes, these fixtures model
/procwith ordinary files on WSL2. The relative gain is the result here, not an absolute native-/procbudget, and parsing is one contributor to the 5,000-process cost, not all of it.PR Size
✅ Small (5 lines).
Type of Change
Checklist
clang-tidyand addressed any warningsclang-formaton my changesTesting
The probe's existing tests cover the status parser's truncated lines, the cut-off affinity lists, VmHWM past the stack buffer and the UID cases. Full suite: 683/683.
Additional Notes
Performance PR: it merges only after Heavy Checks, including
benchmark-regression, passes on its head.🤖 Generated with Claude Code