Feature/improve performance#26
Merged
Merged
Conversation
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.
Description
Rewrites the reactivity core subscription graph for performance.
SubNodeedges replace the previousSet<Subscriber>+Map<Signal, epoch>storage. Each (signal, subscriber) pair is now one object linked into both the signal's subscriber list and the subscriber's dep list. O(1) subscribe and unsubscribe via pointer splice, no hash operations on the hot path, one allocation per edge instead of two.signal.__activeNodeback-pointer (Preact Signals' approach) givesrecordDependency()O(1) duplicate-dependency detection. A subscriber with 10 000 deps no longer pays O(N²) in its inner loop.retrack()instead oftrack(). Stable-dep effects skip the full cleanup-and-rebuild cycle; epoch-based pruning handles dropped deps.EffectCtxobject — per-effect closure count went from six to three.track()is stack-free — localprev/restore replaces the sharedsubscriberStack.suspend/resumeTrackingnow capturecurrentSubscriberdirectly.cleanup,getSubscriberCount,getSubscriberDeps,forEachSubscriber.__s,__f,subscriberStack(all undocumented, underscore-prefixed).Improvements over 2.1.0 on the reactivity stress-test suite:
2187/2187 tests passing. No breaking changes to the documented public API (
signal,derived,effect,batch,untracked,on, devtools helpers — all behave identically).Related Issue
Closes #
Type of Change
Checklist