Bug 1740597 - Tweak GeckoProfiler.CPUUsage gtest expectations of zero/non-zero values - r=canaltinova

The expectation of 50% idle stacks was too optimistic, since we cannot control how the OS interacts with idle threads and may still had CPU time to them unexpectedly.
The patch now only expects at least one zero and at least one non-zero.

Having non-zero values should be guaranteed by the work necessary to go around the loop.
Having zero values is still hopeful, in practice we've seen a minimum of 7 out of 20 zeroes, so expecting only one should be much easier to achieve consistently. But in the worst case it could still theoretically fail; If that happens we may need to tweak again, by increasing the loop count, and/or running the whole test a few times.

Differential Revision: https://phabricator.services.mozilla.com/D131099
This commit is contained in:
Gerald Squelart 2021-11-15 22:34:45 +00:00
Родитель 1250cf6b06
Коммит 1ed87e9a36
1 изменённых файлов: 12 добавлений и 6 удалений

Просмотреть файл

@ -4294,15 +4294,21 @@ TEST(GeckoProfiler, CPUUsage)
// at least "small"? (Whatever that means for cycles.) // at least "small"? (Whatever that means for cycles.)
if (testWithNoStackSampling) { if (testWithNoStackSampling) {
// Note: This test is a bit hand-wavy, and may not be reliable. If // Note: This test is a bit hand-wavy, and may not be reliable. If
// intermittents happen, it may need tweaking. // intermittents happen, it may need tweaking (by increasing the
EXPECT_GT(threadCPUDeltaZeroCount, threadCPUDeltaNonZeroCount) // loop count, or re-trying the whole test).
<< "There should be more zero-CPUs than non-zero"; EXPECT_GT(threadCPUDeltaZeroCount, 0u)
<< "There should be some zero-CPUs due to the idle loop body";
EXPECT_GT(threadCPUDeltaNonZeroCount, 0u)
<< "There should be some non-zero due to inter-loop work";
} }
# else # else
// Note: This test is a bit hand-wavy, and may not be reliable. If // Note: This test is a bit hand-wavy, and may not be reliable. If
// intermittents happen, it may need tweaking. // intermittents happen, it may need tweaking (by increasing the
EXPECT_GT(threadCPUDeltaZeroCount, threadCPUDeltaNonZeroCount) // loop count, or re-trying the whole test).
<< "There should be more zero-CPUs than non-zero"; EXPECT_GT(threadCPUDeltaZeroCount, 0u)
<< "There should be some zero-CPUs due to the idle loop body";
EXPECT_GT(threadCPUDeltaNonZeroCount, 0u)
<< "There should be some non-zero due to inter-loop work";
# endif # endif
# else # else
// All "threadCPUDelta" data should be absent or null on unsupported // All "threadCPUDelta" data should be absent or null on unsupported