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

build: introduce ./configure --with-lto #7408

Closed
wants to merge 1 commit into from

Conversation

indutny
Copy link
Member

@indutny indutny commented Jun 24, 2016

Checklist
  • make -j4 test (UNIX) or vcbuild test nosign (Windows) passes
  • a test and/or benchmark is included
  • documentation is changed or added
  • the commit message follows commit guidelines
Affected core subsystem(s)

build

Description of change

build: introduce ./configure --with-lto

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: #7400

R= @bnoordhuis @nodejs/collaborators

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
@indutny
Copy link
Member Author

indutny commented Jun 24, 2016

It appears to be breakingtest/parallel/test-tick-processor.js, and the build is quite slower than the one without LTO.

I wonder if addons would still work just fine?

@eljefedelrodeodeljefe
Copy link
Contributor

eljefedelrodeodeljefe commented Jun 24, 2016

hmm. side effects are weird. Nothing should pop up really....

Having this has no harm though. If that holds true, LGTM.

@Fishrock123 Fishrock123 added c++ Issues and PRs that require attention from people who are familiar with C++. build Issues and PRs related to build files or the CI. labels Jun 24, 2016
@addaleax
Copy link
Member

addaleax commented Jun 25, 2016

btw, this fails to link for me when using gcc (gcc version 5.2.1 20151010 x86_64-linux-gnu), see here for the output.

EDIT: figured out what’s going wrong, I had to set AR=gcc-ar … 🙄

@@ -290,6 +291,13 @@
],
'ldflags!': [ '-rdynamic' ],
}],
['node_use_lto=="true"', {
'conditions': [ [ 'clang==1', {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you put the condition on a separate line?

@bnoordhuis
Copy link
Member

It appears to be breakingtest/parallel/test-tick-processor.js

@indutny Let me guess: it can't find the RunInDebugContext symbol?

btw, this fails to link for me when using gcc

@addaleax What binutils version do you have installed and are you using ld.gold to link?

@addaleax
Copy link
Member

GNU ld (GNU Binutils for Ubuntu) 2.25.1, switching to gold doesn’t seem to make any difference though.

@jasnell
Copy link
Member

jasnell commented Aug 18, 2016

@indutny .. what's the status on this one?

@indutny
Copy link
Member Author

indutny commented Aug 19, 2016

@jasnell seems to be breaking profiler tests, and the effects may be local to only OS X. Not sure if we want it at this time.

@jasnell
Copy link
Member

jasnell commented Aug 19, 2016

Ok. do you want to keep it open to work on later or close?

@indutny
Copy link
Member Author

indutny commented Aug 19, 2016

@jasnell I would keep it open, the conflicts are not going to be too hard to resolve later on.

@jasnell
Copy link
Member

jasnell commented Jan 6, 2017

ping @indutny ... any updates on this?

@jasnell jasnell added the stalled Issues and PRs that are stalled. label Jan 6, 2017
@addaleax
Copy link
Member

addaleax commented Feb 3, 2017

@indutny By the way, for me this seems to work now. Setting AR=gcc-ar did the trick. :)

I have a rebased version at d6b510c (resolving the conflict here is trivial), CI results @ https://ci.nodejs.org/job/node-test-commit/7653/. Some of the CI hosts ran into the same problem I had, but the OS X tests look a bit worrying: https://ci.nodejs.org/job/node-test-commit-osx/7615/nodes=osx1010/console

@@ -297,6 +297,11 @@ parser.add_option('--with-lttng',
dest='with_lttng',
help='build with Lttng (Only available to Linux)')

parser.add_option('--with-lto',
action='store_true',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tiny nit: It would be better we passed default=False as one of the arguments to add_option.

@indutny
Copy link
Member Author

indutny commented Feb 6, 2017

I'm still not sure if we should pursue this... @addaleax except for the build failures, does it provide any measurable performance benefit for you?

@addaleax
Copy link
Member

addaleax commented Feb 7, 2017

@indutny I can try to run some benchmarking later, but my personal experience would be that generally LTO is worth it.

@jasnell
Copy link
Member

jasnell commented Aug 24, 2017

Closing due to lack of further progress. We can reopen later if necessary

@jasnell jasnell closed this Aug 24, 2017
@bzoz bzoz mentioned this pull request Jun 7, 2018
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Issues and PRs related to build files or the CI. c++ Issues and PRs that require attention from people who are familiar with C++. stalled Issues and PRs that are stalled.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants