Skip to content
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

Slow start on ARM #16955

Closed
peoro opened this issue Nov 11, 2017 · 6 comments
Closed

Slow start on ARM #16955

peoro opened this issue Nov 11, 2017 · 6 comments
Labels
arm Issues and PRs related to the ARM platform. performance Issues and PRs related to the performance of Node.js.

Comments

@peoro
Copy link

peoro commented Nov 11, 2017

I have a Raspberry Pi Zero W (ARMv6) and an Odroid-C2 (ARMv8), both running Arch Linux ARM.
On these systems node has pretty high startup times.

Latest official binary release of node, 9.1.0

I'm running the latest official binary release of node (9.1.0), as the binary installed from the repositories is way way slower (more on this later).

Node is slow to start on those systems:

Raspberry Pi Zero W (ARMv6)

$ time node -v       # printing node version: as fast as it should be
v9.1.0
real    0m0.052s
user    0m0.030s
sys     0m0.000s
$ time node -e ''    # running empty script: pretty slow
real    0m1.394s
user    0m1.180s
sys     0m0.060s
$ time npm -v        # printing npm version: slow
5.5.1
real    0m3.881s
user    0m3.410s
sys     0m0.210s
$ time python2 -c '' # python2 empty script, as a comparison
real    0m0.281s
user    0m0.240s
sys     0m0.030s

Odroid-C2 (ARMv8)

$ time node -v       # printing node version - as fast as it should be
v9.1.0
real    0m0.009s
user    0m0.000s
sys     0m0.000s
$ time node -e ''    # running empty script - ok
real    0m0.270s
user    0m0.240s
sys     0m0.020s
$ time npm -v        # printing npm version - slowish
5.5.1
real    0m0.868s
user    0m0.760s
sys     0m0.100s
$ time python2 -c '' # python2 empty script, as a comparison
real    0m0.049s
user    0m0.020s
sys     0m0.020s

nodejs packaged by Arch Linux ARM

The nodejs (v8.8.1) binary packaged by the Arch Linux ARM project is way way slower than the mainstream released binary. An empty script takes longer than 7 seconds (!) and npm -v something like 15 seconds (!!) on my ARMv6 machine. I reported the issue on ALARM forum.

Yesterday I started looking into that (profiling, stracing, testing various v8 flags etc) and collected a bunch of data before realizing that the upstream release is not that bad. I couldn't get perf working and couldn't understand what's going on with the collected data. I'm not sure whether this is interesting here, if it is, I'll share all my findings.

This is how Arch Linux ARM builds nodejs for ARMv6: ALARM ARMv6 PKGBUILD

In case anybody is interested, I created an AUR package to install the officially released binaries of nodejs on Arch Linux.

Related issues

I couldn't find much about this issue. Only when I googled cacheflush (a syscall that is called a lot of times by the Arch Linux ARM provided binary) I managed to find a few similar issues.

Not sure whether they're related, but here they are:


Is this expected?
Is there anything I can do to improve start up times or figure out why they're so slow?

@mscdex mscdex added arm Issues and PRs related to the ARM platform. performance Issues and PRs related to the performance of Node.js. labels Nov 11, 2017
@bnoordhuis
Copy link
Member

If I had to guess, it's because the AUR package is compiled with --without-snapshot.

~1.5s for start-up doesn't seem too out of the ordinary, given the Zero W's hardware.

You can't really compare it with cpython: one is a JIT compiler, the other a simple interpreter.

@peoro
Copy link
Author

peoro commented Nov 12, 2017

I believe you're right.

Both node -e '' and npm -v are reliably ~20x times slower on the Raspberry Pi Zero W than on my x86-64 desktop, and ~5x slower on the Odroid-C2. Considering that 90+% of their real time is CPU time, these results are not too surprising anymore.

Is there any way to disable the JIT compiler or to cache some of the JITted code?
I'm happy to trade slow startup time for better performance while running stuff on production, but the development and testing part is sometimes unbearable.

@bnoordhuis
Copy link
Member

Is there any way to disable the JIT compiler or to cache some of the JITted code?

The JIT compiler cannot be disabled. The snapshot is a cache of the JS runtime; apart from that options for caching are limited (in a way that's useful for development, at least.)

I'll go ahead and close this out. Can you post follow-up questions to the help repo if you have them? Thanks.

@vedmant
Copy link

vedmant commented Jul 14, 2018

It's actually quite slow even on fast computer MacBook Air i7:
First time:
time npm -v
5.6.0

real 0m0.707s
user 0m0.285s
sys 0m0.146s

Next times:
time npm -v
5.6.0

real 0m0.281s
user 0m0.202s
sys 0m0.046s

@empierre
Copy link

can we reponen it as it is not solved ?

@bnoordhuis
Copy link
Member

Maybe, if you have concrete suggestions for improvement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arm Issues and PRs related to the ARM platform. performance Issues and PRs related to the performance of Node.js.
Projects
None yet
Development

No branches or pull requests

5 participants