riot / ssr

Riot.js node Server Side Rendering
MIT License
32 stars 8 forks source link

ssr really that slow? #8

Closed SassNinja closed 2 years ago

SassNinja commented 5 years ago

I've been curious about the performance of riot ssr. After having found a ssr benchmark repo, I've forked it and added riot to the tests: https://github.com/SassNinja/ssr-benchmarks/tree/riot

I'm very surprised about the results because riot is much slower than any other library (more than 200x slower than svelte!)

Library Average Median Min Max Output Size
react 338.94ms 341ms 321ms 355ms 2719280
preact 64.34ms 60ms 53ms 124ms 2028387
preact-compat 144.88ms 142ms 129ms 183ms 2028328
inferno 81.06ms 78ms 67ms 111ms 3097513
inferno-compat 172.04ms 169ms 154ms 206ms 3097652
svelte 10.04ms 9ms 7ms 18ms 2036453
riot 2119.04ms 2119ms 2031ms 2277ms 1583486

Can you confirm riot ssr is not that fast or is there something wrong in my example riot tags? https://github.com/SassNinja/ssr-benchmarks/blob/riot/src/riot/App.riot

GianlucaGuarini commented 5 years ago

Having such a difference in the benchs means that probably there is a setup issue in your tests. For what I have quickly seen many of the tests use already compiled components while you render and compile riot components in runtime. Have you tried doing the same also with riot? Try to compile your components and then run the SSR

GianlucaGuarini commented 5 years ago

I was able to update the benchmarks and run them locally using benchmark.js that is a bit more reliable. I was then able to see that the Riot.js ssr render function is much slower than the other frameworks. I think the main reason is that I have used JSDOM for it and the order frameworks have implemented custom DOM serialization strategies.

For the sake of simplicity I think using JSDOM is still the easiest and most reliable solution for Riot.js but of course we can improve a lot the render function writing our custom DOM serialization mechanism.

At moment this feature is not on the top of my priorities but I accept help and contributions to improve it. In the end it shouldn't be that hard to replace JSDOM with cheeriojs or simple-dom.

GianlucaGuarini commented 2 years ago

@SassNinja it would be nice to see if this module is still slow compared to the alternatives. Could you please update the benchmarks? Thank you

GianlucaGuarini commented 2 years ago

closing this issue since no updates were provided.