DaniilSokolyuk / NodeReact.NET

Library to render React library components on the server-side with C# as well as on the client.
MIT License
43 stars 5 forks source link

Need help in understanding performance #6

Closed xtroncode closed 3 years ago

xtroncode commented 3 years ago

Hi, We were planning to move our dotnet core application that renders react on the server using ReactJS.Net to linux, for which we switched from using JavaScriptEngineSwitcher.V8 to JavaScriptEngineSwitcher.ChakraCore but were facing some issues with ChakraCore.

So as per @Taritsyn 's suggestion We tried out JavaScriptEngineSwitcher.Node . While JavaScriptEngineSwitcher.Node is working fine on linux, the performance when compared to JavaScriptEngineSwitcher.V8 is not good (p50 of ~90ms on V8 vs p50 of ~160ms on Node) for rendering our webpages.

We are unable to use NodeReact.NET due to #5 .

As per this the above observation is correct but the benchmarks provided in NodeReact.NET prove otherwise that better performance can be achieved with Node.

I would like to understand why NodeReact.NET has better performance than ReactJS.Net + JavaScriptEngineSwitcher.Node. Is it because of using workerpool ? or something else.

Thanks.

DaniilSokolyuk commented 3 years ago

@xtroncode Hi, sorry for the late reply, NodeReact.NET has better performance because it fully async and managed thread can do other work and not wait for the render, also i am reuse allocated memory which causes much fewer garbage collections. Also it uses node.js (out of process) with worker threads, rendering is cpu bound operation and it helps

DaniilSokolyuk commented 3 years ago

I will do #5 when i have vacation. But when using render functions, performance can drop significantly because it will require much more allocation

xtroncode commented 3 years ago

Hi @DaniilSokolyuk , Thanks for the reply. We have already started using JavaScriptEngineSwitcher.Node and are able to get an equivalent performance to V8 . The metrics metioned in my question are incorrect, I had later figured out an issue in my environment which was causing high render times. Thanks again.

DaniilSokolyuk commented 3 years ago

@xtroncode main problem in ReactJS.NET +JavaScriptEngineSwitcher.Node is not performance, main problem is sync call JavaScriptEngineSwitcher.Node and threadpool starvation