Log the time taken for generating the initialSeedUniquifier

- Sometimes useful to know it how long it takes from the log, to make
  sure it's not something else that is blocking.
This commit is contained in:
Trustin Lee 2014-07-04 13:25:26 +09:00
parent cd688c5cde
commit 0623df12a5

View File

@ -156,6 +156,7 @@ public final class ThreadLocalRandom extends Random {
} }
private static long newSeed() { private static long newSeed() {
final long startTime = System.nanoTime();
for (;;) { for (;;) {
final long current = seedUniquifier.get(); final long current = seedUniquifier.get();
final long actualCurrent = current != 0? current : getInitialSeedUniquifier(); final long actualCurrent = current != 0? current : getInitialSeedUniquifier();
@ -165,7 +166,9 @@ public final class ThreadLocalRandom extends Random {
if (seedUniquifier.compareAndSet(current, next)) { if (seedUniquifier.compareAndSet(current, next)) {
if (current == 0 && logger.isDebugEnabled()) { if (current == 0 && logger.isDebugEnabled()) {
logger.debug(String.format("-Dio.netty.initialSeedUniquifier: 0x%016x", actualCurrent)); logger.debug(String.format(
"-Dio.netty.initialSeedUniquifier: 0x%016x (took %d ms)",
actualCurrent, TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTime)));
} }
return next ^ System.nanoTime(); return next ^ System.nanoTime();
} }