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

pgo: enabling pgo at configure #21596

Closed
wants to merge 1 commit into from

Conversation

octaviansoldea
Copy link

This modification allows for compiling with profiled guided optimization (pgo) using the flags
--enable-pgo-generate and --enable-pgo-use.

Refs: #21583
Refs: #1409

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

This is a modification proposed towards enabling pgo compilation. From some preliminary results, I have the following data:

I have compared Node-DC-EIS and Ghost, and have obtained 3.7% and 3.8% improvements respectively. These numbers were validated with unpaired t-test. Moreover, I am collecting data regarding the Node.js benchmark suite and mentioned partial results in Refs: #21583. In this context, I would like to mention that assert and async manifest 3.17% and 3.92% improvements respectively.

The experiments were done on Intel(R) Xeon(R) Platinum 8180 CPU @ 2.50GHz. Nevertheless, the solution passes the tests, and also compiles for 32 bits, see also issue Refs: #1409.

@nodejs-github-bot nodejs-github-bot added the build Issues and PRs related to build files or the CI. label Jun 29, 2018
@octaviansoldea octaviansoldea mentioned this pull request Jun 29, 2018
configure Outdated

if flavor == 'linux':
if options.enable_pgo_generate or options.enable_pgo_use:
if CC != 'gcc' or CXX != 'g++':
Copy link
Contributor

@mscdex mscdex Jun 30, 2018

Choose a reason for hiding this comment

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

This isn't a very good check, especially since some distros support multiple gcc/g++ versions using different executable names. Perhaps it would be better to check for a valid gcc_version from try_check_compiler()?

Copy link
Author

Choose a reason for hiding this comment

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

Hello

Thank you for your feedback and suggestion. I will implement this asap.

@octaviansoldea

@octaviansoldea
Copy link
Author

octaviansoldea commented Jul 10, 2018

Dear Reviewers

Thank you for your valuable comments. I would like to ask if are there any additional comments or suggestions?

@octaviansoldea

@jasnell
Copy link
Member

jasnell commented Jul 12, 2018

common.gypi Outdated
],
},],
],},
],
Copy link
Member

Choose a reason for hiding this comment

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

I don't think you have to change these 2 lines, is this intentional?

Copy link
Author

Choose a reason for hiding this comment

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

Agree and tried to resolve it.

configure Outdated
@@ -892,7 +904,6 @@ def configure_mips(o):
o['variables']['mips_arch_variant'] = options.mips_arch_variant
o['variables']['mips_fpu_mode'] = options.mips_fpu_mode


Copy link
Member

Choose a reason for hiding this comment

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

Any reason to remove this blank? I'm pretty sure it's according to pep to separate top-level functions with 2 blanks.

Copy link
Author

Choose a reason for hiding this comment

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

Agree and tried to resolve it.

configure Outdated
@@ -955,7 +989,6 @@ def configure_node(o):
' or newer only.' % (version_checked_str))

o['variables']['enable_lto'] = b(options.enable_lto)

Copy link
Member

Choose a reason for hiding this comment

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

Also here, any reason for the removal?

Copy link
Author

Choose a reason for hiding this comment

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

Agree and tried to resolve it.

configure Outdated
action="store_true",
dest="enable_pgo_generate",
help="Enable profiling with pgo of a binary. This feature is only available "
"on linux with gcc and g++.")
Copy link
Member

Choose a reason for hiding this comment

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

Probably worth adding a minimal version for gcc/g++ here (and below) too?

Copy link
Author

Choose a reason for hiding this comment

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

Agree and tried to implement the suggestion. Please see lines 962-998 in configure and the comment in the following.

Copy link
Member

Choose a reason for hiding this comment

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

I meant to include minimal gcc version in this comment to let people know it from help. Something like:
'This feature is only available on linux with gcc and g++ 5.4.1 or newer only.'. And the same for line 166.

@octaviansoldea
Copy link
Author

Dear Reviewers

Thank you for the feedback. I will come back with changes asap.

@octaviansoldea

@octaviansoldea
Copy link
Author

octaviansoldea commented Aug 2, 2018

Dear Reviewers,

Thank you again for the very good feedback. In a trial to answer the suggestions, I have tried to resolve the problems related to lines and indentations. Moreover, regarding the checking of the compiler, I tried to make a uniform design with the lto code. In this context, the tests for the compiler are located between lines 962-998 in configure. Moreover, I have introduced the function check_gcc_version that is used for both pgo and lto. Of course, pgo is covered in both of generate and use cases. The reason for doing the checks in these lines is following the fact that more tests are done here, see also

if flavor == 'aix':
...

if target_arch in ('x86', 'x64', 'ia32', 'x32'):
...
elif options.enable_vtune_profiling:
...
else:
...

in lines 950-960.

Could you please tell if you have further suggestions? Is there anything I can do in order to help making the code better?

Thank you in advance,
@octaviansoldea

Copy link
Member

@lundibundi lundibundi left a comment

Choose a reason for hiding this comment

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

Thanks for your work 👍
Just a few nits.

configure Outdated
@@ -893,6 +905,16 @@ def configure_mips(o):
o['variables']['mips_fpu_mode'] = options.mips_fpu_mode


def check_gcc_version(version_checked):
Copy link
Member

Choose a reason for hiding this comment

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

Maybe gcc_version_ge? Though I'm fine with this too. (ge for greater-or-equals in python)

Copy link
Author

