-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nproc: replace num_cpus crate with thread::available_parallelism #4352
nproc: replace num_cpus crate with thread::available_parallelism #4352
Conversation
Looks good |
From what i have read here thread::available_parallelism a error will, but it's not limited to, return in the following cases:
I'm not sure if at any point we will reach those scenarios, but I'm doing a research to see others pitfall we may find. |
I think GNU nproc just returns 1 processor if all methods fail: https://github.com/coreutils/gnulib/blob/f2b8ad906cbc861552a64e3804e5851c323cbac7/lib/nproc.c#L339 Not sure I agree with that, but that's probably what we should do for compatibility. |
one of the great thing about Rust. it forces us to have conversations about the right error handling :) |
So for compatibility reasons it's better to return 1 in case it falls in an error? If we agree with that I will do the changes. |
Yes I think so, but let's also include a comment on the GNU behaviour for context. |
GNU testsuite comparison:
|
GNU testsuite comparison:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Just one more nit
GNU testsuite comparison:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All good now! Thanks! For future PRs, could you squash the commits a bit more? I squashed them all while merging now.
Of course, I'll pay more attention in the next PRs and sorry for the inconvenience. |
not a big deal :) it is just best practice :) |
Closes #4351