chore: improve signal performance by reducing duplicate deps
#14945
Pull request
This PR introduces read versioning, which is different from write versioning (the existing version naming has been updating to be wv respectfully). When we read a signal in a given reactive context we can provide it a read version. This provides us a benefit in that if we have duplicate reads of the same signal, we avoid populating the same signal many X times in the same reaction's dependencies. This is actually significant in many stress-cases where you might read a[x] in a loop, where a a is a signal. If x is 10000, we end up with 10k of a as a dependency, when only a single is satisfactory.
This optimisation adds an extra field to source and derived signals, which is probably worth while given the real-world implications of having a huge reactive dependency array and reactive graph because of additional re-visits.
In terms of of our reactive benchmark the benefits are clear:
Before:
After:
Info
🦋 Changeset detected
Latest commit:
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 1 package
| Name | Type |
|---|---|
| svelte | Patch |
Not sure what this means? Click here to learn what changesets are.
pnpm add https://pkg.pr.new/svelte@14945preview: https://svelte-dev-git-preview-svelte-14945-svelte.vercel.app/
this is an automated message