eknkc / ssr-benchmark

Benchmarking JS web framework SSR performance
758 stars 171 forks source link

Add MFNG (minimal RSC library) benchmark #5

Closed unstubbable closed 7 months ago

unstubbable commented 7 months ago

It seems that the main reason Next.js isn't performing well is due to RSC itself, rather than the app router overhead.

Screenshot 2024-04-11 at 13 48 49

MFNG is a minimal React Server Components bundler & library

eknkc commented 7 months ago

I had to change import.meta.dirname to process.cwd() cause it was undefined for my node version. Maybe it is introduced pretty recently. Anyway.

I also added a duplication factor metric which measures how many times each uuid is observed in the response however it shows 2.5 for mfng which does not really make sense. My calculation code might be wrong.

unstubbable commented 7 months ago

import.meta.dirname was added with v20.11.0.

On my machine, it also shows 2.0 for MFNG:

(index) name ops/sec average (ms) samples body (kb) duplication relative to react
0 'react' 857 '1.166' 12862 '97.28' 'x1.00'
1 'sveltekit' 675 '1.479' 10140 '184.46' 'x2.00' '1.27 x slower'
2 'solid' 640 '1.561' 9607 '215.93' 'x2.00' '1.34 x slower'
3 'remix' 530 '1.884' 7963 '189.10' 'x2.00' '1.62 x slower'
4 'vue' 349 '2.858' 5249 '96.72' 'x1.00' '2.46 x slower'
5 'nuxt' 334 '2.993' 5012 '97.57' 'x1.00' '2.57 x slower'
6 'mfng' 68 '14.543' 1032 '282.15' 'x2.00' '12.60 x slower'
7 'next' 60 '16.609' 904 '284.64' 'x2.00' '14.28 x slower'
unstubbable commented 7 months ago

Ah, I still had a handler in dist that was built on my branch. On master with a fresh build, I also get 2.5. I'll have look into why...

unstubbable commented 7 months ago

Got it, one of the two UUIDs is also used as key for the table row. In the MFNG benchmark, a newer canary version of React is used that includes https://github.com/facebook/react/pull/28123. The Next.js benchmark on the other hand, uses an older canary version where the keys are null in the serialized RSC chunks.