-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(core): switch signals to a refcounting algorithm (#51226)
This commit switches the signals library from a bidirectional symmetric dependency graph using weak references, to a bidirectional _asymmetric_ graph which uses strong references. This is made possible with a reference counting algorithm which only tracks producer -> consumer references for effect-like "live" consumers, preventing memory leaks. The new algorithm should be simpler and faster than the previous implementation as weak references are fairly slow to create and traverse. A tradeoff is that non-live consumers must now poll their producers when read, as they cannot rely on dirty notifications. As part of this refactoring, the `ReactiveNode` class is replaced with an interface instead, and methods are moved to standalone functions. This is paired with instantiating individual signals/computeds via `Object.create` against a prototype node which contains static or initial values. This technique, in conjunction with the rest, greatly improves the performance of node creation. PR Close #51226
- Loading branch information
1 parent
7bb4f91
commit f56b655
Showing
26 changed files
with
1,019 additions
and
700 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.