diff --git a/Documentation/config-gerrit.txt b/Documentation/config-gerrit.txt index 4c1766f2b8..71441d832c 100644 --- a/Documentation/config-gerrit.txt +++ b/Documentation/config-gerrit.txt @@ -2779,16 +2779,16 @@ Number of threads to use for indexing in normal interactive operations. Setting it to 0 disables the dedicated thread pool and indexing will be done in the same thread as the operation. + -If not set or set to a negative value, defaults to 1 plus half of the number of -logical CPUs as returned by the JVM. +If not set or set to a zero, defaults to the number of logical CPUs as returned +by the JVM. If set to a negative value, defaults to a direct executor. [[index.batchThreads]]index.batchThreads:: + Number of threads to use for indexing in background operations, such as online schema upgrades. + -If not set or set to a negative value, defaults to the number of logical -CPUs as returned by the JVM. +If not set or set to a zero, defaults to the number of logical CPUs as returned +by the JVM. If set to a negative value, defaults to a direct executor. [[index.onlineUpgrade]]index.onlineUpgrade:: + diff --git a/java/com/google/gerrit/acceptance/AbstractDaemonTest.java b/java/com/google/gerrit/acceptance/AbstractDaemonTest.java index 6828393191..819012fc9f 100644 --- a/java/com/google/gerrit/acceptance/AbstractDaemonTest.java +++ b/java/com/google/gerrit/acceptance/AbstractDaemonTest.java @@ -397,6 +397,8 @@ public abstract class AbstractDaemonTest { baseConfig.setString("sshd", null, "listenAddress", "off"); } + baseConfig.setInt("index", null, "batchThreads", -1); + baseConfig.setInt("receive", null, "changeUpdateThreads", 4); Module module = createModule(); if (classDesc.equals(methodDesc) && !classDesc.sandboxed() && !methodDesc.sandboxed()) { diff --git a/java/com/google/gerrit/server/index/IndexModule.java b/java/com/google/gerrit/server/index/IndexModule.java index d9575584c5..3c9538c2d9 100644 --- a/java/com/google/gerrit/server/index/IndexModule.java +++ b/java/com/google/gerrit/server/index/IndexModule.java @@ -104,7 +104,7 @@ public class IndexModule extends LifecycleModule { public IndexModule( ListeningExecutorService interactiveExecutor, ListeningExecutorService batchExecutor) { - this.threads = -1; + this.threads = 0; this.interactiveExecutor = interactiveExecutor; this.batchExecutor = batchExecutor; this.closeExecutorsOnShutdown = false; @@ -211,11 +211,12 @@ public class IndexModule extends LifecycleModule { return interactiveExecutor; } int threads = this.threads; - if (threads <= 0) { - threads = config.getInt("index", null, "threads", 0); - } - if (threads <= 0) { - threads = Runtime.getRuntime().availableProcessors() / 2 + 1; + if (threads < 0) { + return MoreExecutors.newDirectExecutorService(); + } else if (threads == 0) { + threads = + config.getInt( + "index", null, "threads", Runtime.getRuntime().availableProcessors() / 2 + 1); } return MoreExecutors.listeningDecorator( workQueue.createQueue(threads, "Index-Interactive", true)); @@ -230,7 +231,9 @@ public class IndexModule extends LifecycleModule { return batchExecutor; } int threads = config.getInt("index", null, "batchThreads", 0); - if (threads <= 0) { + if (threads < 0) { + return MoreExecutors.newDirectExecutorService(); + } else if (threads == 0) { threads = Runtime.getRuntime().availableProcessors(); } return MoreExecutors.listeningDecorator(workQueue.createQueue(threads, "Index-Batch", true));