summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugo Arès <hugo.ares@ericsson.com>2016-05-18 08:33:35 -0400
committerDavid Pursehouse <dpursehouse@collab.net>2016-05-19 00:38:32 +0000
commit776e004f059d4d4b4d6e3f24490aa0336762f614 (patch)
treedc615b409ea784e88a67d72a941f3e6e103d134b
parentbbfde1990942eba28564f56ca77d3f4560df3361 (diff)
Synchronize MyersDiff and HistogramDiff invocations on local variable
I4516bcc2c synchronized MyersDiff and HistogramDiff invocations but it used a synchronization object that is not local to the PatchList being loaded. In other words, even if PatchList can be loaded in parallel, only one file header diff can be computed at the time across the entire server. In stable-2.12, a fresh instance of PatchListLoaded is used every time a PatchList is loaded so this change is not needed, and must be reverted when merging stable-2.11 into stable-2.12. Change-Id: I5acace093b16c9b87cf465c515018433c3f38d6a
-rw-r--r--gerrit-server/src/main/java/com/google/gerrit/server/patch/PatchListLoader.java6
1 files changed, 2 insertions, 4 deletions
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/patch/PatchListLoader.java b/gerrit-server/src/main/java/com/google/gerrit/server/patch/PatchListLoader.java
index 13cb50673b..838b3433de 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/patch/PatchListLoader.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/patch/PatchListLoader.java
@@ -87,7 +87,6 @@ public class PatchListLoader extends CacheLoader<PatchListKey, PatchList> {
private final ThreeWayMergeStrategy mergeStrategy;
private final ExecutorService diffExecutor;
private final long timeoutMillis;
- private final Object lock;
@Inject
PatchListLoader(GitRepositoryManager mgr,
@@ -98,7 +97,6 @@ public class PatchListLoader extends CacheLoader<PatchListKey, PatchList> {
patchListCache = plc;
mergeStrategy = MergeUtil.getMergeStrategy(cfg);
diffExecutor = de;
- lock = new Object();
timeoutMillis =
ConfigUtil.getTimeUnit(cfg, "cache", PatchListCacheImpl.FILE_NAME,
"timeout", TimeUnit.MILLISECONDS.convert(5, TimeUnit.SECONDS),
@@ -206,7 +204,7 @@ public class PatchListLoader extends CacheLoader<PatchListKey, PatchList> {
Future<FileHeader> result = diffExecutor.submit(new Callable<FileHeader>() {
@Override
public FileHeader call() throws IOException {
- synchronized (lock) {
+ synchronized (diffEntry) {
return diffFormatter.toFileHeader(diffEntry);
}
}
@@ -222,7 +220,7 @@ public class PatchListLoader extends CacheLoader<PatchListKey, PatchList> {
+ " comparing " + diffEntry.getOldId().name()
+ ".." + diffEntry.getNewId().name());
result.cancel(true);
- synchronized (lock) {
+ synchronized (diffEntry) {
return toFileHeaderWithoutMyersDiff(diffFormatter, diffEntry);
}
} catch (ExecutionException e) {