Commit 1135665f authored by Jesse McKenna's avatar Jesse McKenna Committed by Commit Bot

Fix CPU count in unit tests when >64 CPUs

On Windows systems with > 64 logical processors, the processor count
returned by base::SysInfo::NumberOfProcessors() is below the actual
count. This is because Windows splits logical processors on systems
with more than 64 into Processor Groups, and an accurate count of
system processors requires using newer Windows API call
::GetActiveProcessorCount(ALL_GROUPS), which counts processors across
all groups.

For most code in Chrome, using more than one processor group's
processors is likely overkill (and requires additional code to assign
each thread to a processor group), so this change does not modify the
existing base::SysInfo::NumberOfProcessors() - it will still reflect
the number of processors in the calling process's group.

Instead, this change modifies the test launcher itself, as that is the
only currently known use case for running on more than one processor
group's processors.

On the 72-core P920 (which has two groups containing 36 CPUs each),
when running base_unittests.exe, this change has the following effect:

Before:
C:\src\chromium\src>out\Default\base_unittests.exe
[...]
Using 36 parallel jobs.

After:
C:\src\chromium\src>out\Default\base_unittests.exe
[...]
Using 72 parallel jobs.

Bug: 983014
Change-Id: Ie7a828b4fba9f2e8e7f220738af58d5de8e17816
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1704388Reviewed-by: default avatarErik Chen <erikchen@chromium.org>
Commit-Queue: Jesse McKenna <jessemckenna@google.com>
Cr-Commit-Position: refs/heads/master@{#696927}
parent 372615c3
......@@ -1752,6 +1752,12 @@ size_t NumParallelJobs() {
}
// Default to the number of processor cores.
#if defined(OS_WIN)
// Use processors in all groups (Windows splits more than 64 logical
// processors into groups).
return base::checked_cast<size_t>(
::GetActiveProcessorCount(ALL_PROCESSOR_GROUPS));
#endif
return base::checked_cast<size_t>(SysInfo::NumberOfProcessors());
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment