Svelte v5 runes benchmark results & discussion 🔥 #13277
Replies: 5 comments 13 replies
-
Thanks for looking into this!
I need to do an investigation into this, as it might be something we're doing wrong or maybe something with how the adapter is setup. I'll get back to you.
We've spent a lot of time tuning our signals implementation for optimal memory and runtime performance. I've spent a lot of time looking at V8 deopts and the team has spent significant time cleaning up and simplifying hot code paths.
We have our own benchmark on the repo that was adapted from the reactivity benchmark. Just run
That would be useful, but ultimately every framework does deep reactivity quite differently so it might not really be a fair comparison.
We have no intentions of exposing our internal signals API in the public domain. Signals aren't really the important thing here either, and that's awesome because it allows us to change our signals architecture freely without having to release new majors of Svelte. It also afford us the ability to move to the TC39 signals once it's stable, or to throw our signals entirely in the case we find a better reactivity subsystem in the future. |
Beta Was this translation helpful? Give feedback.
-
So I figured the issue, it was indeed in the adapter. Try this one instead; export const svelteFramework: ReactiveFramework = {
name: "Svelte v5",
signal: (initialValue) => {
const s = $.state(initialValue);
return {
write: (v) => $.set(s, v),
read: () => $.get(s),
};
},
computed: (fn) => {
const c = $.derived(fn);
return {
read: () => $.get(c),
};
},
effect: $.render_effect,
withBatch: $.flush_sync,
withBuild: <T>(fn: () => T): T => {
let res: T | undefined;
$.effect_root(() => {
$.render_effect(() => {
res = fn();
});
});
return res!;
},
}; |
Beta Was this translation helpful? Give feedback.
-
I noticed React.js isn't included. Given its widespread use and importance in the development community, could you consider adding React.js to the benchmarks for a more comprehensive comparison? |
Beta Was this translation helpful? Give feedback.
-
I would be curious to see how this compares to Svelte 4's reactivity, would that be possible? |
Beta Was this translation helpful? Give feedback.
-
Guys, I suppose you all know this page? https://krausest.github.io/js-framework-benchmark/current.html It was updated to include Svelte v5. As of today, it runs v5.0.5. Unsure if the Svelte team has contributed to this effort, but would be nice if:
Cheers! |
Beta Was this translation helpful? Give feedback.
-
(lower times are better)
I've been working on a deep-dive comparison of the best TS reactivity libs.
During this, I created a fork of the JS reactivity benchmark and added Svelte v5.
I've been in touch with @trueadm to verify that my Svelte v5 adapter looks good.
To my surprise, Svelte v5 outperformed all other reactivity libs by quite a solid margin on all benchmark tests except the
cellx
ones.I have some follow-up questions, so I figured I'd open up the discussion to more of the Svelte community.
The
cellx
benchmark tests are the only ones where Svelte v5 performs significantly worse than all of the other frameworks (~100x slower). They're not included in the average benchmark graph because MobX fails to run them correctly at all. Perhaps this usage pattern is something worth looking into as a potential perf pitfall in Svelte?Do these results match your team's expectations? I was honestly quite surprised and excited by how much faster Svelte v5 was compared with the rest of the field.
I'd love to understand why Svelte v5 is performing so well on these benchmarks. Do you have any up front ideas as to why this may be the case, whether they be algorithmic or more practical optimizations?
These benchmarks currently only focus on deep dependency trees of shallow primitives. I'd love to add some benchmarks of deeply nested reactive objects / arrays / maps / sets for the frameworks which support them. Thoughts?
Lastly and most importantly, I think it's a shame that Svelte v5's reactivity isn't packaged for standalone usage but rather exposed as an unofficial, internal API. Would you consider an RFC to isolate the core reactivity ala
@vue/reactivity
?For context, my deep-dive on this was inspired by the TC39 Signals Proposal, which is why I'm looking to understand what aspects of the best TS reactivity libs ala Svelte v5 could potentially be backported into the proposal or polyfill.
Thanks! 🙏
Beta Was this translation helpful? Give feedback.
All reactions