Skip to content

Commit

Permalink
Lowered the shared resource explosion detection threshold and changed…
Browse files Browse the repository at this point in the history
… the log level from warn to debug just in case it's false positive
  • Loading branch information
trustin committed Feb 13, 2009
1 parent 3d355eb commit 6370d06
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ public class MemoryAwareThreadPoolExecutor extends ThreadPoolExecutor {
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(MemoryAwareThreadPoolExecutor.class);

private static final int MISUSE_WARNING_THRESHOLD = 1024;
// I'd say 64 active event thread pools are obvious misuse.
private static final int MISUSE_WARNING_THRESHOLD = 64;
private static final AtomicInteger activeInstances = new AtomicInteger();
private static final AtomicBoolean loggedMisuseWarning = new AtomicBoolean();

Expand Down Expand Up @@ -205,8 +206,9 @@ public MemoryAwareThreadPoolExecutor(
int activeInstances = MemoryAwareThreadPoolExecutor.activeInstances.incrementAndGet();
if (activeInstances >= MISUSE_WARNING_THRESHOLD &&
loggedMisuseWarning.compareAndSet(false, true)) {
logger.warn(
"There are too many active " + getClass().getSimpleName() +
logger.debug(
"There are too many active " +
MemoryAwareThreadPoolExecutor.class.getSimpleName() +
" instances (" + activeInstances + ") - you should share " +
"the small number of instances to avoid excessive resource " +
"consumption.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ public class HashedWheelTimer implements Timer {
InternalLoggerFactory.getInstance(HashedWheelTimer.class);
private static final AtomicInteger id = new AtomicInteger();

private static final int MISUSE_WARNING_THRESHOLD = 1024;
// I'd say 64 active timer threads are obvious misuse.
private static final int MISUSE_WARNING_THRESHOLD = 64;
private static final AtomicInteger activeInstances = new AtomicInteger();
private static final AtomicBoolean loggedMisuseWarning = new AtomicBoolean();

Expand Down Expand Up @@ -134,11 +135,11 @@ public HashedWheelTimer(
int activeInstances = HashedWheelTimer.activeInstances.incrementAndGet();
if (activeInstances >= MISUSE_WARNING_THRESHOLD &&
loggedMisuseWarning.compareAndSet(false, true)) {
logger.warn(
"There are too many active " + getClass().getSimpleName() +
" instances (" + activeInstances + ") - you should share " +
"the small number of instances to avoid excessive resource " +
"consumption.");
logger.debug(
"There are too many active " +
HashedWheelTimer.class.getSimpleName() + " instances (" +
activeInstances + ") - you should share the small number " +
"of instances to avoid excessive resource consumption.");
}
}

Expand Down

0 comments on commit 6370d06

Please sign in to comment.