What is the "heuristics" for the default number of threads? #2968
Replies: 1 comment 1 reply
-
See #2854 and #2856 as related issues.
I suppose I'm fine with this as long as it's made clear that the specific heuristics may change. PRs are welcome.
I'm not really inclined to do this. ripgrep is very spartan in terms of what environment variables it supports. And I don't really think it's ripgrep's responsibility to control resource usage beyond what the user invoking |
Beta Was this translation helpful? Give feedback.
-
The man page says:
I've been trying to find more information on what the "heuristics" behind this default is, but I failed. Is it documented anywhere?
I found:
ripgrep/crates/core/flags/hiargs.rs
Line 172 in 71d71d2
which suggests that
--threads
defaults the number of CPU cores on the host, but at most 12. Is that the case?Wishes
Document the default more precisely. It'll help users and sysadms.
Make it possible to control the default maximum number of threads via an environment variable (e.g.
RIPGREP_DEFAULT_MAX_THREADS
), so that sysadms can limit it on shared multi-tenant systems.Background
We discovered a single
rg
process running wild on our UCSF Wynton HPC system (1,400 users), where it consumed tons of CPU (definitely more than 12) and lots of memory. The system was so sluggish (>500 cores worth of load on a 48-core host) that we struggled to troubleshoot, so we don't have the exact details, but as soon as we terminated this singlerg
process, everything went back to normal. FWIW, we think thisrg
process was launched via a remote VS Code session, but not 100% sure).Beta Was this translation helpful? Give feedback.
All reactions