Open zerosnacks opened 2 days ago
impl looks good! there's a regression re the way rayon thread pool is spawned though, a command like
Thanks, good catch!
I think we should keep the current behavior, that is if
--jobs
flag not passed then we use rayon default (the number of CPUs available) instead single thread.
I had implemented it this way to avoid spawning the global thread pool as the vast majority of commands are not multi-threaded, cc @DaniPopes should we spawn by default?
wonder how (if) this would also affect the threadpools spawned in deps (and if we want to or not) like compilers
wonder how (if) this would also affect the threadpools spawned in deps (and if we want to or not) like compilers
Good point, whenever Rayon is first accessed it will spawn a global thread pool with default settings (unless configured).
Right now it will attempt to spawn for a thread for each job here:
I'm not sure what we are optimizing for - not running with the default settings of available logical CPUs? It seems desirable, unless specifically required to be limited. A possible motivation would be to pay the cost of spawning upfront.
cc @DaniPopes
Motivation
Closes: https://github.com/foundry-rs/foundry/issues/8408
Solution
--jobs
flag. If not passed it is not spawned. If passed as--jobs 0
it will use the default Rayon configuration (number of logical CPUs).ShellOpts
toGlobalOpts
.GlobalOpts
where required, this can be the case when wanting to indicate aconflicts_with
a global argument or you need access to the thread pool. In most cases when checking against the shell configuration it is probably easier to use the e.g.shell::is_json
variant over passing it all the way down.