I'm running my Z80 emulator both in Chrome and in Node. I get about 10x the performance in Chrome that I do in Node. (100k Z80 instructions take 6 ms in Chrome and 60 ms in Node.) I've run the profiler:
% node --prof index.js
% node --prof-process isolate-0x108000000-25550-v8.log
and it says that 95% of the time is spent in C++:
[Summary]:
ticks total nonlib name
103 3.8% 3.8% JavaScript
2604 95.2% 95.8% C++
6 0.2% 0.2% GC
17 0.6% Shared libraries
12 0.4% Unaccounted
The C++ breakdown is:
[C++ entry points]:
ticks cpp total name
2127 98.3% 77.7% T __ZN2v88internal40Builtin_CallSitePrototypeGetPromiseIndexEiPmPNS0_7IsolateE
32 1.5% 1.2% T __ZN2v88internal21Builtin_HandleApiCallEiPmPNS0_7IsolateE
I've tracked down CallSitePrototypeGetPromiseIndex
to this source file. I'm not using promises, async
, or await
in my code. My test is just a tight loop of 100k emulated Z80 instructions, no I/O or anything.
I've found others online using the --prof
flag and none are finding this in their results. Is it a side-effect of profiling? Am I triggering promises somehow inside the loop? Any reason Node should be this much slower than Chrome?
Details: Node v12.13.1, Chrome 79.0.3945.88.