nvm-sh/nvm

Move on clang LLVM

PeterDaveHello opened this issue · 7 comments

Tested on FreeBSD 10.1 64bit with nodejs v0.12.7

$ uname -a

FreeBSD vm2 10.1-RELEASE-p19 FreeBSD 10.1-RELEASE-p19 #0: Sat Aug 22 03:55:09 UTC 2015 root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC amd64

$ c++ --version

FreeBSD clang version 3.4.1 (tags/RELEASE_34/dot1-final 208032) 20140512
Target: x86_64-unknown-freebsd10.1
Thread model: posix

$ g++ --version

g++ (FreeBSD Ports Collection) 4.8.5
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Compilation time spent by clang LLVM:

real 1m49.474s
user 14m51.253s
sys 2m0.750s

Compilation time spent by clang GCC:

real 2m23.481s
user 20m24.823s
sys 2m54.503s

@ljharb What do you think about the checklist?
I'm using Ubuntu, Debian and FreeBSD as my main workstations.

I think certainly doing it for FreeBSD is good - I'm very nervous about changing how everything is compiled - but the speedup is very tempting. We'll also need to test on travis-ci as well as Mac OS.

Okay I removed the checklist, but we need to solve the compilation on FreeBSD first, in fact the latest nodejs on FreeBSD doesn't need any patches, what about support compile from merged nodejs aka version greater than 1.0 from now?

That'd be a fine start, and there's existing helpers that should allow you to do that :-)

Okay let's give it a try.

Manual compile test:

clang llvm:

~/node-v4.2.2 $ clang++ --version
FreeBSD clang version 3.4.1 (tags/RELEASE_34/dot1-final 208032) 20140512
Target: x86_64-unknown-freebsd10.1
Thread model: posix
~/node-v4.2.2 $ time make CXX=clang++ -j 15
.
.
.
real    2m27.425s
user    26m51.125s
sys     2m27.803s

gcc:

~/node-v4.2.2 $ g++ --version
g++ (FreeBSD Ports Collection) 4.8.5
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
~/node-v4.2.2 $ time make CXX=g++ -j 15
.
.
.
real    3m12.031s
user    35m14.671s
sys     4m5.747s

9 min 23 sec diff in user space, about 30% time spent

Start to work on this again.

Now test nodejs v7.1.0 on Debian 8.6 amd64, with 25 threads.

$ g++ --version
g++ (Debian 4.9.2-10) 4.9.2
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ time make CXX=g++ -j 25
.
.
.
real    6m59.985s
user    133m10.544s
sys     5m43.584s
$ clang++ --version
Debian clang version 3.5.0-10 (tags/RELEASE_350/final) (based on LLVM 3.5.0)
Target: x86_64-pc-linux-gnu
Thread model: posix
$ time make CXX=clang++ -j 25
.
.
.
real    4m59.905s
user    96m25.876s
sys     3m21.440s

Base on this result, we may try to use clang by detecting if clang exists, it'll save our time on the compilation.