You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The goal of `alien-signals` is to create a ~~push-pull~~[push-pull-push model](https://github.com/stackblitz/alien-signals/pull/19) based signal library with the lowest overhead.
18
-
19
-
We have set the following constraints in scheduling logic:
11
+
-[YanqingXu/alien-signals-in-lua](https://github.com/YanqingXu/alien-signals-in-lua): Lua implementation of alien-signals
12
+
-[medz/alien-signals-dart](https://github.com/medz/alien-signals-dart): alien-signals Dart implementation of alien-signals
13
+
-[Rajaniraiyn/react-alien-signals](https://github.com/Rajaniraiyn/react-alien-signals): React bindings for the alien-signals API
14
+
-[CCherry07/alien-deepsignals](https://github.com/CCherry07/alien-deepsignals): Use alien-signals with the interface of a plain JavaScript object
20
15
21
-
1. No dynamic object fields
22
-
2. No use of Array/Set/Map
23
-
3. No recursion calls
24
-
4. Class properties must be fewer than 10 (https://v8.dev/blog/fast-properties)
16
+
# alien-signals
25
17
26
-
Experimental results have shown that with these constraints, it is possible to achieve excellent performance for a Signal library without using sophisticated scheduling strategies. The overall performance of `alien-signals`is approximately 400% that of Vue 3.4's reactivity system.
18
+
This project explores a push-pull based signal algorithm. Its current implementation is similar to or related to certain other frontend projects:
27
19
28
-
For more detailed performance comparisons, please visit: https://github.com/transitive-bullshit/js-reactivity-benchmark
- Graph-coloring approach of Reactively (https://milomg.dev/2022-12-01/reactivity)
29
24
30
-
## Motivation
25
+
We impose some constraints (such as not using Array/Set/Map and disallowing function recursion) to ensure performance. We found that under these conditions, maintaining algorithmic simplicity offers more significant improvements than complex scheduling strategies.
31
26
32
-
To achieve high-performance code generation in https://github.com/vuejs/language-tools, I needed to write some on-demand computed logic using Signals, but I couldn't find a low-cost Signal library that satisfied me.
27
+
Even though Vue 3.4 is already optimized, alien-signals is still noticeably faster. (I wrote code for both, and since they share similar algorithms, they’re quite comparable.)
33
28
34
-
In the past, I accumulated some knowledge of reactivity systems in https://github.com/vuejs/core/pull/5912, so I attempted to develop `alien-signals` with the goal of creating a Signal library with minimal memory usage and excellent performance.
Since Vue 3.5 switched to a Pull reactivity system in https://github.com/vuejs/core/pull/10397, I continued to research the Push-Pull reactivity system here. It is worth mentioning that I was inspired by the doubly-linked concept, but `alien-signals` does not use a similar implementation.
31
+
## Background
37
32
38
-
## Adoptions
33
+
I spent considerable time [optimizing Vue 3.4’s reactivity system](https://github.com/vuejs/core/pull/5912), gaining experience along the way. Since Vue 3.5 [switched to a pull-based algorithm similar to Preact](https://github.com/vuejs/core/pull/10397), I decided to continue researching a push-pull based implementation in a separate project. Our end goal is to implement fully incremental AST parsing and virtual code generation in Vue language tools, based on alien-signals.
39
34
40
-
- Used in Vue language tools (https://github.com/vuejs/language-tools) for virtual code generation.
35
+
## Adoption
41
36
42
-
- The core reactivity system code was ported to Vue 3.6 and later. (https://github.com/vuejs/core/pull/12349)
37
+
-[vuejs/core](https://github.com/vuejs/core): The core algorithm has been ported to 3.6 or higher (PR:https://github.com/vuejs/core/pull/12349)
38
+
-[vuejs/language-tools](https://github.com/vuejs/language-tools): Used in the language-core package for virtual code generation
In order to eliminate recursive calls and improve performance, we record the last link node of the previous loop in `propagate` and `checkDirty` functions, and implement the rollback logic to return to this node.
@@ -92,25 +95,26 @@ This results in code that is difficult to understand, and you don't necessarily
0 commit comments