Skip to content

Commit 2123e36

Browse files
author
Vladimir Kotal
committed
add tunable for repository invalidation concurrency level
Also, do not rebuild repository tags in the web app. fixes #3157
1 parent 76b5929 commit 2123e36

File tree

5 files changed

+31
-5
lines changed

5 files changed

+31
-5
lines changed

opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/Configuration.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ public final class Configuration {
179179
private boolean compressXref;
180180
private boolean indexVersionedFilesOnly;
181181
private int indexingParallelism;
182+
private int repositoryInvalidationParallelism;
182183
private int historyParallelism;
183184
private int historyFileParallelism;
184185
private boolean tagsEnabled;
@@ -1149,6 +1150,14 @@ public void setIndexingParallelism(int value) {
11491150
this.indexingParallelism = Math.max(value, 0);
11501151
}
11511152

1153+
public int getRepositoryInvalidationParallelism() {
1154+
return repositoryInvalidationParallelism;
1155+
}
1156+
1157+
public void setRepositoryInvalidationParallelism(int value) {
1158+
this.repositoryInvalidationParallelism = Math.max(value, 0);
1159+
}
1160+
11521161
public int getHistoryParallelism() {
11531162
return historyParallelism;
11541163
}

opengrok-indexer/src/main/java/org/opengrok/indexer/configuration/RuntimeEnvironment.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,6 +1114,16 @@ public int getIndexingParallelism() {
11141114
parallelism;
11151115
}
11161116

1117+
/**
1118+
* Gets the value of {@link Configuration#getRepositoryInvalidationParallelism()} -- or
1119+
* if zero, then as a default gets the number of available processors halved.
1120+
* @return a natural number >= 1
1121+
*/
1122+
public int getRepositoryInvalidationParallelism() {
1123+
int parallelism = syncReadConfiguration(Configuration::getRepositoryInvalidationParallelism);
1124+
return parallelism < 1 ? (Runtime.getRuntime().availableProcessors() / 2) : parallelism;
1125+
}
1126+
11171127
/**
11181128
* Gets the value of {@link Configuration#getHistoryParallelism()} -- or
11191129
* if zero, then as a default gets the number of available processors.

opengrok-indexer/src/main/java/org/opengrok/indexer/history/HistoryGuru.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
/*
21-
* Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved.
21+
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
2222
* Portions Copyright (c) 2017, 2020, Chris Fraire <[email protected]>.
2323
*/
2424
package org.opengrok.indexer.history;
@@ -815,7 +815,14 @@ public void invalidateRepositories(Collection<? extends RepositoryInfo> repos, C
815815
* run in parallel to speed up the process.
816816
*/
817817
final CountDownLatch latch = new CountDownLatch(repos.size());
818-
final ExecutorService executor = Executors.newFixedThreadPool(env.getIndexingParallelism(),
818+
int parallelismLevel;
819+
// Both indexer and web app startup should be as quick as possible.
820+
if (cmdType.equals(CommandTimeoutType.INDEXER) || cmdType.equals(CommandTimeoutType.WEBAPP_START)) {
821+
parallelismLevel = env.getIndexingParallelism();
822+
} else {
823+
parallelismLevel = env.getRepositoryInvalidationParallelism();
824+
}
825+
final ExecutorService executor = Executors.newFixedThreadPool(parallelismLevel,
819826
runnable -> {
820827
Thread thread = Executors.defaultThreadFactory().newThread(runnable);
821828
thread.setName("invalidate-repos-" + thread.getId());

opengrok-indexer/src/main/java/org/opengrok/indexer/history/RepositoryFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ public static Repository getRepository(File file, CommandTimeoutType cmdType, bo
245245

246246
// If this repository displays tags only for files changed by tagged
247247
// revision, we need to prepare list of all tags in advance.
248-
if (env.isTagsEnabled() && repo.hasFileBasedTags()) {
248+
if (cmdType.equals(CommandTimeoutType.INDEXER) && env.isTagsEnabled() && repo.hasFileBasedTags()) {
249249
repo.buildTagList(file, cmdType);
250250
}
251251

opengrok-web/src/main/java/org/opengrok/web/api/v1/controller/ConfigurationController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*/
1919

2020
/*
21-
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
21+
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
2222
* Portions Copyright (c) 2017, 2020, Chris Fraire <[email protected]>.
2323
*/
2424
package org.opengrok.web.api.v1.controller;
@@ -59,7 +59,7 @@ public String get() {
5959
@PUT
6060
@Consumes(MediaType.APPLICATION_XML)
6161
public void set(final String body, @QueryParam("reindex") final boolean reindex) {
62-
env.applyConfig(body, reindex, reindex ? CommandTimeoutType.INDEXER : CommandTimeoutType.RESTFUL);
62+
env.applyConfig(body, reindex, CommandTimeoutType.RESTFUL);
6363
suggesterService.refresh();
6464
}
6565

0 commit comments

Comments
 (0)