-
Notifications
You must be signed in to change notification settings - Fork 191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Node.js vs Graal.js Performance #74
Comments
Hi @weixingsun thanks for your question. I am trying to understand what your benchmark script ( I can execute the application itself (
On that benchmark, GraalVM even outperforms Node. But note that your fib calculation blocks the event loop, so you can only do one calculation at a time, serve only one request at a time (you usually want to avoid exactly that when using Node.js) - all requests are serialized and calculated one after the other. So you are measuring hardly any Node.js/express code - this benchmark almost exclusively measures core JavaScript via the fibonacci calculation (for a 30 sec benchmark, only 28 iterations are run through Node.js/express; the time is spent in the I am using Can you please help me understand what you try to measure with the Best, |
@wirthi thanks for your reply, I just want to saturate a certain core in my server. which I can see they occupied 100% user cycles, which means I created a bottleneck on cpu3: 07:27:43 PM CPU %usr %nice %sys %iowait %irq %soft %steal %guest %gnice %idle |
oops, test_graal.sh is creating bottleneck on cpu 2, log above is for test_v8.sh |
We have two execution modes, "native" (default) and "JVM" (see https://www.graalvm.org/docs/reference-manual/languages/js/ for more information). Setting jvm options switches to the JVM. |
@woess Thanks for explaining the modes, but I got 186.197s after removing all the jvm options. what vm is underneath? Nashorn or GraalVM? perf record gave me following stacktraces: |
I was curious as well, so I figured I could provide a real life benchmark, running a webpack build. This was entirely unscientific and the tests were only run once. The results were surprising. Here are the relevant files: https://gist.github.com/EdwardDrapkin/d1b380787821462c5677323614f20146 The results wound up: Node 11:
Graal native:
Graal JVM:
Graal JVM with --jvm.XX:+UseG1GC:
|
thanks for sharing your benchmark. I am no expert on webpack - I guess the Note that, unlike the peak-performance benchmark weixingsun posted above, your's is heavy on startup - it's a one-time executed tool. If even original Node finishes that in 3 seconds, Graal-Node.js will have a hard time of keeping up with that. Graal-Node.js requires more time to JIT-compile the source code it gets. This makes it slower on workloads like If I could reproduce your run fully, I'd love to look into it and see if there is anything we can optimize for. Best, |
I can't provide the actual source code we use at work, but it's a fairly straightforward React project. You'd get similar results if you copied any react project in there. I will note that I switched the TS language service in IntelliJ to use GraalVM instead of NodeJS, and while it's exceptionally painful for a good long while, after about an hour it feels faster but AFAIK there's no way to benchmark proprietary IntelliJ plugins. |
Create a simple Nuxt.js project with selecting yarn package manager as default. And run |
Is startup performance not going to be considered? Having to run both graaljs and nodejs in parallel is going to be confusing. I thought the point of graal was to have 1 tool that does it all and have the interop? |
Hi @hc-codersatlas we are currently working on significant startup improvements by AOT-compiling larger parts of the Node.js codebase. This is a significant engineering effort though, so it takes a while. Best, |
Hey, i'm also interested in it. I've just measured node.js vs graalvm's node performance and the latter is 10-20x slower. graalvm-ee-19.1.1 |
Is this for startup or peak performance? Can you share the workload as suggested? |
Hi, Thomas. Thanks for reply. It's rough time of execution in millis of exactly the same code on node and graalvm's node (startup time excluded from measurement). It includes processing of stdin, parsing (string + regexp operations mostly), objects instantiating and calling object methods with some business logics. I think i will be able to provide the code, will doublecheck it. |
Just run
or graalvm node on PATH, eg:
It will clone required JS code, prepare data and run benchmarking, see actual execution time. |
Hi @4ntoine thanks for your code. I confirm we can execute it and measure performance. Your benchmark does not consider warm-up. To mitigate that, you can put a loop around the core of your benchmark (lines 153ff in benchmark.js) and measure each iteration independently - however, that might not give exact results due to caching in the code. We are working on some micro-benchmarks to better measure the performance. But it seems we are within 2.5X of origin Node if you account for the warmup. Also, note that running in JVM mode ( We'll get back to you once we know more. Also, improving our warmup performance is high up our list, so that should get better over the next releases. Best, |
Hey. Thanks for the update.
Yup, there is some caching and i can modify it to avoid side effect of caching for better benchmarking.
Does it mean you target to have 2.5x worse performance compared to Node? |
Our target is to be at least comparable speed or better for any workload. This is a longterm target however and we aren't there yet for Node.js applications. |
Running It takes around 15minutes to start compiling and I didn't wait after that. Stock node does that in around ~2 minutes. |
I think it should maybe get documented that node-graalvm is not as optimized at present as it could be and that at present the startup time is higher and the performance is slower for none long-running processes. so that not everyone is shocked. |
Agreed that we should put the information on startup into the documentation. On peak performance it is not so clear as there are also workloads where we are faster. |
I note that there are cases where GraalVM Node.js performs slower than Node.js after many iterations of the same task, which does not appear to be caused by start up time. I created a repo that illustrates that GraalVM performs slower than Node.js at:
I hope you will find it useful: https://github.com/Ivan-Kouznetsov/graalvm-perf |
@ivan you need to calculate that right NodeJS will most time be faster in that cases but when you replace Regex with the Regex from java and the JSONParser and Query Element with the Java one and the HTTPGet Method with that from Java you outperform NodeJS by Far. |
Are we there at the moment? Any benchmarks/comparisons available? Thanks |
@4ntoine the state is still the same everything that uses nodejs modules from node-graaljs is slower if you use Only Java or Javascript it is faster. |
thanks for your benchmarks, they provide relevant insight! And they show the fundamental misconception, which is
1000 iterations of something is not "many" in the JIT world. As per your documentation (original) Node.js would need 0.120s for the full jsonpath-classic-benchmark.js. GraalVM is in the Java world - and there, it would take a few hundred milliseconds to even start the JVM, let alone execute the benchmark. Thanks to native-image, we can be faster on GraalVM, but the same basic principle still applies: we need to JIT-compile the code, and that won't fully happen within 120 milliseconds. I've hacked some proper warmup into your benchmark, like this (e.g. for
Basically, I am executing your full benchmark repeatedly, and print out how long each iteration takes: GraalVM EE 20.3.0
compared to Node.js 12.18.0
Admitted, GraalVM's first 2 iterations are horrible. Iterations 3 and 4 are in the ballpark of V8. Starting with iteration 5, GraalVM is actually significantly (around 25%) faster than V8. There's one more trick up our sleeve. In On the On Best, |
@wirthi #360 (comment) maybe makes this obsolet as this performance degradations are now less a problem then before. Even npm is now not freezing anymore the string update is a hugh one combined with the new default boot mode |
It would be cool if the jvm cached the generated binary from each class so that the warmup only would happen once and not on each program restart. |
Dude,
I came across GraalVM and have a glance at the JVM options part, and thought it is promising,
But I found that the performance is much lower than latest Node.js, here is the result:
https://github.com/weixingsun/perf_tuning_results/blob/master/Node.js%20vs.%20GraalVM
Any idea about the difference?
The text was updated successfully, but these errors were encountered: