Skip to content

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

Closed
indutny wants to merge 1 commit into
nodejs:masterfrom
indutny:feature/lto
Closed

build: introduce ./configure --with-lto#7408
indutny wants to merge 1 commit into
nodejs:masterfrom
indutny:feature/lto

Conversation

@indutny

Copy link
Copy Markdown
Member
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
Copy Markdown
MemberAuthor

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

eljefedelrodeodeljefe commented Jun 24, 2016

Copy link
Copy Markdown
Contributor

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

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

@Fishrock123Fishrock123 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

addaleax commented Jun 25, 2016

Copy link
Copy Markdown
Member

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 … 🙄

Comment threadcommon.gypi
'ldflags!': [ '-rdynamic' ],
}],
['node_use_lto=="true"', {
'conditions': [ [ 'clang==1', {

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

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

@jasnell

Copy link
Copy Markdown
Member

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

@indutny

Copy link
Copy Markdown
MemberAuthor

@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
Copy Markdown
Member

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

@indutny

Copy link
Copy Markdown
MemberAuthor

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

@jasnell

Copy link
Copy Markdown
Member

ping @indutny ... any updates on this?

@jasnelljasnell added the stalled Issues and PRs that are stalled. label Jan 6, 2017
@addaleax

Copy link
Copy Markdown
Member

@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

Comment threadconfigure
help='build with Lttng (Only available to Linux)')

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

Copy link
Copy Markdown
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
Copy Markdown
MemberAuthor

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
Copy Markdown
Member

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

@jasnell

Copy link
Copy Markdown
Member

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

@jasnelljasnell closed this Aug 24, 2017
@bzozbzoz mentioned this pull request Jun 7, 2018
2 tasks
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

buildIssues and PRs related to build files or the CI.c++Issues and PRs that require attention from people who are familiar with C++.stalledIssues and PRs that are stalled.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants

@indutny@eljefedelrodeodeljefe@addaleax@bnoordhuis@jasnell@jbergstroem@thefourtheye@Fishrock123