Choose a reason for hiding this comment

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

Agree and tried to resolve it.

configure Outdated
raise Exception(
'The option --enable-lto is supported for gcc and gxx %s'
' or newer only.' % (version_checked_str))
if check_gcc_version(version_checked) == False:
Copy link
Member

Choose a reason for hiding this comment

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

if not check_gcc_version(version_checked):

Copy link
Author

Choose a reason for hiding this comment

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

Agree and tried to resolve it.

configure Outdated
if check_gcc_version(version_checked) == False:
version_checked_str = ".".join(map(str, version_checked))
raise Exception(
'The options --enable-pgo-generate and --enable-pgo-use options '
Copy link
Member

Choose a reason for hiding this comment

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

Duplicate 'options', should probably be 'The options --enable-pgo-generate and --enable-pgo-use '?

Copy link
Author

Choose a reason for hiding this comment

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

Agree and tried to resolve it.

configure Outdated
action="store_true",
dest="enable_pgo_generate",
help="Enable profiling with pgo of a binary. This feature is only available "
"on linux with gcc and g++.")
Copy link
Member

Choose a reason for hiding this comment

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

I meant to include minimal gcc version in this comment to let people know it from help. Something like:
'This feature is only available on linux with gcc and g++ 5.4.1 or newer only.'. And the same for line 166.

configure Outdated
if flavor == 'linux':
if options.enable_pgo_generate or options.enable_pgo_use:
version_checked = (5, 4, 1)
if check_gcc_version(version_checked) == False:
Copy link
Member

Choose a reason for hiding this comment

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

Also if not check_gcc_version(version_checked):

Copy link
Author

Choose a reason for hiding this comment

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

Agree and tried to resolve it.

@lundibundi
Copy link
Member

This needs CI and some final reviews. @addaleax @bnoordhuis @mscdex

Copy link
Member

@lundibundi lundibundi left a comment

Choose a reason for hiding this comment

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

LGTM.

@lundibundi
Copy link
Member

@octaviansoldea could you please rebase this PR on the current master?

Also, ping @jasnell @richardlau @bnoordhuis @addaleax.

Copy link
Member

@jasnell jasnell left a comment

Choose a reason for hiding this comment

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

still lgtm

@octaviansoldea
Copy link
Author

Dear Reviewers

Thank you for your messages. I will answer asap.

@octaviansoldea

This modification allows for compiling with profiled guided
optimization (pgo) using the flags
--enable-pgo-generate and --enable-pgo-use.

Refs: nodejs#21583
Refs: nodejs#1409
@lundibundi
Copy link
Member

@addaleax
Copy link
Member

addaleax commented Sep 2, 2018

@addaleax
Copy link
Member

addaleax commented Sep 3, 2018

@gabrielschulhof
Copy link
Contributor

The latter CI is actually green, so landing.

@gabrielschulhof
Copy link
Contributor

Landed in 9be1555.

gabrielschulhof pushed a commit that referenced this pull request Sep 4, 2018
This modification allows for compiling with profiled guided
optimization (pgo) using the flags
--enable-pgo-generate and --enable-pgo-use.

Refs: #21583
Refs: #1409
PR-URL: #21596
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
targos pushed a commit that referenced this pull request Sep 5, 2018
This modification allows for compiling with profiled guided
optimization (pgo) using the flags
--enable-pgo-generate and --enable-pgo-use.

Refs: #21583
Refs: #1409
PR-URL: #21596
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
@misterdjules
Copy link

@octaviansoldea Is it correct that this PR does not enable Profile Guided Optimization by default? If so, is that the goal in the future and is there already a PR/issue where we can track that change/discussion?

@targos targos added this to Don't land (for now) in v10.x Sep 23, 2018
@targos targos moved this from Don't land (for now) to Don't land (ever) in v10.x Sep 23, 2018
@targos
Copy link
Member

targos commented Sep 23, 2018

@addaleax You said in #22716 that this was breaking native addons. Do we need to revert the change?

@lundibundi
Copy link
Member

@targos there has been an #22772 but it was decided that breakage was caused by some stale configs and native addons should be working fine.
Though @addaleax could you please confirm that there has not been any other problems related to this?

@addaleax
Copy link
Member

@lundibundi @targos I can’t reproduce any breakage anymore. I guess that’s a pretty good sign but I’m not sure how to go back to the situation where I had the broken config.

@targos
Copy link
Member

targos commented Sep 25, 2018

Should we try to land it again on v10?

@octaviansoldea
Copy link
Author

Dear Reviewers, Hello,

First of all, please accept my apologies for a prolonged inactivity, it is related to personal issues.

@misterdjules the intention was to use pgo on demand only, i.e. not to enable it by default. Adding pgo by default means having a predefined workload for profiling, and, actually it would be good to ask the community if there is such an accepted software.

In this context, I would like to backport this PR to v10. However, I feel I would like to learn a bit more what is to be done, provided, this is acceptable, of course.

@addaleax I would like to ask for a bit of guidance for understanding what were the reasons not to land this on v10? Could you and colleagues, please, write a bit more comments on this?

Thank you in advance,
@octaviansoldea

@addaleax addaleax removed this from Don't land (ever) in v10.x Sep 27, 2018
@addaleax
Copy link
Member

@octaviansoldea Sorry, it seems like this was caused by me using a stale config of some sort after trying to build addons on the v10.x-staging branch. We’ll land it on v10.x and see if something goes wrong.

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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants