Repository navigation
perf(core): sort integrations once per rebuild - #59402
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Looks correct. State.create builds a fresh integrations Map on every rebuild and never changes it after publishing, so caching the sorted entries on the Map's identity can't go stale. project() takes name straight from ref.name, so list() returns the same order and shape as before. In packages/core, the integration and provider tests pass and typecheck:tsc is clean.
Public API: unchanged.
1 task
This was referenced Oct 29, 2026
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.
Problem
Integration.list()re-sorted every integration by name withlocaleCompareon each call.Provider.snapshot()calls it on every model lookup (a few times per step) and turns the result straight into a Map, so that sort was mostly wasted work. The integration definitions only change when the integration state is rebuilt.Change
I sort the entries once per rebuilt state, memoized on the identity of
state.get().integrations(each rebuild produces a new Map), andlist()just maps over the sorted entries.The sort key is the same:
project()takesnamestraight fromentry.ref.nameand credentials never change it, andtoSortedis stable, so the output order and shape are identical to before.With 100 registered integrations and no credentials, a quick local benchmark went from about 126 µs to 43 µs per
list()call.Out of scope
Credential reads in
list()and howProvider.snapshot()consumes the result are unchanged.