Poor performance on context mutation. #3757
-
|
Hello, Happy new year everyone! We had to do an audit about state a management library for our svelte applications. Performance was mandatory. We started by auditing 3 libraries (more to come) and we did a very quick and dirty perf test where XState registered very low performance when adding 200000 new element to an array. I'd really wanted to work with
Here the repository if you want to look into the code: |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
|
Thanks for the benchmark. There is a plan for improvement: since transitions are deterministic, we can "cache" transitions so that instead of looking through the state node tree to determine what the enabled transitions are, we'd already know them. That way, the only cost is what happens in So the comparison that needs to be made is Also, you can use Performance is something that we'll tackle when we've finalized the API changes for v5 👍 |
Beta Was this translation helpful? Give feedback.
-
|
Just wanted to point out that this benchmark feels like it is not fairly comparing xstate and immer in particular. If you are using a single |
Beta Was this translation helpful? Give feedback.

Thanks for the benchmark. There is a plan for improvement: since transitions are deterministic, we can "cache" transitions so that instead of looking through the state node tree to determine what the enabled transitions are, we'd already know them. That way, the only cost is what happens in
assign(...).So the comparison that needs to be made is
arr.concat(...)vs. the other techniques, in this case.Also, you can use
immerwith XState instead ofarr.concat(...); not sure how much that would make a difference though.Performance is something that we'll tackle when we've finalized the API changes for v5 👍