Fix unnecessary reruns after read signal coercion#5475
Open
ealmloff wants to merge 29 commits into
Open
Conversation
Move the wrapped readable, the wrapper-level subscriber list, and the forwarding reactive context into one shared `ReadSignalInner` allocation so creating a wrapper costs the same one generational-box reference as a bare `Signal`. This keeps `test_for_memory_leaks` passing on the props-macro coercion path that constructs a fresh `ReadSignal` per render: peak memory stays flat across 10000 iterations. `point_to` moves the wrapped readable out of `other.inner` via `Option::take` and releases `other.inner` immediately, instead of using `CopyValue::point_to` and leaking the new wrapper's state. Subscribers and the forwarding context are lazily initialized so wrappers that are never read pay nothing extra; the forwarding callback captures the `Subscribers` handle directly so it remains `Send + Sync` regardless of the wrapper's storage type. Fixes clippy warnings in the new tests.
# Conflicts: # packages/signals/src/boxed.rs # packages/signals/tests/memo.rs
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.
Instead of moving and marking all reactive contexts as dirty when the source of the ReadSignal changes, this pr limits the scope to just the contexts that where explicitly used with the boxed version
Fixes #5474