These reviews are from cargo-vet. To add your review, set up cargo-vet and submit your URL to its registry.

The current version of num_cpus is 1.16.0.

cargo-vet does not verify reviewers' identity. You have to fully trust the source the audits are from.

safe-to-run

This crate can be compiled, run, and tested on a local workstation or in controlled automation without surprising consequences. More…

safe-to-deploy (implies safe-to-run)

This crate will not introduce a serious security vulnerability to production software exposed to untrusted input. More…

unknown

May have been packaged automatically without a review


These reviews are from Crev, a distributed system for code reviews. To add your review, set up cargo-crev.

The current version of num_cpus is 1.16.0.

1.13.0 (older version) Rating: Positive Thoroughness: Low Understanding: Low

by MaulingMonkey on 2020-09-07

Queries the OS for the number of CPU cores you have.

Pros:

  • You didn't have to write it.
  • Handles all that hideously platform specific nonsense for you.

Cons:

  • Lots of (necessary) unsafe
  • Linux cgroups support seems wildly overcomplicated.
  • Lies and lies and lies and lies. Not exactly this crate's fault - the system APIs are brittle and full of edge cases. Multi-processor architectures are full of edge cases.

Alternatives:

  • Just hardcode a reasonable number of threads for your workload! Spinning up threads for 64 CPU cores to all false-share a single cacheline because that's how many logical cores were detected isn't the right choice! And all your threads are probably blocked on I/O anyways!

Full Audit

1.12.0 (older version) Rating: Positive Thoroughness: Medium Understanding: Medium

by MaulingMonkey on 2020-09-07

Show review…

Queries the OS for the number of CPU cores you have.

Pros:

  • You didn't have to write it.
  • Handles all that hideously platform specific nonsense for you.

Cons:

  • Lots of (necessary) unsafe
  • Linux cgroups support seems wildly overcomplicated.
  • Lies and lies and lies and lies. Not exactly this crate's fault - the system APIs are brittle and full of edge cases. Multi-processor architectures are full of edge cases.

Alternatives:

  • Just hardcode a reasonable number of threads for your workload! Spinning up threads for 64 CPU cores to all false-share a single cacheline because that's how many logical cores were detected isn't the right choice! And all your threads are probably blocked on I/O anyways!

Full Audit

1.10.1 (older version) Rating: Positive Thoroughness: Medium Understanding: Medium

Approved without comment by dpc on 2019-07-03


Crates in the crates.io registry are tarball snapshots uploaded by crates' publishers. The registry is not using crates' git repositories. There is absolutely no guarantee that the repository URL declared by the crate belongs to the crate, or that the code in the repository is the code inside the published tarball. To review the actual code of the crate, it's best to use cargo crev open num_cpus. Alternatively, you can download the tarball of num_cpus v1.16.0 or view the source online.