Skip to content

Reuse name sets when enumerating union and intersection properties - #64817

Closed
Jake Bailey (jakebailey) wants to merge 1 commit into
jakebailey/mem/small-property-source-setsfrom
jakebailey/mem/reused-property-name-sets
Closed

Jake Bailey (jakebailey) wants to merge 1 commit into
jakebailey/mem/small-property-source-setsfrom
jakebailey/mem/reused-property-name-sets

Conversation

@jakebailey

@jakebailey Jake Bailey (jakebailey) commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

Enumerating the properties of a union or intersection allocates a fresh set of already-combined names each time; on large projects those short-lived sets are a sizable share of all allocated bytes.

  • Borrows the set from a per-checker free list. Enumeration can recurse into other combined types, so each call still takes its own set.
  • MUI measurements showed 6.76% fewer allocated bytes and 0.60% fewer allocations.
  • Retained heap did not materially change.

Part of the memory optimization stack summarized in #64734.

@typescript-automation typescript-automation Bot added Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Oct 14, 2026
@jakebailey
Jake Bailey (jakebailey) added this pull request to stack #64806 October 14, 2026 14:20
@jakebailey Jake Bailey (jakebailey) changed the title Reuse name sets when enumerating combined type properties Reuse name sets when enumerating union and intersection properties Oct 14, 2026
Enumerating the properties of a union or intersection tracks which
names have already been combined. A fresh set is allocated for every
enumeration, and on large projects those sets account for a sizable
share of all allocated bytes, adding GC work for no lasting benefit.

Borrow the set from a per-checker free list instead. Enumeration can
recurse into other combined types, so each call still takes its own
set.

mui-docs:

          │    before    │               after                │
          │ allocated-B  │ allocated-B   vs base              │
  MUIDocs   4.389Gi ± 1%   4.092Gi ± 0%  -6.76% (p=0.002 n=6)

          │   before    │               after               │
          │   allocs    │   allocs     vs base              │
  MUIDocs   23.32M ± 1%   23.18M ± 0%  -0.60% (p=0.002 n=6)
@jakebailey
Jake Bailey (jakebailey) force-pushed the jakebailey/mem/reused-property-name-sets branch from da7313e to 1526143 Compare October 14, 2026 16:02
@jakebailey
Jake Bailey (jakebailey) removed this pull request from stack #64806 October 14, 2026 16:55
@jakebailey

Copy link
Copy Markdown
Member Author

Folded into #64815.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Author: Team For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant