Parallelize ChangeJson#toChangeInfos

99%ile latency of QueryChanges is between 20 seconds and
80 seconds on googlesource.com depending on the time of
day. There are two main reasons for that:
1) Performing operations that require loading ChangeNotes
2) Performing operations that require opening the repo
3) Filling accounts with a cold AccountCache

This commit parallelizes formatting the individual results
to mitigate 1+2. 3 will be addressed by a different change
that will make the AccountFiller parallelize, too.

Parallelization is done on a newly introduced FanOutExectuor
that can be used whenever a serving thread wants to parallelize
work.

Change-Id: I36c6b92e31488ad001f5aea43efc837d31ba3021
This commit is contained in:
Patrick Hiesel
2018-04-16 12:04:02 +02:00
committed by Patrick Hiesel
parent a691e63bd6
commit 2ed3982ffb
5 changed files with 113 additions and 36 deletions

View File

@@ -17,6 +17,7 @@ package com.google.gerrit.server.config;
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.google.gerrit.server.FanOutExecutor;
import com.google.gerrit.server.git.WorkQueue;
import com.google.inject.AbstractModule;
import com.google.inject.Provides;
@@ -61,6 +62,17 @@ public class SysExecutorModule extends AbstractModule {
return queues.createQueue(poolSize, "SendEmail");
}
@Provides
@Singleton
@FanOutExecutor
public ExecutorService createFanOutExecutor(@GerritServerConfig Config config, WorkQueue queues) {
int poolSize = config.getInt("execution", null, "fanOutThreadPoolSize", 25);
if (poolSize == 0) {
return MoreExecutors.newDirectExecutorService();
}
return queues.createQueue(poolSize, "FanOut");
}
@Provides
@Singleton
@ChangeUpdateExecutor