Minor performance tuning to avoid excessive connection attempts of downed databases.

pull/154/head
Brett Wooldridge
parent d7ad473ac3
commit fd15648979

@ -296,7 +296,7 @@ public final class HikariPool implements HikariPoolMBean, IBagStateListener
while (!isShutdown && totalConnections.get() < maxPoolSize && (minIdle == 0 || getIdleConnections() < minIdle)) {
if (!addConnection()) {
quietlySleep(sleepBackoff);
sleepBackoff = Math.min(1000L, (long) ((double) sleepBackoff * 1.5));
sleepBackoff = Math.min(connectionTimeout / 2, (long) ((double) sleepBackoff * 1.5));
continue;
}

@ -128,9 +128,9 @@ public final class PoolUtilities
threadFactory = new DefaultThreadFactory(threadName, true);
}
int processors = Math.max(1, Runtime.getRuntime().availableProcessors() / 2);
int processors = Math.max(1, Runtime.getRuntime().availableProcessors() / 4);
LinkedBlockingQueue<Runnable> queue = new LinkedBlockingQueue<Runnable>(queueSize);
ThreadPoolExecutor executor = new ThreadPoolExecutor(processors, processors, 2, TimeUnit.SECONDS, queue, threadFactory,
ThreadPoolExecutor executor = new ThreadPoolExecutor(processors, processors, 5, TimeUnit.SECONDS, queue, threadFactory,
new ThreadPoolExecutor.DiscardPolicy());
executor.allowCoreThreadTimeOut(true);
return executor;

@ -293,7 +293,7 @@ public final class HikariPool implements HikariPoolMBean, IBagStateListener
while (!isShutdown && totalConnections.get() < maxPoolSize && (minIdle == 0 || getIdleConnections() < minIdle)) {
if (!addConnection()) {
quietlySleep(sleepBackoff);
sleepBackoff = Math.min(1000L, (long) ((double) sleepBackoff * 1.5));
sleepBackoff = Math.min(connectionTimeout / 2, (long) ((double) sleepBackoff * 1.5));
continue;
}

@ -110,9 +110,9 @@ public final class PoolUtilities
threadFactory = new DefaultThreadFactory(threadName, true);
}
int processors = Math.max(1, Runtime.getRuntime().availableProcessors() / 2);
int processors = Math.max(1, Runtime.getRuntime().availableProcessors() / 4);
LinkedBlockingQueue<Runnable> queue = new LinkedBlockingQueue<Runnable>(queueSize);
ThreadPoolExecutor executor = new ThreadPoolExecutor(processors, processors, 2, TimeUnit.SECONDS, queue, threadFactory,
ThreadPoolExecutor executor = new ThreadPoolExecutor(processors, processors, 5, TimeUnit.SECONDS, queue, threadFactory,
new ThreadPoolExecutor.DiscardPolicy());
executor.allowCoreThreadTimeOut(true);
return executor;

Loading…
Cancel
Save