Skip to content

Commit c7309fc

Browse files
author
Vladimir Kotal
committed
move remaining parallelism tunables to Configuration
fixes #2110
1 parent 47da214 commit c7309fc

File tree

2 files changed

+43
-25
lines changed

2 files changed

+43
-25
lines changed

src/org/opensolaris/opengrok/configuration/Configuration.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ public final class Configuration {
184184
private RemoteSCM remoteScmSupported;
185185
private boolean optimizeDatabase;
186186
/**
187-
* @deprecated This is kept around so not to break object deserialization.
187+
* @deprecated This is kept around so not to break object de-serialization.
188188
* <p>Anyone who is using `--lock on` will now be setting
189189
* {@link #luceneLocking} and resetting this field back to its default
190190
* value. This should mean that the configuration is written leaving out
@@ -198,6 +198,8 @@ public final class Configuration {
198198
private boolean compressXref;
199199
private boolean indexVersionedFilesOnly;
200200
private int indexingParallelism;
201+
private int historyParallelism;
202+
private int historyRenamedParallelism;
201203
private boolean tagsEnabled;
202204
private int hitsPerPage;
203205
private int cachePages;
@@ -1061,6 +1063,22 @@ public void setIndexingParallelism(int value) {
10611063
this.indexingParallelism = value > 0 ? value : 0;
10621064
}
10631065

1066+
public int getHistoryParallelism() {
1067+
return historyParallelism;
1068+
}
1069+
1070+
public void setHistoryParallelism(int value) {
1071+
this.historyParallelism = value > 0 ? value : 0;
1072+
}
1073+
1074+
public int getHistoryRenamedParallelism() {
1075+
return historyRenamedParallelism;
1076+
}
1077+
1078+
public void setHistoryRenamedParallelism(int value) {
1079+
this.historyRenamedParallelism = value > 0 ? value : 0;
1080+
}
1081+
10641082
public boolean isTagsEnabled() {
10651083
return this.tagsEnabled;
10661084
}

src/org/opensolaris/opengrok/configuration/RuntimeEnvironment.java

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -178,18 +178,7 @@ public final class RuntimeEnvironment {
178178
/* Get thread pool used for top-level repository history generation. */
179179
public static synchronized ExecutorService getHistoryExecutor() {
180180
if (historyExecutor == null) {
181-
int num = Runtime.getRuntime().availableProcessors();
182-
String total = System.getProperty("org.opensolaris.opengrok.history.NumCacheThreads");
183-
if (total != null) {
184-
try {
185-
num = Integer.valueOf(total);
186-
} catch (Throwable t) {
187-
LOGGER.log(Level.WARNING, "Failed to parse the number of "
188-
+ "cache threads to use for cache creation", t);
189-
}
190-
}
191-
192-
historyExecutor = Executors.newFixedThreadPool(num,
181+
historyExecutor = Executors.newFixedThreadPool(getInstance().getHistoryParallelism(),
193182
new ThreadFactory() {
194183
@Override
195184
public Thread newThread(Runnable runnable) {
@@ -206,18 +195,7 @@ public Thread newThread(Runnable runnable) {
206195
/* Get thread pool used for history generation of renamed files. */
207196
public static synchronized ExecutorService getHistoryRenamedExecutor() {
208197
if (historyRenamedExecutor == null) {
209-
int num = Runtime.getRuntime().availableProcessors();
210-
String total = System.getProperty("org.opensolaris.opengrok.history.NumCacheRenamedThreads");
211-
if (total != null) {
212-
try {
213-
num = Integer.valueOf(total);
214-
} catch (Throwable t) {
215-
LOGGER.log(Level.WARNING, "Failed to parse the number of "
216-
+ "cache threads to use for cache creation of renamed files", t);
217-
}
218-
}
219-
220-
historyRenamedExecutor = Executors.newFixedThreadPool(num,
198+
historyRenamedExecutor = Executors.newFixedThreadPool(getInstance().getHistoryRenamedParallelism(),
221199
new ThreadFactory() {
222200
@Override
223201
public Thread newThread(Runnable runnable) {
@@ -1133,6 +1111,28 @@ public int getIndexingParallelism() {
11331111
parallelism;
11341112
}
11351113

1114+
/**
1115+
* Gets the value of {@link Configuration#getHistoryParallelism()} -- or
1116+
* if zero, then as a default gets the number of available processors.
1117+
* @return a natural number &gt;= 1
1118+
*/
1119+
public int getHistoryParallelism() {
1120+
int parallelism = threadConfig.get().getHistoryParallelism();
1121+
return parallelism < 1 ? Runtime.getRuntime().availableProcessors() :
1122+
parallelism;
1123+
}
1124+
1125+
/**
1126+
* Gets the value of {@link Configuration#getHistoryRenamedParallelism()} -- or
1127+
* if zero, then as a default gets the number of available processors.
1128+
* @return a natural number &gt;= 1
1129+
*/
1130+
public int getHistoryRenamedParallelism() {
1131+
int parallelism = threadConfig.get().getHistoryRenamedParallelism();
1132+
return parallelism < 1 ? Runtime.getRuntime().availableProcessors() :
1133+
parallelism;
1134+
}
1135+
11361136
public boolean isTagsEnabled() {
11371137
return threadConfig.get().isTagsEnabled();
11381138
}

0 commit comments

Comments
 (0)