Wr/fix heap oom large custom labels @W-21251439@#1795
Draft
WillieRuemmele wants to merge 4 commits into
Draft
Conversation
…r-child Previously initMergeMap called child.parseXml() for each child, which re-parsed the entire parent XML file (e.g. 31K lines) for every one of 3,945 children. Now parses each parent once and extracts children directly from the parsed result.
Verifies correctness of multi-package merge with deduplication: - Labels unique to each package are preserved - Shared labels (same fullName) are deduplicated - First-encountered definition wins on conflicting content
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
What issues does this PR fix or reference?
#, @W-21251439@
Functionality Before
<insert gif and/or summary>
Functionality After
<insert gif and/or summary>
Metadata Registry: Successful Deploy and Retrieve (required if applicable)
Deploy output:
<paste CLI output and/or screenshot>
Retrieve output:
<paste CLI output and/or screenshot>
Summary of Changes
Problem
When multiple package directories contain the same
CustomLabelsfile (common in multi-package projects), the recomposition finalizer (source→metadata conversion for deploy) was accumulating duplicate children. With large label files across 2-3 packages, this caused the merged output to double or triple in size, leading to heap OOM crashes.Fix:
recompositionFinalizer.tsAdded
deduplicateChildren()— when the same label (keyed bytype.name#fullName) appears from multiple packages, only the first occurrence is kept. This is safe because:CustomLabels.labelsis an ephemeral artifact for deploy (zipped and sent to the org, never written to disk).nonDecompositionFinalizer, which writes labels back to their respective package directories — users never see git diffs.Fix:
nonDecompositionFinalizer.tsRefactored
initMergeMapto parse each parent XML file once and extract all children directly, rather than re-parsing the parent for every individual child component. This eliminates redundant XML parsing that scaled quadratically with label count.Snapshot diff (~16k lines)
The
customLabels-multipletest snapshot went from 32,918 lines to 16,471 — almost exactly halved. The test data has labels across 2 packages (second-appandthird-app) with largely identical content, so the old behavior was duplicating nearly every entry. The ~92 "additions" in the diff are ordering artifacts from the dedup changing sort positions, not new labels.New test:
customLabels-mergedA focused snapshot test with small synthetic data (3 packages, 8 unique labels, 2 shared across packages) to verify the dedup behavior explicitly without relying on the large real-world test data.