From 11fdec3c4a740a84796f2b78ac302c87044a4080 Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Fri, 4 Jul 2014 13:25:26 +0900 Subject: [PATCH] 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. --- .../main/java/io/netty/util/internal/ThreadLocalRandom.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/io/netty/util/internal/ThreadLocalRandom.java b/common/src/main/java/io/netty/util/internal/ThreadLocalRandom.java index 5ab5db5a11..7fa15aa627 100644 --- a/common/src/main/java/io/netty/util/internal/ThreadLocalRandom.java +++ b/common/src/main/java/io/netty/util/internal/ThreadLocalRandom.java @@ -156,6 +156,7 @@ public final class ThreadLocalRandom extends Random { } private static long newSeed() { + final long startTime = System.nanoTime(); for (;;) { final long current = seedUniquifier.get(); final long actualCurrent = current != 0? current : getInitialSeedUniquifier(); @@ -165,7 +166,9 @@ public final class ThreadLocalRandom extends Random { if (seedUniquifier.compareAndSet(current, next)) { 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(); }