perf: avoid sysinfo System::new_all() when only one metric is needed#46
Merged
ShixiangWang merged 1 commit intoJun 22, 2026
Merged
Conversation
andrewbudge
marked this pull request as draft
June 17, 2026 18:38
Found via the criterion suite: parse/10_simple and parse/1000_simple both cost a flat ~50ms, while the DAG engine builds 10,000 rules in 3ms. A fixed cost independent of workload size pointed at WorkflowConfig::validate(), which called sysinfo::System::new_all() — walking all of /proc (every process, disk, and NIC) — just to read total system memory. Probe only RAM with System::new() + refresh_memory(). total_memory() still returns bytes in sysinfo 0.38, so behavior is unchanged. Same fix applied to executor::available_memory_gb, available_threads (now num_cpus::get()), and process::detect_total_memory_mb. parse/10_simple: 50ms -> 39us. All 890 lib tests pass; fmt + clippy clean.
andrewbudge
force-pushed
the
perf/avoid-sysinfo-new-all
branch
from
June 17, 2026 18:40
d315337 to
ef9d802
Compare
andrewbudge
marked this pull request as ready for review
June 17, 2026 18:45
Member
|
@andrewbudge Great! thanks for the improvement and contribution. |
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.
What
WorkflowConfig::validate()calledsysinfo::System::new_all()— which walks all of/proc(every process, disk, and network interface) — just to read total system memory. That added a fixed ~50 ms to everyparse/validate/dry-run/run.Fix: probe only memory with
System::new()+refresh_memory(). Behavior is identical —total_memory()still returns bytes in sysinfo 0.38, so the/1024/1024math and the emitted warnings are unchanged. The same pattern is fixed inexecutor::available_memory_gb,available_threads(nownum_cpus::get()), andprocess::detect_total_memory_mb.How I found it
Running the existing criterion suite,
parse/10_simpleandparse/1000_simpleboth clocked ~50 ms — flat, regardless of rule count — whiledag/chain_10000built 10,000 rules in 3 ms. A fixed cost that didn't scale with the workload pointed straight at the per-callnew_all().Result
parse/10_simpleparse/1000_simplelifecycle/10_simpleParsing now scales with rule count instead of being pinned at ~50 ms.
cargo fmt --check+cargo clippy --workspace -D warningsclean;cargo test --workspace --lib→ 890 passed.