Run ReceiveCommits in a shared thread pool
Since the work ReceiveCommits may take a long, potentially unbounded amount of time, we would like to have it run in the background so it can be monitored for timeouts and cancelled, and have stalls reported to the user from the main thread. Wraps ReceiveCommits in a new PreReceiveHook, AsyncReceiveCommits, that runs its delegated ReceiveCommits in a WorkQueue.Executor. The default implementation sizes the thread pool to the number of available processors, under the assumption that most database and pack operations are essentially CPU-bound. This is after reading the pack from the wire, indexing it, and storing it locally, so there is no I/O to the client involved, and available CPUs is a pretty good estimate. Since it may not be in some cases, for example if threads block on slow database I/O, the pool size is configurable. Change-Id: I5769944b49ead4224a1855ba72ee359de26e7bf8
This commit is contained in:
@@ -33,6 +33,7 @@ import com.google.gerrit.server.config.SitePath;
|
||||
import com.google.gerrit.server.contact.HttpContactStoreConnection;
|
||||
import com.google.gerrit.server.git.LocalDiskRepositoryManager;
|
||||
import com.google.gerrit.server.git.PushReplication;
|
||||
import com.google.gerrit.server.git.ReceiveCommitsExecutorModule;
|
||||
import com.google.gerrit.server.git.WorkQueue;
|
||||
import com.google.gerrit.server.mail.SignedTokenEmailTokenVerifier;
|
||||
import com.google.gerrit.server.mail.SmtpEmailSender;
|
||||
@@ -190,6 +191,7 @@ public class WebAppInitializer extends GuiceServletContextListener {
|
||||
final List<Module> modules = new ArrayList<Module>();
|
||||
modules.add(new WorkQueue.Module());
|
||||
modules.add(new ChangeHookRunner.Module());
|
||||
modules.add(new ReceiveCommitsExecutorModule());
|
||||
modules.add(cfgInjector.getInstance(GerritGlobalModule.class));
|
||||
modules.add(new EhcachePoolImpl.Module());
|
||||
modules.add(new SmtpEmailSender.Module());
|
||||
|
||||
Reference in New Issue
Block a user