eknkc / ssr-benchmark

Benchmarking JS web framework SSR performance
745 stars 172 forks source link

Add MFNG (minimal RSC library) benchmark #5

Closed unstubbable closed 1 month ago

unstubbable commented 1 month 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 1 month 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 1 month 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 1 month 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 1 month 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.