Skip to content

Performance improvements to cache - #1659

Merged
AlecAivazis merged 28 commits into
houdini-2.0from
perf
Jun 14, 2026
Merged

Performance improvements to cache#1659
AlecAivazis merged 28 commits into
houdini-2.0from
perf

Conversation

@AlecAivazis

Copy link
Copy Markdown
Collaborator

Fixes an O(n²) hot path in writeSelection that became expensive on records with many fields. Typical operations are ~40% faster; wide records (100+ fields) see much larger gains (253x for some benchmarks).

Also adds a benchmark CI job that runs on every PR touching the cache, so regressions are caught automatically.

Three hot-path changes: dedicated typename map on InMemoryStorage (O(1)
lookup instead of full layer traversal), toNotify as Set<SubscriptionSpec>
in writeSelection (dedup at add time, avoids FieldSelection tuple overhead),
and memoized getFieldsForType via WeakMap (O(1) for repeated selection+type
pairs).

Benchmark CI now runs 3× on each branch sequentially on the same runner and
takes the median, so comparisons are machine-stable. Benchmark selections
hoisted to module scope so the getFieldsForType memo actually hits.
Longer per-benchmark time reduces RME at the source; adaptive thresholds
in compare.js absorb the remaining noise, so the 3-run median is no longer needed.
@changeset-bot

changeset-bot Bot commented Jun 14, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 4622e69

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@AlecAivazis
AlecAivazis merged commit ffedd79 into houdini-2.0 Jun 14, 2026
23 of 25 checks passed
@AlecAivazis
AlecAivazis deleted the perf branch June 14, 2026 08:44
AlecAivazis added a commit that referenced this pull request Jun 19, 2026
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
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.

1 participant