updated threadpool size

This commit is contained in:
Jeremy Long
2017-03-07 06:37:21 -05:00
parent 679df936e7
commit 03ec3142c3
5 changed files with 11 additions and 12 deletions

View File

@@ -613,9 +613,7 @@ public class Engine implements FileFilter {
*/ */
protected ExecutorService getExecutorService(Analyzer analyzer) { protected ExecutorService getExecutorService(Analyzer analyzer) {
if (analyzer.supportsParallelProcessing()) { if (analyzer.supportsParallelProcessing()) {
// just a fair trade-off that should be reasonable for all analyzer types final int maximumNumberOfThreads = Runtime.getRuntime().availableProcessors();
final int maximumNumberOfThreads = 4 * Runtime.getRuntime().availableProcessors();
LOGGER.debug("Parallel processing with up to {} threads: {}.", maximumNumberOfThreads, analyzer.getName()); LOGGER.debug("Parallel processing with up to {} threads: {}.", maximumNumberOfThreads, analyzer.getName());
return Executors.newFixedThreadPool(maximumNumberOfThreads); return Executors.newFixedThreadPool(maximumNumberOfThreads);
} else { } else {

View File

@@ -63,11 +63,11 @@ public class NvdCveUpdater implements CachedWebDataSource {
/** /**
* The thread pool size to use for CPU-intense tasks. * The thread pool size to use for CPU-intense tasks.
*/ */
private static final int PROCESSING_THREAD_POOL_SIZE = 1; private static final int PROCESSING_THREAD_POOL_SIZE = Runtime.getRuntime().availableProcessors();
/** /**
* The thread pool size to use when downloading files. * The thread pool size to use when downloading files.
*/ */
private static final int DOWNLOAD_THREAD_POOL_SIZE = Settings.getInt(Settings.KEYS.MAX_DOWNLOAD_THREAD_POOL_SIZE, 50); private static final int DOWNLOAD_THREAD_POOL_SIZE = Math.round(1.5f * Runtime.getRuntime().availableProcessors());
/** /**
* ExecutorService for CPU-intense processing tasks. * ExecutorService for CPU-intense processing tasks.
*/ */
@@ -99,16 +99,20 @@ public class NvdCveUpdater implements CachedWebDataSource {
} }
try { try {
initializeExecutorServices();
cveDb = CveDB.getInstance();
dbProperties = cveDb.getDatabaseProperties();
boolean autoUpdate = true; boolean autoUpdate = true;
try { try {
autoUpdate = Settings.getBoolean(Settings.KEYS.AUTO_UPDATE); autoUpdate = Settings.getBoolean(Settings.KEYS.AUTO_UPDATE);
} catch (InvalidSettingException ex) { } catch (InvalidSettingException ex) {
LOGGER.debug("Invalid setting for auto-update; using true."); LOGGER.debug("Invalid setting for auto-update; using true.");
} }
if (autoUpdate && checkUpdate()) { if (!autoUpdate) {
return;
}
initializeExecutorServices();
cveDb = CveDB.getInstance();
dbProperties = cveDb.getDatabaseProperties();
if (checkUpdate()) {
final UpdateableNvdCve updateable = getUpdatesNeeded(); final UpdateableNvdCve updateable = getUpdatesNeeded();
if (updateable.isUpdateNeeded()) { if (updateable.isUpdateNeeded()) {
performUpdate(updateable); performUpdate(updateable);

View File

@@ -1,7 +1,6 @@
application.name=${pom.name} application.name=${pom.name}
application.version=${pom.version} application.version=${pom.version}
autoupdate=true autoupdate=true
max.download.threads=50
# the url to obtain the current engine version from # the url to obtain the current engine version from
engine.version.url=https://jeremylong.github.io/DependencyCheck/current.txt engine.version.url=https://jeremylong.github.io/DependencyCheck/current.txt

View File

@@ -1,7 +1,6 @@
application.name=${pom.name} application.name=${pom.name}
application.version=${pom.version} application.version=${pom.version}
autoupdate=true autoupdate=true
max.download.threads=50
# the url to obtain the current engine version from # the url to obtain the current engine version from
engine.version.url=https://jeremylong.github.io/DependencyCheck/current.txt engine.version.url=https://jeremylong.github.io/DependencyCheck/current.txt

View File

@@ -1,7 +1,6 @@
application.name=${pom.name} application.name=${pom.name}
application.version=${pom.version} application.version=${pom.version}
autoupdate=true autoupdate=true
max.download.threads=50
# the url to obtain the current engine version from # the url to obtain the current engine version from
engine.version.url=http://jeremylong.github.io/DependencyCheck/current.txt engine.version.url=http://jeremylong.github.io/DependencyCheck/current.txt