Skip to content

Commit

Permalink
Shrink interners after Skyfocus.
Browse files Browse the repository at this point in the history
Additional -530.5MB, -24.0% retained heap reduction for test project.

PiperOrigin-RevId: 625941947
Change-Id: I9b0a326a9567f50ce34701b8d64c2ed5e5e69e65
  • Loading branch information
jin authored and Copybara-Service committed Apr 18, 2024
1 parent a119dd3 commit 076494c
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@
import com.google.devtools.build.lib.cmdline.TargetParsingException;
import com.google.devtools.build.lib.concurrent.ExecutorUtil;
import com.google.devtools.build.lib.concurrent.NamedForkJoinPool;
import com.google.devtools.build.lib.concurrent.PooledInterner;
import com.google.devtools.build.lib.concurrent.QuiescingExecutor;
import com.google.devtools.build.lib.concurrent.QuiescingExecutors;
import com.google.devtools.build.lib.concurrent.ThreadSafety;
Expand Down Expand Up @@ -4153,6 +4154,12 @@ public final void runSkyfocus(Reporter reporter, ActionCache actionCache)
.withRequest(Request.DO_NOTHING)
.withVerificationSet(focusResult.getVerificationSet());

// Now that the graph has dropped nodes, run a GC to reclaim some memory.
System.gc();
// Next, shrink the interners' backing maps - which now have larger
// capacities than necessary - and reclaim some more memory.
PooledInterner.shrinkAll();

dumpSkyfocusKeys(dumpKeysOption, reporter, focusResult, graph, skyFunctionCountBefore);

reportReductions(
Expand All @@ -4170,9 +4177,6 @@ public final void runSkyfocus(Reporter reporter, ActionCache actionCache)
Long::toString);

if (skyfocusState.options().dumpPostGcStats) {
System.gc();
// Users may skip heap size reporting, which triggers slow manual GCs, in place of faster
// focusing.
reportReductions(
reporter, "Heap", beforeHeap, getHeapSize(), StringUtilities::prettyPrintBytes);
}
Expand Down

0 comments on commit 076494c

Please sign in to comment.