From: Egor Bogatov Date: Fri, 10 Feb 2023 11:28:13 +0000 (+0100) Subject: Remove contention from HandleHistogramProfileRand (#81932) X-Git-Tag: accepted/tizen/unified/riscv/20231226.055536~4109 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0d95bf1c5ead1227762914495f7206e315c3fc16;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Remove contention from HandleHistogramProfileRand (#81932) --- diff --git a/src/coreclr/vm/jithelpers.cpp b/src/coreclr/vm/jithelpers.cpp index 2628f56..a6d41ca 100644 --- a/src/coreclr/vm/jithelpers.cpp +++ b/src/coreclr/vm/jithelpers.cpp @@ -5407,12 +5407,12 @@ void JIT_PartialCompilationPatchpoint(int* counter, int ilOffset) static unsigned HandleHistogramProfileRand() { - // generate a random number (xorshift32) + // Generate a random number (xorshift32) // - // intentionally simple so we can have multithreaded - // access w/o tearing state. + // Intentionally simple for faster random. It's stored in TLS to avoid + // multithread contention. // - static volatile unsigned s_rng = 100; + static thread_local unsigned s_rng = 100; unsigned x = s_rng; x ^= x << 13;