Skip to content

perf(fetchium): brand wrapped values with a base class instead of a WeakSet - #92

Merged
abedell-phantom merged 1 commit into
mainfrom
perf/wrapped-value-brand
Nov 6, 2026
Merged

abedell-phantom merged 1 commit into
mainfrom
perf/wrapped-value-brand

Conversation

@abedell-phantom

Copy link
Copy Markdown
Contributor

Why

Every FormattedValue and LiveCollectionBinding added itself to the WRAPPED_VALUE WeakSet in its constructor: one entry per formatted field value for as long as the value lived. Hermes walks every WeakSet entry slot on each young GC and keeps those lists at their peak size.

What

  • Both classes extend an abstract WrappedValue and are recognized with instanceof; the WeakSet is gone. Neither registry was exported.

Evidence

Hermes heap snapshots of a large React Native app (Android emulator, release bundle, a list-heavy screen switched 10 times): WeakSet entries 14.5k → 0.1k. wrapped-value-brand.test.ts covers formatted values reading through without a WeakSet registration.

…eakSet

Every FormattedValue and LiveCollectionBinding added itself to the
WRAPPED_VALUE WeakSet in its constructor, one entry per formatted field
value for as long as the value lived. Both now extend an abstract
WrappedValue class and are recognized with instanceof.
@abedell-phantom
abedell-phantom requested review from a team and pzuraq as code owners November 6, 2026 00:24
@abedell-phantom
abedell-phantom merged commit 73c55a5 into main Nov 6, 2026
1 check passed
@abedell-phantom
abedell-phantom deleted the perf/wrapped-value-brand branch November 6, 2026 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants