You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I compared this against the Charon Go source (charon/app/stacksnipe/stacksnipe.go). This is a clean, faithful, and well-documented port. Tests actually exceed the Go coverage. A few notes below — nothing blocking.
NUL-split cmdline → drop empties → join with spaces, comm trimming, dedup-by-raw-cmdline, and substring-based name derivation (from cmdline, not comm) all match the Go logic.
The tracing topic (topic = "stacksnipe") mirrors Go's log.WithTopic. ✔
👍 Good Rust-specific choices
First-tick skip (stacksnipe.rs:108-111): tokio::time::interval fires immediately on the first tick, whereas Go's time.NewTicker waits one full interval. Skipping the first tick correctly preserves Go's timing, and the comment explains why. Nice catch.
spawn_blocking (stacksnipe.rs:118): the blocking /proc filesystem walk is correctly moved off the async runtime — better than Go's plain goroutine.
Making snipe infallible is justified: Go's snipe returns an error, but walkFunc swallows every error and returns nil, so walkErr is effectively never set. filter_map(Result::ok) is the faithful, simpler equivalent.
🟡 Behavioral note — name selection determinism
vc_name (stacksnipe.rs:219-225) returns the first match in SUPPORTED_VCS order via .find(). The Go version iterates a map without break, keeping the last match in non-deterministic iteration order:
forvc:=rangesupportedVCs {
ifstrings.Contains(cmdlineString, vc) {
vcName=vc// no break → keeps last, map order is random
}
}
So when a single cmdline contains two supported VC names, Go could report either one (run-to-run), while Rust deterministically reports the first by array order. The Rust behavior is strictly better, but it is a deviation from Go and name_multi_match_deterministic_first bakes it in — worth a one-line comment noting this is an intentional improvement over Go's non-determinism.
🟡 Minor: token vec built before dedup check
In snipe, cli_tokens is allocated at stacksnipe.rs:187before the dedup check at line 196. Go builds its cmdLine slice after the dedup check, so duplicate cmdlines (e.g. background threads) avoid the per-token String allocations. Reordering — dedup-insert first, then build cli_tokens — would match Go and skip wasted work for duplicates. Purely a micro-optimization. Fix this →
ℹ️ Scope: not yet wired into app startup
Charon wires the sniper into the node lifecycle at app/app.go:170 (stacksnipe.New(conf.ProcDirectory, stackComponents)), where stackComponents writes the Prometheus metric (monitoringapi.go:324). This PR adds the module only — there's no caller of Instance::run and no MetricsFn bridged to a metric. Assuming wiring + the metric are a deliberate follow-up; flagging so it isn't lost.
Tests
Test coverage is thorough and goes beyond Go's single happy-path test (exact-comm-match, name-from-cmdline, dedup, NUL handling, comm newline trim, non-PID dirs, disabled path, nonexistent path). I was unable to execute cargo test in this environment (command not permitted), so please confirm CI is green.
Verdict: Looks good to merge once CI passes. The two 🟡 items are optional polish; the wiring is presumably a follow-up.
· feat/stacksnipe
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
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.
fix #71