Skip to content

add tunable for concurrency level of repository invalidation #3775

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ public final class Configuration {
private boolean compressXref;
private boolean indexVersionedFilesOnly;
private int indexingParallelism;
private int repositoryInvalidationParallelism;
private int historyParallelism;
private int historyFileParallelism;
private boolean tagsEnabled;
Expand Down Expand Up @@ -1168,6 +1169,14 @@ public void setIndexingParallelism(int value) {
this.indexingParallelism = Math.max(value, 0);
}

public int getRepositoryInvalidationParallelism() {
return repositoryInvalidationParallelism;
}

public void setRepositoryInvalidationParallelism(int value) {
this.repositoryInvalidationParallelism = Math.max(value, 0);
}

public int getHistoryParallelism() {
return historyParallelism;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1114,6 +1114,16 @@ public int getIndexingParallelism() {
parallelism;
}

/**
* Gets the value of {@link Configuration#getRepositoryInvalidationParallelism()} -- or
* if zero, then as a default gets the number of available processors halved.
* @return a natural number >= 1
*/
public int getRepositoryInvalidationParallelism() {
int parallelism = syncReadConfiguration(Configuration::getRepositoryInvalidationParallelism);
return parallelism < 1 ? (Runtime.getRuntime().availableProcessors() / 2) : parallelism;
}

/**
* Gets the value of {@link Configuration#getHistoryParallelism()} -- or
* if zero, then as a default gets the number of available processors.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

/*
* Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
* Portions Copyright (c) 2017, 2020, Chris Fraire <[email protected]>.
*/
package org.opengrok.indexer.history;
Expand Down Expand Up @@ -815,7 +815,14 @@ public void invalidateRepositories(Collection<? extends RepositoryInfo> repos, C
* run in parallel to speed up the process.
*/
final CountDownLatch latch = new CountDownLatch(repos.size());
final ExecutorService executor = Executors.newFixedThreadPool(env.getIndexingParallelism(),
int parallelismLevel;
// Both indexer and web app startup should be as quick as possible.
if (cmdType == CommandTimeoutType.INDEXER || cmdType == CommandTimeoutType.WEBAPP_START) {
parallelismLevel = env.getIndexingParallelism();
} else {
parallelismLevel = env.getRepositoryInvalidationParallelism();
}
final ExecutorService executor = Executors.newFixedThreadPool(parallelismLevel,
runnable -> {
Thread thread = Executors.defaultThreadFactory().newThread(runnable);
thread.setName("invalidate-repos-" + thread.getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ public static Repository getRepository(File file, CommandTimeoutType cmdType, bo

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

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

Expand Down