Repository navigation
fix: no benchmark warning when a process exits before it can be sampled - #4260
Conversation
A job that finishes faster than the benchmark interval leaves the monitor with no sample, so BenchmarkRecord.data_collected stays False and get_benchmarks logs "Benchmark: unable to collect cpu and memory benchmark statistics: process no longer exists (pid=...)" at warning level. This is benign — the process simply completed too quickly to measure — but at scale it floods the log with warnings about healthy fast jobs. Track that case (process_gone) separately from real collection errors: a psutil.NoSuchProcess during sampling now sets the flag instead of being recorded as an error, and get_benchmarks emits it at debug level. Genuine collection failures (permission errors, too many open files) still warn.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughBenchmark records now distinguish early process termination from collection errors. Sampling handles vanished main and child processes separately, while serialization adjusts missing-statistics logging. Tests cover benign disappearance, partial sampling, and actual collection failures. ChangesBenchmark process disappearance handling
Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/snakemake/benchmark.py`:
- Around line 402-405: Update the process sampling logic surrounding the
NoSuchProcess handler so process_gone is set only when self.main disappears
before the first usable sample. Treat vanished child processes as skippable,
continue sampling the remaining process tree, and preserve any partial sample
and warning behavior when the benchmarked main process remains alive.
In `@tests/test_benchmark_process_gone.py`:
- Around line 39-69: Strengthen the tests around get_benchmarks(): in
test_get_benchmarks_does_not_warn_when_only_reason_is_process_gone, assert
logger.debug received the expected process-disappearance message rather than
merely being called. In
test_get_benchmarks_still_warns_on_real_collection_error, set process_gone=True
while retaining the real error and continue asserting that logger.warning is
called.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 5c643788-cd6a-453d-a1b1-d15dac4c25d9
📒 Files selected for processing (2)
src/snakemake/benchmark.pytests/test_benchmark_process_gone.py
…n process A vanished child raised NoSuchProcess out of the whole-tree try block, discarding the tick's partial sample and setting process_gone while the benchmarked process was still alive. The likeliest escape path was the memory-info skip handler itself: proc.name() on the vanished child. Each process now samples under its own handler: a child exiting between enumeration and sampling is skipped and the partial sample kept (peaks no longer bias low for fork-heavy jobs); process_gone is set only when the observed main process is the one that disappeared.
|
Thanks a lot! |
🤖 I have created a release *beep* *boop* --- ## [9.24.0](v9.23.1...v9.24.0) (2026-07-30) ### Features * allow to combine cases with otherwise in branch function ([#4262](#4262)) ([000ff52](000ff52)) ### Bug Fixes * avoid config hash crash for non-serializable values ([#4241](#4241)) ([1a27746](1a27746)) * compilation error when final line contains an f-string ([#4234](#4234)) ([9c5e7fe](9c5e7fe)) * Group error log formatting ([#4256](#4256)) ([bb6dcde](bb6dcde)) * leak of benchmark monitor threads ([#4259](#4259)) ([d37852e](d37852e)) * no benchmark warning when a process exits before it can be sampled ([#4260](#4260)) ([6738359](6738359)) * persistence starttime unset/defaults ([#4251](#4251)) ([56395c0](56395c0)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
A job that finishes faster than the benchmark interval leaves the monitor with no sample, so
BenchmarkRecord.data_collectedstaysFalseandget_benchmarkslogs at warning level:This is benign — the process simply completed too quickly to measure — but at scale it floods the log with warnings about healthy fast jobs.
Track that case (
process_gone) separately from real collection errors: apsutil.NoSuchProcessduring sampling now sets the flag instead of being recorded as an error, andget_benchmarksemits it at debug level. Genuine collection failures (permission errors, too many open files) still warn.QC
docs/) is updated to reflect the changes or this is not necessary (e.g. if the change does neither modify the language nor the behavior or functionalities of Snakemake).AI-assistance disclosure
I used AI assistance for:
Summary by CodeRabbit