{"_id":"physical-cpu-count","_rev":"292795","name":"physical-cpu-count","description":"Provides the number of physical cores","dist-tags":{"latest":"2.0.0"},"maintainers":[{"name":"seb","email":""}],"time":{"modified":"2021-06-03T18:53:22.000Z","created":"2016-12-05T15:05:55.213Z","2.0.0":"2016-12-07T06:32:51.627Z","1.0.0":"2016-12-05T15:05:55.213Z"},"users":{"shyling":true},"author":{"name":"Sebastiaan Deckers","email":"sebdeckers83@gmail.com"},"versions":{"2.0.0":{"name":"physical-cpu-count","version":"2.0.0","description":"Provides the number of physical cores","main":"index.js","scripts":{"test":"snazzy && node test.js"},"keywords":["os","cpu","cpus","length","physical","logical","cores"],"author":{"name":"Sebastiaan Deckers","email":"sebdeckers83@gmail.com"},"license":"ISC","devDependencies":{"snazzy":"^5.0.0"},"gitHead":"ae8966c1793a6b8674580c6fab6fc75eca876c60","_id":"physical-cpu-count@2.0.0","_shasum":"18de2f97e4bf7a9551ad7511942b5496f7aba660","_from":".","_npmVersion":"3.10.9","_nodeVersion":"7.2.0","_npmUser":{"name":"seb","email":"sebdeckers83@gmail.com"},"dist":{"shasum":"18de2f97e4bf7a9551ad7511942b5496f7aba660","size":1773,"noattachment":false,"key":"/physical-cpu-count/-/physical-cpu-count-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/physical-cpu-count/download/physical-cpu-count-2.0.0.tgz"},"maintainers":[{"name":"seb","email":""}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/physical-cpu-count-2.0.0.tgz_1481092369666_0.0765470527112484"},"directories":{},"publish_time":1481092371627,"_cnpm_publish_time":1481092371627,"_hasShrinkwrap":false},"1.0.0":{"name":"physical-cpu-count","version":"1.0.0","description":"Provides the number of physical cores","main":"index.js","scripts":{"test":"snazzy && node test.js"},"keywords":["os","cpu","cpus","length","physical","logical","cores"],"author":{"name":"Sebastiaan Deckers","email":"sebdeckers83@gmail.com"},"license":"ISC","devDependencies":{"snazzy":"^5.0.0"},"gitHead":"8a4d2234d5a23b152166890c0b17b3cb593bfcd5","_id":"physical-cpu-count@1.0.0","_shasum":"302966a7b1fb23f07dcea6a04492d807dc474a57","_from":".","_npmVersion":"2.15.11","_nodeVersion":"4.6.2","_npmUser":{"name":"seb","email":"sebdeckers83@gmail.com"},"dist":{"shasum":"302966a7b1fb23f07dcea6a04492d807dc474a57","size":1354,"noattachment":false,"key":"/physical-cpu-count/-/physical-cpu-count-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/physical-cpu-count/download/physical-cpu-count-1.0.0.tgz"},"maintainers":[{"name":"seb","email":""}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/physical-cpu-count-1.0.0.tgz_1480950354979_0.8576818211004138"},"directories":{},"publish_time":1480950355213,"_cnpm_publish_time":1480950355213,"_hasShrinkwrap":false}},"readme":"# physical-cpu-count\n\nReturns the number of physical CPU cores.\n\n## Example\n\n```js\nconst physicalCpuCount = require('physical-cpu-count')\n// 4\n\nconst logicalCpuCount = require('os').cpus().length\n// 8\n```\n\n## Use Case\n\nWorking with clusters of Node.js processes it is common to see code using `os.cpus().length` as the number of child workers to fork. For some workloads this can negatively impact performance on CPUs that use simultaneous multithreading (SMT). Latency is doubled because two processes share the same physical CPU core to get their work done. Additionally there is memory spent for each running worker, as well as time to spawn their processes. It is better to fork no more child processes than there are physical cores.\n\n## Known Limitations\n\nImplemented for Linux, macOS, and Windows.\n\nOther platforms use a naive approach that only looks at Intel CPUs, and assumes every Intel CPU supports, and has enabled, Hyper-Threading with two threads per physical core. These assumptions are not always correct.\n\nPower management might also make CPU cores unavailable.\n\n## See also:\n\n- [Issue `nodejs/node#7730` to implement physical core detection natively in Node.js.](https://github.com/nodejs/node/issues/7730)\n- [Relevant Stack Overflow answer for macOS and Linux.](https://stackoverflow.com/a/23378780)\n- [Solutions for Windows WMIC from the command prompt.](http://superuser.com/questions/226552/how-to-tell-how-many-cpus-cores-you-have-on-windows-7)\n","_attachments":{},"license":"ISC"}