Disable printing cache stats by default on Init/Reindex
Printing cache statistics can be slow, particularly when the
caches are large. For example, when the caches are ~400G,
printing cache stats takes over 30 mins.
Release-Notes: Printing cache stats is disabled by default for Init and Reindex
Change-Id: I848d6dfef0be9dee9ebac8a597dd7e617cbe30e4
diff --git a/Documentation/pgm-init.txt b/Documentation/pgm-init.txt
index f6c3c85..9f592486 100644
--- a/Documentation/pgm-init.txt
+++ b/Documentation/pgm-init.txt
@@ -99,6 +99,9 @@
The administrator must manually install the required library in the `lib/`
folder.
+--show-cache-stats::
+ Show cache statistics at the end of program.
+
== CONTEXT
This command can only be run on a server which has direct local access to the
managed Git repositories.
diff --git a/Documentation/pgm-reindex.txt b/Documentation/pgm-reindex.txt
index 0653d8d..b74829d 100644
--- a/Documentation/pgm-reindex.txt
+++ b/Documentation/pgm-reindex.txt
@@ -36,9 +36,8 @@
Reindex only index with given name. This option can be supplied
more than once to reindex multiple indices.
---disable-cache-stats::
- Disables printing cache statistics at the end of program to reduce
- noise. Defaulted when reindex is run from init on a new site.
+--show-cache-stats::
+ Show cache statistics at the end of program.
== CONTEXT
The secondary index must be enabled. See
diff --git a/java/com/google/gerrit/pgm/Init.java b/java/com/google/gerrit/pgm/Init.java
index 19d19d4..0deb195 100644
--- a/java/com/google/gerrit/pgm/Init.java
+++ b/java/com/google/gerrit/pgm/Init.java
@@ -92,6 +92,9 @@
@Option(name = "--skip-download", usage = "Don't download given library")
private List<String> skippedDownloads;
+ @Option(name = "--show-cache-stats", usage = "Show cache statistics at the end")
+ private boolean showCacheStats;
+
@Inject Browser browser;
private GerritIndexStatus indexStatus;
@@ -164,7 +167,7 @@
indicesToReindex.add(schemaDef.getName());
}
}
- reindex(indicesToReindex, run.flags.isNew);
+ reindex(indicesToReindex);
}
start(run);
}
@@ -277,7 +280,7 @@
}
}
- private void reindex(List<String> indices, boolean isNewSite) throws Exception {
+ private void reindex(List<String> indices) throws Exception {
if (indices.isEmpty()) {
return;
}
@@ -288,8 +291,8 @@
reindexArgs.add("--index");
reindexArgs.add(index);
}
- if (isNewSite) {
- reindexArgs.add("--disable-cache-stats");
+ if (showCacheStats) {
+ reindexArgs.add("--show-cache-stats");
}
getConsoleUI()
diff --git a/java/com/google/gerrit/pgm/Reindex.java b/java/com/google/gerrit/pgm/Reindex.java
index 0eb1b67..993e00f 100644
--- a/java/com/google/gerrit/pgm/Reindex.java
+++ b/java/com/google/gerrit/pgm/Reindex.java
@@ -84,11 +84,9 @@
private List<String> indices = new ArrayList<>();
@Option(
- name = "--disable-cache-stats",
- usage =
- "Disables printing the cache statistics."
- + "Defaults to true when reindex is run from init on a new site, false otherwise")
- private boolean disableCacheStats;
+ name = "--show-cache-stats",
+ usage = "Show cache statistics at the end.")
+ private boolean showCacheStats;
private Injector dbInjector;
private Injector sysInjector;
@@ -120,7 +118,7 @@
try {
boolean ok = list ? list() : reindex();
- if (!disableCacheStats) {
+ if (showCacheStats) {
printCacheStats();
}
return ok ? 0 : 1;