bnoordhuis / v8-cmake

The V8 JavaScript engine, but built with CMake instead of GN - WIP
BSD 3-Clause "New" or "Revised" License
183 stars 52 forks source link

10x slowdown when compared to chrome? #78

Open Alloyed opened 9 months ago

Alloyed commented 9 months ago

using this test on my local machine, with a locally built copy of d8.exe (on windows MSVC, cmake --build . --config Release): https://gist.github.com/Alloyed/cc525d0baf56697f856f389e35335b2b

$ ./d8.exe
V8 version 11.5.150.2
d8> load("nbody.js")
runNBody()...
runNBody(): 29.878999999999905 ms
undefined
d8>

Doing the same test in my locally installed copy of chrome: https://jsfiddle.net/Lxtfun0b/

☁️ "Running fiddle"
"runNBody()..."
"runNBody(): 3.699999988079071 ms"

My first guess is that the currently used gn build flags are not the same as chrome uses in production, but just wanted to flag this before I start investigating.

bnoordhuis commented 9 months ago

Could be, or it's just differences in V8 versions. They tweak their heuristics continually and micro benchmarks that complete in under a second are unlikely to reach a JIT steady state.

Use https://github.com/v8/web-tooling-benchmark/ for something more representative.

dnets commented 5 months ago

Noticed this too. This is really bad compared to Chrome. @Alloyed have you managed to investigate? I've used simple for(i=0; i<100000000; i++) {let b = new Object()} And it's around 2800ms for v8-cmake's d8 vs Chrome's 150ms

Daninet commented 2 months ago

I had a look into the issue, and I realized that the TurboFan optimizing compiler of v8 is turned off. Here is my fix: https://github.com/bnoordhuis/v8-cmake/pull/83 D8's performance now is similar to Chrome on my computer.