Repository navigation
perf(identity): bound per-connect procfs work in binary identity resolution - #5213
Merged
FrostGod merged 1 commit intoNov 6, 2026
Conversation
…lution Cut the procfs and hashing work openshell-binary-identity pays for every external connect, all of it synchronous on the sandbox broker thread while the workload's connect(2) stays blocked: - Cap /proc/<pid>/cmdline reads at 128 KiB so a long command line can no longer grow per-connect work without bound. Reading one byte past the cap keeps the truncation predicate exact, and the truncated tail drops its last argument so no partial fragment reaches cmdline_paths. - Deduplicate the collected cmdline paths with a hash set instead of a quadratic Vec scan, preserving the insertion order consumers compare. - Evict one digest-cache entry at capacity instead of clearing the whole cache, so a capacity crossing no longer forces a full-file rehash of every live executable. - Read /proc/<pid>/status once per ancestry hop instead of twice, so the NSpid check and the parent PID come from one kernel generation. - Hash executables with a 64 KiB buffer instead of 8 KiB; a same-run release-mode comparison over a page-cached 100 MiB file measures about 1.28x throughput (68.9 ms vs 88.2 ms per hash). Digests, fail-closed Option contracts, and cmdline_paths for untruncated command lines are unchanged; streaming digests stay byte-identical, pinned by an equivalence test against the one-shot facade hash. Closes ai-openshell#5182 Signed-off-by: Emilien Macchi <emacchi@redhat.com>
4 tasks
Contributor
|
/ok to test 9675864 |
Contributor
|
Please soften the release note: large uncached executables can still delay connections while being hashed; this change reduces that cost. |
Contributor
Author
done |
FrostGod
approved these changes
Nov 6, 2026
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.
Summary
Cut the procfs and hashing work
openshell-binary-identitydoes per external connect, all of it synchronous on the sandbox broker thread while the workload's connect(2) stays blocked.Related Issue
Closes #5182
Changes
/proc/<pid>/cmdlinereads at 128 KiB; one extra byte makes the truncation predicate exact, and the truncated tail drops its last argument so no partial fragment reachescmdline_pathsVec::containsscan, keeping the insertion order consumers compare/proc/<pid>/statusonce per ancestry hop instead of twiceRelease Notes
Binary identity resolution now bounds its per-connect procfs work: long command lines and digest-cache churn no longer add unbounded cost per mediated connect. Large uncached executables can still delay a connect while being hashed; this change reduces that cost.
Testing
Checks appropriate to the affected code and behavior pass
Unit tests added/updated (if applicable)
E2E tests added/updated (if applicable)
cargo test -p openshell-binary-identity: 20 tests, up from 5 (long-cmdline child fixture, cap boundary matrix, dedup order, eviction at capacity, status parser, streaming-vs-one-shot digest equivalence)cargo test -p openshell-sandbox network_broker,-p openshell-supervisor-network,-p openshell-sandbox-backendWorkspace clippy and rustfmt command sets, run directly (the mise tasks' lockfile check hits a local uv config conflict)
mise run e2e:podman:ciBuffer benchmark (same-run, release mode, page-cached 100 MiB file, 15 rounds): 64 KiB vs 8 KiB is about 1.28x throughput, 68.9 vs 88.2 ms per hash
Argv beyond the 128 KiB cap no longer appears in snapshot validation, OPA denial strings, or identity logs.
cmdline_pathsis diagnostic context and never authorizes (pinned by the supervisor-network spoofing tests), so this only limits forensic visibility of very long command lines.Checklist