From 598b676a96d5c6b61ae6b85748311ec4677cac62 Mon Sep 17 00:00:00 2001 From: Kaushik Lingarkar Date: Fri, 27 May 2022 15:16:48 -0700 Subject: Cache ProjectControl instances in SSH queries Use a PerThreadCache in SSH queries to cache ProjectControl instances inside DefaultPermissionBackend#ForProject so that its performance is comparable to REST where the aforementioned cache is already used. This cache helps improve performance of the change visibility check, which is done as a post-filter on the results obtained from an index query. Release-Notes: SSH query performance is improved Change-Id: Ia0b5d8c10db4f6631c59af5d2e6631d7ca4d1ea0 --- java/com/google/gerrit/server/query/change/OutputStreamQuery.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/java/com/google/gerrit/server/query/change/OutputStreamQuery.java b/java/com/google/gerrit/server/query/change/OutputStreamQuery.java index 7b71b76671..6907f15a41 100644 --- a/java/com/google/gerrit/server/query/change/OutputStreamQuery.java +++ b/java/com/google/gerrit/server/query/change/OutputStreamQuery.java @@ -29,6 +29,7 @@ import com.google.gerrit.extensions.common.PluginDefinedInfo; 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.cache.PerThreadCache; import com.google.gerrit.server.config.TrackingFooters; import com.google.gerrit.server.data.ChangeAttribute; import com.google.gerrit.server.data.PatchSetAttribute; @@ -206,7 +207,7 @@ public class OutputStreamQuery { return; } - try { + try (PerThreadCache ignored = PerThreadCache.create()) { final QueryStatsAttribute stats = new QueryStatsAttribute(); stats.runTimeMilliseconds = TimeUtil.nowMs(); -- cgit v1.2.3