-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
-flto
on clang/gcc?
#7400
Comments
cc @bnoordhuis |
Here are tls-throughput result comparison on my mac (10 runs):
|
I suspect that it will also slightly improve start time and overall performance. |
Out of curiosity, was this prompted by news of ThinLTO? |
@indutny Did you build with |
@mscdex yup @bnoordhuis yep, and also I am on OS X, so gcc is not an option anyway. |
@bnoordhuis btw, |
Something to consider too: http://clang.llvm.org/docs/UsersManual.html#cmdoption-fwhole-program-vtables |
What I mean is that when you compile with clang++ but link with g++, then g++ won't know how to do LTO across files because the .o files don't contain GIMPLE (because they contain LLVM bitcode.) |
Introduce `--with-lto` configure option to use Link Time Optimization compiler pass in gcc/clang compilers. This flag slightly improves performance of C/C++ heavy code: tls/throughput.js dur="5" type="buf" size="2": ./out/Release/node-flto: 6.1295 ./out/Release/node: 5.6876 ....... 7.77% tls/throughput.js dur="5" type="buf" size="1024": ./out/Release/node-flto: 1567 ./out/Release/node: 1455 ........ 7.70% tls/throughput.js dur="5" type="buf" size="1048576": ./out/Release/node-flto: 4167.8 ./out/Release/node: 4026.7 . 3.50% tls/throughput.js dur="5" type="asc" size="2": ./out/Release/node-flto: 5.5664 ./out/Release/node: 5.0363 ...... 10.52% tls/throughput.js dur="5" type="asc" size="1024": ./out/Release/node-flto: 1462.2 ./out/Release/node: 1336.8 .... 9.38% tls/throughput.js dur="5" type="asc" size="1048576": ./out/Release/node-flto: 3947.5 ./out/Release/node: 3847.4 . 2.60% tls/throughput.js dur="5" type="utf" size="2": ./out/Release/node-flto: 5.5544 ./out/Release/node: 5.0786 ....... 9.37% tls/throughput.js dur="5" type="utf" size="1024": ./out/Release/node-flto: 1328.5 ./out/Release/node: 1255.7 .... 5.80% tls/throughput.js dur="5" type="utf" size="1048576": ./out/Release/node-flto: 3051.1 ./out/Release/node: 2985.1 . 2.21% See: nodejs#7400
@bnoordhuis oh, of course. Do you think we need to do something about it? |
FWIW I tried |
@indutny The PR probably needs to enforce that LINK and LINK.target == CXX.target, unless explicitly overridden. |
In fact, that's pretty common case - from what I observed, LTO in gcc usually gives only cross-object dead code elimination (which is already a good thing, even though in theory it can do more). |
Alright, so clang only then? |
Well, I think it's still favorable for release builds, no matter what compiler we're using. |
So, if we wanted to play around with release binaries for 64-bit linux we'd want to set up a recent clang on centos5? |
@RReverser I'm not so sure this would be good to have in release builds (and/or as a default) if |
@jbergstroem |
Introduce `--with-lto` configure option to use Link Time Optimization compiler pass in gcc/clang compilers. This flag slightly improves performance of C/C++ heavy code: tls/throughput.js dur="5" type="buf" size="2": ./out/Release/node-flto: 6.1295 ./out/Release/node: 5.6876 ....... 7.77% tls/throughput.js dur="5" type="buf" size="1024": ./out/Release/node-flto: 1567 ./out/Release/node: 1455 ........ 7.70% tls/throughput.js dur="5" type="buf" size="1048576": ./out/Release/node-flto: 4167.8 ./out/Release/node: 4026.7 . 3.50% tls/throughput.js dur="5" type="asc" size="2": ./out/Release/node-flto: 5.5664 ./out/Release/node: 5.0363 ...... 10.52% tls/throughput.js dur="5" type="asc" size="1024": ./out/Release/node-flto: 1462.2 ./out/Release/node: 1336.8 .... 9.38% tls/throughput.js dur="5" type="asc" size="1048576": ./out/Release/node-flto: 3947.5 ./out/Release/node: 3847.4 . 2.60% tls/throughput.js dur="5" type="utf" size="2": ./out/Release/node-flto: 5.5544 ./out/Release/node: 5.0786 ....... 9.37% tls/throughput.js dur="5" type="utf" size="1024": ./out/Release/node-flto: 1328.5 ./out/Release/node: 1255.7 .... 5.80% tls/throughput.js dur="5" type="utf" size="1048576": ./out/Release/node-flto: 3051.1 ./out/Release/node: 2985.1 . 2.21% Fixes: nodejs#7400
This should stay open, yes? (Hi! I'm triaging inactive issues!) |
Hello I am trying to build Node.js with lto. However, I get the following error, when executing the tests, i.e. when running - make test - :
Could you please help? Did anybody encounter the same error? I saw that there was some activity in the recent past regarding memory leaks, therefore, I am wondering if this is something related to newer version of Node.js or not. I am looking forward to hearing from you. Thank you in advance,
(edit by @addaleax: formatting) |
@octaviansoldea Which compiler/OS/libc are you using? Generally, that test is very new, and you shouldn’t worry about it failing with this error at this point |
It might also help to have something like “steps to reproduce”? |
Thank you for your message and feedback. Here are the steps I am using when compiling Node.js. The versions of gcc and g++ used are The Linux version I am using is The modifications I am introducing are related to two files For compilation, please use ./configure --enable-lto at the configuration step, and make -j number at proper compilation. In this context, I recommend using number = 1.5 * number_of_processors_available. Moreover, please note that the line 'lto': ' -flto=4 -fuse-linker-plugin -ffat-lto-objects ', influences the linking time. One can use "... -flto=number ...", where number is different number = 1.5 * number_of_processors_available as mentioned above. Any help and feedback is greatly appreciated. |
This modification allows for compiling with link time optimization (lto) using the flag --enable-lto. Refs: nodejs#7400
Ping... what's the status on this? |
Closing due to inactivity. |
I wonder if we should give a try to the Link Time Optimizations flag in clang. It appears to be used when building v8 (though, as far as I can tell no on mac), and may be useful for building OpenSSL and/or core itself.
Thoughts?
cc @nodejs/collaborators
The text was updated successfully, but these errors were encountered: