Update spin-wait pause/yield normalization (#55295)
authorKoundinya Veluri <kouvel@users.noreply.github.com>
Tue, 13 Jul 2021 15:59:20 +0000 (08:59 -0700)
committerGitHub <noreply@github.com>
Tue, 13 Jul 2021 15:59:20 +0000 (08:59 -0700)
commit4ff3762a2e08245a5f005beffeb42cca5c4b6c10
treee2f3e18cee966f687bad55934a347f68b1641ae2
parentb2a670b5421af99edad62f8cb5ae172cd8d05030
Update spin-wait pause/yield normalization (#55295)

Update spin-wait pause/yield normalization

- Modified the measurement to use much less time and to remeasure periodically to reduce CPU usage during startup
- Each measurement does a low-microsecond-level measurement of pause/yield times
- Some small amount of history of recent measurements is retained and used to for now take the lowest measurement for normalization
- Measurements are done lazily, and at most every few seconds another measurement is taken
- Added a profiling event that includes info about a measurement and the established value from recent measurements that is used for normalization
15 files changed:
src/coreclr/System.Private.CoreLib/src/System/Threading/Thread.CoreCLR.cs
src/coreclr/inc/yieldprocessornormalized.h
src/coreclr/utilcode/yieldprocessornormalized.cpp
src/coreclr/vm/CMakeLists.txt
src/coreclr/vm/ClrEtwAll.man
src/coreclr/vm/ClrEtwAllMeta.lst
src/coreclr/vm/comsynchronizable.cpp
src/coreclr/vm/comsynchronizable.h
src/coreclr/vm/ecalllist.h
src/coreclr/vm/eventtrace.cpp
src/coreclr/vm/finalizerthread.cpp
src/coreclr/vm/threads.cpp
src/coreclr/vm/yieldprocessornormalized.cpp
src/libraries/System.Private.CoreLib/src/System/Threading/LowLevelSpinWaiter.cs
src/libraries/System.Private.CoreLib/src/System/Threading/SpinWait.cs