summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPrudhvi Akhil Alahari <prudhvi.alahari@linaro.org>2023-02-08 19:34:54 +0530
committerMartin Fick <martin.fick@linaro.org>2023-05-05 15:33:30 +0000
commit2ca5ed5037506d19cef2e37a3818a4b61f76eaa4 (patch)
tree5f8955c3465c11032c9e2c954ea487f7939bc393
parentcf407cb99f3fe9681286df06b2c23759e023948c (diff)
Move creation of PerThreadCache to SshCommand
Change Ia0b5d8c10d, only added PerThreadCache in SSH query command. We want most SSH commands to benefit from PerThreadCache same as all the REST APIs use this cache. Move creation of PerThreadCache to SshCommand so that the cache is available to most commands, including plugins. We have some plugin use cases where this helps with performance either because of the extra project caching or the extra ref caching enabled by this. Release-Notes: Improved performance for plugin-provided SSH commands that perform multiple permission checks or ref lookups for the same project Change-Id: I5ade18ecab14bf419a23759dfe4ab0beeaf83ea9
-rw-r--r--java/com/google/gerrit/server/query/change/OutputStreamQuery.java3
-rw-r--r--java/com/google/gerrit/sshd/SshCommand.java4
2 files changed, 4 insertions, 3 deletions
diff --git a/java/com/google/gerrit/server/query/change/OutputStreamQuery.java b/java/com/google/gerrit/server/query/change/OutputStreamQuery.java
index 716cf106d2..961404adb7 100644
--- a/java/com/google/gerrit/server/query/change/OutputStreamQuery.java
+++ b/java/com/google/gerrit/server/query/change/OutputStreamQuery.java
@@ -30,7 +30,6 @@ import com.google.gerrit.index.query.QueryParseException;
import com.google.gerrit.index.query.QueryResult;
import com.google.gerrit.server.DynamicOptions;
import com.google.gerrit.server.account.AccountAttributeLoader;
-import com.google.gerrit.server.cache.PerThreadCache;
import com.google.gerrit.server.config.TrackingFooters;
import com.google.gerrit.server.data.ChangeAttribute;
import com.google.gerrit.server.data.PatchSetAttribute;
@@ -211,7 +210,7 @@ public class OutputStreamQuery {
return;
}
- try (PerThreadCache ignored = PerThreadCache.create()) {
+ try {
final QueryStatsAttribute stats = new QueryStatsAttribute();
stats.runTimeMilliseconds = TimeUtil.nowMs();
diff --git a/java/com/google/gerrit/sshd/SshCommand.java b/java/com/google/gerrit/sshd/SshCommand.java
index 9df263b860..a4e427d1eb 100644
--- a/java/com/google/gerrit/sshd/SshCommand.java
+++ b/java/com/google/gerrit/sshd/SshCommand.java
@@ -23,6 +23,7 @@ import com.google.gerrit.server.DynamicOptions;
import com.google.gerrit.server.InvalidDeadlineException;
import com.google.gerrit.server.RequestInfo;
import com.google.gerrit.server.RequestListener;
+import com.google.gerrit.server.cache.PerThreadCache;
import com.google.gerrit.server.cancellation.RequestCancelledException;
import com.google.gerrit.server.cancellation.RequestStateContext;
import com.google.gerrit.server.config.GerritServerConfig;
@@ -62,7 +63,8 @@ public abstract class SshCommand extends BaseCommand {
public void start(ChannelSession channel, Environment env) throws IOException {
startThread(
() -> {
- try (DynamicOptions pluginOptions = new DynamicOptions(injector, dynamicBeans)) {
+ try (PerThreadCache ignored = PerThreadCache.create();
+ DynamicOptions pluginOptions = new DynamicOptions(injector, dynamicBeans)) {
parseCommandLine(pluginOptions);
stdout = toPrintWriter(out);
stderr = toPrintWriter(err);