machine_class 3/4: log nprocs, not ncores
commit6c6d2c773d2581daf9d9d55c8afeadb30f9a52d0
authorLucian Wischik <ljw@fb.com>
Tue, 24 May 2022 18:49:08 +0000 (24 11:49 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Tue, 24 May 2022 18:49:08 +0000 (24 11:49 -0700)
tree3d832fe7067174fc633a04336956fc95d9e78f5c
parentd3d1177efdb4c54da86efc619ad755724ad8c7d2
machine_class 3/4: log nprocs, not ncores

Summary:
Imagine a machine with two cores each of them hyperthreaded. Unix will report this as 4 processors even though only two concurrent pieces of work can be done at the same time. In ServerMain we count nprocs, and simply assume without evidence that our machine is hyperthreaded, and divide nprocs by 2, and use that as the number of concurrent typecheck worker processes.

A little knowledge is a dangerous thing. In D32986569 (https://github.com/facebook/hhvm/commit/270f2b868c002e32c85dd91cd90fd4b8776a6d13) (Dec2021) I decided to be fancy and record the actual number of cores. What I learnt was that we are sometimes run on hyperthreaded machines (where /2 is a good thing) and sometimes on non-hyperthreaded machines (where /2 is needlessly throwing away perf). So I added code to report the number of cores based on /sys/cpuinfo.

That was a bad idea. If we had that "two hyperthreaded core" scenario and created a VM on it, it's quite common for the VM to be told via /sys/cpuinfo that it has four non-hyperthreaded cores. In other words, my attempt to record ncores was flawed.

This diff deletes the code. It simply reports nprocs. It's the best we can do. I changed the column name from "ncores" to "nprocs". I didn't want any confusion.

Reviewed By: nt591

Differential Revision: D36620523

fbshipit-source-id: 63fc1e06069832bd9b2d015b95bfdbfb7f74cab6
hphp/hack/src/utils/sys/sys_utils.ml
hphp/hack/src/utils/sys/sys_utils.mli
hphp/hack/test/unit/utils/sys_utils_test.ml