Intern unresolved symlink targets (#31122) `UnresolvedSymlinkAction` interns its destination string in the constructor. Actions with the same destination share string storage without changing the raw target value, action key, or deferred `PathFragment` conversion. One matched pair of partial monorepo analyses retained 3.27 million fewer strings and backing arrays, accounting for about 664 MB in the class histogram. Reported after-GC heap was 676 MB lower; analysis time and peak RSS were essentially unchanged. This is a single comparison, not a repeatability claim. Validation on upstream master: all six `UnresolvedSymlinkActionTest` cases pass, covering action keys, symlink creation, and serialization. RELNOTES: None -zbarskybot Closes #31122 COPYBARA_INTEGRATE_REVIEW=https://github.com/bazelbuild/bazel/pull/31122 from dzbarsky:codex/symlink-targets-upstream 9f444949636d5a953d7ad10c3bc8f978f79988ce PiperOrigin-RevId: 981263379 Change-Id: I0e825a11a001568b5c19e83b81c8e70959bdc905
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/starlark/UnresolvedSymlinkAction.java b/src/main/java/com/google/devtools/build/lib/analysis/starlark/UnresolvedSymlinkAction.java index c0d81f7..43ab770 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/starlark/UnresolvedSymlinkAction.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/starlark/UnresolvedSymlinkAction.java
@@ -58,7 +58,7 @@ SymlinkTargetType targetType, String progressMessage) { super(owner, NestedSetBuilder.emptySet(Order.STABLE_ORDER), ImmutableSet.of(primaryOutput)); - this.target = target; + this.target = target.intern(); this.targetType = targetType; this.progressMessage = progressMessage; }