Skip to content

Conversation

l0rinc
Copy link
Contributor

@l0rinc l0rinc commented Aug 9, 2024

Split out of https://github.com/hebasto/bitcoin/pull/316/files#r1711537463

nproc is linux only, getconf _NPROCESSORS_ONLN is used in the Linux kernel for the same task (works on Mac as well): https://github.com/torvalds/linux/blob/master/tools/testing/selftests/rcutorture/bin/kvm-build.sh#L44

On linux:

# nproc
8
root@rescue ~ # getconf _NPROCESSORS_ONLN
8

Note that in the productivity doc the recommended core count is one less than before, seems simpler to me this way.

@DrahtBot
Copy link
Contributor

DrahtBot commented Aug 9, 2024

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage

For detailed information about the code coverage, see the test coverage report.

Reviews

See the guideline for information on the review process.
A summary of reviews will appear here.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #30712 (fuzz: Add missing fuzz targets to cmake build by maflcko)
  • #30454 (build: Introduce CMake-based build system by hebasto)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@l0rinc l0rinc changed the title Change nproc in docs to getconf _NPROCESSORS_ONLN doc: Change nproc in docs to getconf _NPROCESSORS_ONLN Aug 9, 2024
@DrahtBot DrahtBot added the Docs label Aug 9, 2024
Copy link
Contributor

@hodlinator hodlinator left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 6d7bf8e

Long-time devs state how MacOS is not a supported development platform, and this change does make things more verbose, so I'm curious to get their take. But I'm happy to see there is a way that works for both.

Verified that it does seem to be the right identifier to query by reading: https://www.gnu.org/software/libc/manual/html_node/Processor-Resources.html

You are not changing doc/fuzzing.md which was linked in #30619 (comment)?

nproc is linux only, getconf _NPROCESSORS_ONLN is used in the Linux kernel for the same task: https://github.com/torvalds/linux/blob/master/tools/testing/selftests/rcutorture/bin/kvm-build.sh#L44

Co-authored-by: Hodlinator <172445034+hodlinator@users.noreply.github.com>
@maflcko
Copy link
Member

maflcko commented Aug 14, 2024

nproc is linux only

I don't think this is true. I don't have a mac, but I fail to see why installing it won't work. Also, a bash alias similar to alias nproc="sysctl -n hw.logicalcpu" or alias nproc="getconf _NPROCESSORS_ONLN" should work as well.

No objection to changing this, but I think the claim that nproc is linux-only may not be true.

@l0rinc
Copy link
Contributor Author

l0rinc commented Aug 14, 2024

Thanks @maflcko, I would actually prefer mentioning nproc (+ alternatives) only once in the docs - will be easier after the cmake PR updates are merged.

@DrahtBot
Copy link
Contributor

🐙 This pull request conflicts with the target branch and needs rebase.

@l0rinc l0rinc closed this Aug 28, 2024
@laanwj
Copy link
Member

laanwj commented Aug 28, 2024

it is true that getconf _NPROCESSORS_ONLN works on macos out of the box, while nproc isn't installed by default, but the identifier is so ugly and hard to type i find it an questionable improvement documentation-wise

@l0rinc
Copy link
Contributor Author

l0rinc commented Aug 28, 2024

i find it an questionable improvement documentation-wise

Yeah, would require more thorough doc updates to clarify that - agree, not worth it

@l0rinc l0rinc deleted the paplorinc/nproc branch August 28, 2024 21:13
@maflcko
Copy link
Member

maflcko commented Sep 20, 2024

Just for reference, the change would be wrong anyway, because the two are used to return different values

$ podman run --cpuset-cpus=0-1 --rm ubuntu:noble nproc 
2
$ podman run --cpuset-cpus=0-1 --rm ubuntu:noble getconf _NPROCESSORS_ONLN
16

@l0rinc
Copy link
Contributor Author

l0rinc commented Sep 20, 2024

Yeah, I hated how verbose that was.
But did a search again and it seems coreutils adds nproc support, so pushed a PR adding that in the OSx docs: https://github.com/bitcoin/bitcoin/pull/30936/files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants