On Tue, 16 Jun 2026 14:30:54 GMT, Andrew Haley <[email protected]> wrote:
>> src/hotspot/share/runtime/javaThread.cpp line 429:
>>
>>> 427: int state;
>>> 428: do {
>>> 429: state = os::random();
>>
>> Tidbit: `os::random()` seems to be Park-Miller `mod (2**31-1)`, so the
>> highest bit is always unset. Does it have impact on profiling? IOW, does any
>> profiling code depends on all bits being uniformly distributed?
>>
>> It sounds from this code that we _do_ care about the highest bits?
>>
>>
>> auto threshold = (UCONST64(1) << 32) >> ratio_shift;
>> __ cmpl(r_profile_rng, threshold);
>> __ jccb(Assembler::aboveEqual, nope);
>
> Any nonzero starting point is fine. All we really need is for the top bits to
> be uniformly distributed and uncorrelated with the program being run.
Right, right. I somehow thought this `os::random()` the actual random value we
use to sample, not the starting point.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/28541#discussion_r3421678769