Drop remaining debug logs for known groups
Getting known groups is expensive. At the moment we log them when
requests are traced which makes traced requests more expensive. This
badly affects the performance if traced requests log known groups for
many users (e.g. the log in ExternalUser and the logs in IdentifiedUser
that we already dropped in change Ia2e7d8395). If now tracing is enabled
for too many requests this can bring down the server. To prevent this
from happening, we drop these logs. The logging of known groups in
RestApiServlet, ReceiveCommits and DefaultRefFilter is less bad as it
happens only once per requests (and likely known groups are needed at a
later point anyway), but to be on the save side we drop them as well.
Release-Notes: skip
Bug: Google b/354875955
Bug: Google b/355393768
Change-Id: I15647018c935adf51fe4fedd16e5831615826a38
Signed-off-by: Edwin Kempin <ekempin@google.com>
diff --git a/java/com/google/gerrit/httpd/restapi/RestApiServlet.java b/java/com/google/gerrit/httpd/restapi/RestApiServlet.java
index 0844ca9..daa1e9f 100644
--- a/java/com/google/gerrit/httpd/restapi/RestApiServlet.java
+++ b/java/com/google/gerrit/httpd/restapi/RestApiServlet.java
@@ -1649,8 +1649,6 @@
clientProvidedDeadline ->
logger.atFine().log("%s = %s", X_GERRIT_DEADLINE, clientProvidedDeadline));
logger.atFinest().log("Calling user: %s", globals.currentUser.get().getLoggableName());
- logger.atFinest().log(
- "Groups: %s", lazy(() -> globals.currentUser.get().getEffectiveGroups().getKnownGroups()));
}
private boolean isDelete(HttpServletRequest req) {
diff --git a/java/com/google/gerrit/server/ExternalUser.java b/java/com/google/gerrit/server/ExternalUser.java
index 9680f3e..bd4271d 100644
--- a/java/com/google/gerrit/server/ExternalUser.java
+++ b/java/com/google/gerrit/server/ExternalUser.java
@@ -14,10 +14,7 @@
package com.google.gerrit.server;
-import static com.google.common.flogger.LazyArgs.lazy;
-
import com.google.common.collect.ImmutableSet;
-import com.google.common.flogger.FluentLogger;
import com.google.gerrit.server.account.GroupBackend;
import com.google.gerrit.server.account.GroupMembership;
import com.google.gerrit.server.account.externalids.ExternalId;
@@ -34,8 +31,6 @@
* <p>This class is thread-safe.
*/
public class ExternalUser extends CurrentUser {
- private static final FluentLogger logger = FluentLogger.forEnclosingClass();
-
public interface Factory {
ExternalUser create(
Collection<String> emailAddresses,
@@ -76,8 +71,6 @@
synchronized (this) {
if (effectiveGroups == null) {
effectiveGroups = groupBackend.membershipsOf(this);
- logger.atFinest().log(
- "Known groups of %s: %s", getLoggableName(), lazy(effectiveGroups::getKnownGroups));
}
}
return effectiveGroups;
diff --git a/java/com/google/gerrit/server/git/receive/ReceiveCommits.java b/java/com/google/gerrit/server/git/receive/ReceiveCommits.java
index 536e1fb..b59ec1a 100644
--- a/java/com/google/gerrit/server/git/receive/ReceiveCommits.java
+++ b/java/com/google/gerrit/server/git/receive/ReceiveCommits.java
@@ -803,9 +803,6 @@
Collection<ReceiveCommand> commands, MultiProgressMonitor progress) {
logger.atFine().log("Calling user: %s, commands: %d", user.getLoggableName(), commands.size());
- // If the list of groups is large, the log entry may get dropped, so separate out.
- logger.atFine().log("Groups: %s", lazy(() -> user.getEffectiveGroups().getKnownGroups()));
-
if (!projectState.getProject().getState().permitsWrite()) {
for (ReceiveCommand cmd : commands) {
reject(
diff --git a/java/com/google/gerrit/server/permissions/DefaultRefFilter.java b/java/com/google/gerrit/server/permissions/DefaultRefFilter.java
index 3d8ae4f..5913673 100644
--- a/java/com/google/gerrit/server/permissions/DefaultRefFilter.java
+++ b/java/com/google/gerrit/server/permissions/DefaultRefFilter.java
@@ -16,7 +16,6 @@
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.collect.ImmutableSet.toImmutableSet;
-import static com.google.common.flogger.LazyArgs.lazy;
import static com.google.gerrit.entities.RefNames.REFS_CONFIG;
import static java.util.stream.Collectors.toCollection;
@@ -130,7 +129,6 @@
"Filter refs for repository %s by visibility (options = %s, refs = %s)",
projectState.getNameKey(), opts, refs);
logger.atFinest().log("Calling user: %s", user.getLoggableName());
- logger.atFinest().log("Groups: %s", lazy(() -> user.getEffectiveGroups().getKnownGroups()));
logger.atFinest().log(
"auth.skipFullRefEvaluationIfAllRefsAreVisible = %s",
skipFullRefEvaluationIfAllRefsAreVisible);