Add Gerrit config to disable mergeability bit in ChangeInfo

Computing mergeability of open changes becomes very expensive for hosts
that have fast-moving branches and a lot of open changes. This commit
scales down this problem by adding a config to remove the bit from
ChangeInfo.

We will consult the mailing list to see if we can remove this bit from
ChangeInfo and the change index completely or add a new MERGEABLE list
option.

Change-Id: I28e90e17abaf369d03ff9d3c0d491903ecf30bf9
This commit is contained in:
Patrick Hiesel
2019-01-24 10:11:23 +01:00
parent 3307aed7b1
commit db8df4886c
5 changed files with 32 additions and 2 deletions

View File

@@ -83,6 +83,7 @@ import com.google.gerrit.server.ReviewerStatusUpdate;
import com.google.gerrit.server.StarredChangesUtil;
import com.google.gerrit.server.account.AccountInfoComparator;
import com.google.gerrit.server.account.AccountLoader;
import com.google.gerrit.server.config.GerritServerConfig;
import com.google.gerrit.server.config.TrackingFooters;
import com.google.gerrit.server.index.change.ChangeField;
import com.google.gerrit.server.notedb.ChangeNotes;
@@ -111,6 +112,7 @@ import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.function.Supplier;
import org.eclipse.jgit.lib.Config;
/**
* Produces {@link ChangeInfo} (which is serialized to JSON afterwards) from {@link ChangeData}.
@@ -216,6 +218,7 @@ public class ChangeJson {
private final Metrics metrics;
private final RevisionJson revisionJson;
private final Optional<PluginDefinedAttributesFactory> pluginDefinedAttributesFactory;
private final boolean excludeMergeableInChangeInfo;
private final boolean lazyLoad;
private AccountLoader accountLoader;
@@ -236,6 +239,7 @@ public class ChangeJson {
TrackingFooters trackingFooters,
Metrics metrics,
RevisionJson.Factory revisionJsonFactory,
@GerritServerConfig Config cfg,
@Assisted Iterable<ListChangesOption> options,
@Assisted Optional<PluginDefinedAttributesFactory> pluginDefinedAttributesFactory) {
this.userProvider = user;
@@ -252,6 +256,8 @@ public class ChangeJson {
this.metrics = metrics;
this.revisionJson = revisionJsonFactory.create(options);
this.options = Sets.immutableEnumSet(options);
this.excludeMergeableInChangeInfo =
cfg.getBoolean("change", "api", "excludeMergeableInChangeInfo", false);
this.lazyLoad = containsAnyOf(this.options, REQUIRE_LAZY_LOAD);
this.pluginDefinedAttributesFactory = pluginDefinedAttributesFactory;
@@ -509,7 +515,7 @@ public class ChangeJson {
if (str.isOk()) {
out.submitType = str.type;
}
if (!has(SKIP_MERGEABLE)) {
if (!excludeMergeableInChangeInfo && !has(SKIP_MERGEABLE)) {
out.mergeable = cd.isMergeable();
}
if (has(SUBMITTABLE)) {