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

Linux large pages - after rebase #22079

Merged
merged 1 commit into from
Oct 18, 2018
Merged

Conversation

uttampawar
Copy link
Contributor

Support under Linux to map the text segment of node into 2M pages.
As requested in PR #21064, I've re-base the huge page support code with master branch.

Make test results show no failures.
$ make test
[03:13|% 100|+ 2363|- 0]: Done

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. labels Aug 2, 2018
@uttampawar
Copy link
Contributor Author

@gireeshpunathil I've rebased the code. Please let me know if I'm missing anything. Thanks.

@gireeshpunathil
Copy link
Member

@gireeshpunathil
Copy link
Member

gireeshpunathil commented Aug 2, 2018

@uttampawar - thanks. Given that this is opened in lieu of #21064,

@uttampawar uttampawar changed the title Intel large pages - after rebase Linux large pages - after rebase Aug 2, 2018
@uttampawar
Copy link
Contributor Author

@gireeshpunathil The code is exactly the same. And yes #21064 can be closed.

@uttampawar
Copy link
Contributor Author

Last change (addition of new line) is the only difference between original code and the one I submitted.

@gireeshpunathil
Copy link
Member

@addaleax @Fishrock123 @gabrielschulhof - this is a clone of #21064 (resubmitted here due to author unavailable I guess). Given that you had reviewed that, will you please have a look?

Also the feature under this PR is exercised only if configured with --use-largepages (that too only in Linux) so running CI does not cover that, instead only helps making sure it does not break anything. How do we go about this in general? custom CI that builds with custom params? /cc @Trott

Copy link
Member

@addaleax addaleax left a comment

Choose a reason for hiding this comment

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

src/node.cc Outdated
@@ -3806,6 +3807,15 @@ int Start(int argc, char** argv) {

CHECK_GT(argc, 0);

#ifdef NODE_ENABLE_LARGE_CODE_PAGES
if (node::IsLargePagesEnabled()) {
if ((node::MapStaticCodeToLargePages()) != 0) {
Copy link
Member

Choose a reason for hiding this comment

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

style nit: redundant ()?

iss >> permission;

if (permission.compare("r-xp") == 0) {
start = reinterpret_cast<unsigned int64_t>(&__nodetext);
Copy link
Member

Choose a reason for hiding this comment

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

style nit: uint64_t

if (permission.compare("r-xp") == 0) {
start = reinterpret_cast<unsigned int64_t>(&__nodetext);
char* from = reinterpret_cast<char* >(hugepage_align_up(start));
char* to = reinterpret_cast<char* >(hugepage_align_down(end));
Copy link
Member

Choose a reason for hiding this comment

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

style nit: no space before >

}

inline int64_t hugepage_align_up(int64_t addr) {
const size_t hps = 2L * 1024 * 1024;
Copy link
Member

Choose a reason for hiding this comment

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

Given that this line occurs a number of times, maybe it makes sense to move it out of the functions?

Also, style nit: 2 spaces of indentation

__attribute__((__aligned__(2 * 1024 * 1024)))
__attribute__((__noinline__))
__attribute__((__optimize__("2")))
MoveTextRegionToLargePages(struct text_region r) {
Copy link
Member

Choose a reason for hiding this comment

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

style nit: const text_region& r (struct is not necessary)?

src/node_large_page.cc Outdated Show resolved Hide resolved
return -1;
}

if (r.from > reinterpret_cast<void* > (&MoveTextRegionToLargePages))
Copy link
Member

Choose a reason for hiding this comment

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

ditto here, no space before/after the cast’s >

int MapStaticCodeToLargePages() {
struct text_region r = FindNodeTextRegion();
if (r.found_text_region == false) {
fprintf(stderr, "Hugepages WARNING: failed to find text region \n");
Copy link
Member

Choose a reason for hiding this comment

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

There’s an extra space at the end of the message here


namespace node {
bool IsLargePagesEnabled();
int MapStaticCodeToLargePages();
Copy link
Member

Choose a reason for hiding this comment

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

style nit: no indentation inside namespaces, blank lines/before after the namespace lines

// If successful copy the code there and unmap the original region.

extern char __executable_start;
extern char __etext;
Copy link
Member

Choose a reason for hiding this comment

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

Where are these two used?

@Trott
Copy link
Member

Trott commented Aug 3, 2018

I'm not sure if this has security implications, but out of caution: @nodejs/security-wg

@uttampawar
Copy link
Contributor Author

@addaleax Thanks for the review. You are correct, this is re-submission since original author is on vacation. I'll address suggested changes.

@uttampawar
Copy link
Contributor Author

uttampawar commented Aug 9, 2018

From the test log I see "test-trace-event-promises" test failed as shown below,
not ok 1878 parallel/test-trace-event-promises
I don't see this failure on my "dev" machine. Is there anything can I do to address this issue? Is this failure due to my change?

@addaleax
Copy link
Member

addaleax commented Aug 9, 2018

From the test log I see "test-trace-event-promises" test failed as shown below,
not ok 1878 parallel/test-trace-event-promises
I don't see this failure on my "dev" machine. Is there anything can I do to address this issue? Is this failure due to my change?

@uttampawar It’s unrelated (was due to a broken master branch), and it will go away after rebasing :)

@uttampawar
Copy link
Contributor Author

@addaleax Do I need to re-base again and resubmit?

@lundibundi
Copy link
Member

lundibundi commented Aug 13, 2018

@uttampawar yeah, just rebase on current master and force push to your branch (uttampawar:intel-large-pages), no need to resubmit, GitHub will update this PR for you.

configure Outdated
action='store_true',
dest='node_use_large_pages',
help='build with Large Pages support (enabled only for Linux).' +
'(Needs Linux kernel >= 2.6.38 with Transparent Huge pages enabled)')
Copy link
Member

Choose a reason for hiding this comment

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

Just a nit 'Transparent Huge pages' -> 'Transparent Huge Pages'
Also, maybe
'build with Large Pages support. This feature is supported only on Linux kernel >= 2.6.38 with Transparent Huge Pages enabled'?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed.

configure Outdated
@@ -977,6 +983,9 @@ def configure_node(o):
else:
o['variables']['node_use_dtrace'] = 'false'

use_large_pages = (flavor == 'linux' and options.node_use_large_pages)
Copy link
Member

Choose a reason for hiding this comment

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

I'd suggest to raise error (example here https://github.com/nodejs/node/blob/0a4ace24d5207ad3c86298a7159c782e6a289781/configure#L951-L953) instead of silently ignoring the option, what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@lundibundi I thin k it's a good idea. Failing early will help catch a build system error when Huge pages are not supported.
@addaleax @jasnell Any other opinions?

Copy link
Member

Choose a reason for hiding this comment

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

@uttampawar
I think we can go ahead and implement it this way considering

  • it is done this way in other places (see code below your change, enable-lto, dtrace etc)
  • considered a good change at least by me, you and @gireeshpunathil.

return -1;
}

if (r.from > reinterpret_cast<void*> (&MoveTextRegionToLargePages))
Copy link
Member

Choose a reason for hiding this comment

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

Just a nit: unnecessary space after reinterpret_cast<void*>

Copy link
Member

Choose a reason for hiding this comment

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

@uttampawar
Copy link
Contributor Author

uttampawar commented Aug 14, 2018

@addaleax @lundibundi Finished re-base of large pages support patch.
I don't see any errors after rebasing as shown below,
$ make test
[03:24|% 100|+ 2365|- 0]: Done

Also, "make test-ci" shows no failures.

@uttampawar
Copy link
Contributor Author

The build log says failure due to "no space left" error. See details below,

not ok 2294 sequential/test-fs-watch

duration_ms: 0.111
severity: fail
exitcode: 1
stack: |-
internal/fs/watchers.js:170
throw error;
^

Error: ENOSPC: no space left on device, watch '/home/travis/build/nodejs/node/test/.tmp.0/watch.txt'
    at FSWatcher.start (internal/fs/watchers.js:164:26)
    at Object.watch (fs.js:1255:11)
    at Object.<anonymous> (/home/travis/build/nodejs/node/test/sequential/test-fs-watch.js:48:22)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
    at startup (internal/bootstrap/node.js:266:19)

@lundibundi
Copy link
Member

@uttampawar could you please rebase once again, just to be sure this PR has all of the updates from master (there were problems with the CI that has been fixed on master).

Ping @addaleax @gabrielschulhof @gireeshpunathil. Also, wdyt of #22079 (comment).

@gireeshpunathil
Copy link
Member

raising exception on irrelevant platforms looks like a good option to me.

@lundibundi
Copy link
Member

ping @uttampawar, PTAL #22079 (comment).

@uttampawar
Copy link
Contributor Author

@lundibundi Rebased it.

@uttampawar
Copy link
Contributor Author

@gireeshpunathil @addaleax @gabrielschulhof Can someone start CI with --use-largepages option please?

@gireeshpunathil
Copy link
Member

Copy link
Member

@addaleax addaleax left a comment

Choose a reason for hiding this comment

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

Just making sure this doesn’t land without having addressed the outstanding comments (since this might look like it could be ready, judging from the one approval and CI)

@gireeshpunathil
Copy link
Member

and CI)

but why doesn't the CI result appear here? @addaleax - I started a CI few hours back (please see the link above), it's result does not seem to be available in this page: either as a summary or details. I am just wondering whether I ran it correctly or not, will you please have a look?

jasnell pushed a commit that referenced this pull request Oct 21, 2018
PR-URL: #22079
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
@suresh-srinivas
Copy link
Contributor

Should this be backported to v10.x-staging? If yes please follow the guide and raise a backport PR, if not let me know or add the dont-land-on label.

Thanks, yes we will work on raising a PR @uttampawar

@uttampawar uttampawar deleted the intel-large-pages branch October 29, 2018 18:12
suresh-srinivas added a commit to suresh-srinivas/node that referenced this pull request Oct 30, 2018
Fixes: nodejs#23906
Refs: nodejs#22079

This change to ld.implicit.script moves libc static code to
.lpstub area and avoids the issue detailed in 23906

Quick performance comparision on web-tooling shows 3%
improvement for the combination over fully-static

cycles                       376,235,487,455  390,007,877,315
instructions                 700,341,146,973  714,773,201,182
itlb_misses_walk_completed        20,654,246       28,908,381
itlb_misses_walk_completed_4k     19,884,666       28,865,118
itlb_misses_walk_completed_2m_4m     769,391           43,251
Score                                   9.13             8.86
uttampawar pushed a commit to uttampawar/node that referenced this pull request Oct 31, 2018
Backport-PR-URL: nodejs#23861
PR-URL: nodejs#22079
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
pull bot pushed a commit to SimenB/node that referenced this pull request Nov 1, 2018
Fixes: nodejs#23906
Refs: nodejs#22079

This change to ld.implicit.script moves libc static code to
.lpstub area and avoids the issue detailed in 23906

Quick performance comparision on web-tooling shows 3%
improvement for the combination over fully-static

cycles                       376,235,487,455  390,007,877,315
instructions                 700,341,146,973  714,773,201,182
itlb_misses_walk_completed        20,654,246       28,908,381
itlb_misses_walk_completed_4k     19,884,666       28,865,118
itlb_misses_walk_completed_2m_4m     769,391           43,251
Score                                   9.13             8.86

PR-URL: nodejs#23964
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
targos pushed a commit that referenced this pull request Nov 2, 2018
Fixes: #23906
Refs: #22079

This change to ld.implicit.script moves libc static code to
.lpstub area and avoids the issue detailed in 23906

Quick performance comparision on web-tooling shows 3%
improvement for the combination over fully-static

cycles                       376,235,487,455  390,007,877,315
instructions                 700,341,146,973  714,773,201,182
itlb_misses_walk_completed        20,654,246       28,908,381
itlb_misses_walk_completed_4k     19,884,666       28,865,118
itlb_misses_walk_completed_2m_4m     769,391           43,251
Score                                   9.13             8.86

PR-URL: #23964
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
MylesBorins pushed a commit that referenced this pull request Nov 4, 2018
Backport-PR-URL: #23861
PR-URL: #22079
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
MylesBorins pushed a commit that referenced this pull request Nov 27, 2018
Fixes: #23906
Refs: #22079

This change to ld.implicit.script moves libc static code to
.lpstub area and avoids the issue detailed in 23906

Quick performance comparision on web-tooling shows 3%
improvement for the combination over fully-static

cycles                       376,235,487,455  390,007,877,315
instructions                 700,341,146,973  714,773,201,182
itlb_misses_walk_completed        20,654,246       28,908,381
itlb_misses_walk_completed_4k     19,884,666       28,865,118
itlb_misses_walk_completed_2m_4m     769,391           43,251
Score                                   9.13             8.86

PR-URL: #23964
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
@codebytere codebytere mentioned this pull request Nov 27, 2018
rvagg pushed a commit that referenced this pull request Nov 28, 2018
Backport-PR-URL: #23861
PR-URL: #22079
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
rvagg pushed a commit that referenced this pull request Nov 28, 2018
Fixes: #23906
Refs: #22079

This change to ld.implicit.script moves libc static code to
.lpstub area and avoids the issue detailed in 23906

Quick performance comparision on web-tooling shows 3%
improvement for the combination over fully-static

cycles                       376,235,487,455  390,007,877,315
instructions                 700,341,146,973  714,773,201,182
itlb_misses_walk_completed        20,654,246       28,908,381
itlb_misses_walk_completed_4k     19,884,666       28,865,118
itlb_misses_walk_completed_2m_4m     769,391           43,251
Score                                   9.13             8.86

PR-URL: #23964
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
MylesBorins pushed a commit that referenced this pull request Nov 29, 2018
Backport-PR-URL: #23861
PR-URL: #22079
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
MylesBorins pushed a commit that referenced this pull request Nov 29, 2018
Fixes: #23906
Refs: #22079

This change to ld.implicit.script moves libc static code to
.lpstub area and avoids the issue detailed in 23906

Quick performance comparision on web-tooling shows 3%
improvement for the combination over fully-static

cycles                       376,235,487,455  390,007,877,315
instructions                 700,341,146,973  714,773,201,182
itlb_misses_walk_completed        20,654,246       28,908,381
itlb_misses_walk_completed_4k     19,884,666       28,865,118
itlb_misses_walk_completed_2m_4m     769,391           43,251
Score                                   9.13             8.86

PR-URL: #23964
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
@codebytere codebytere mentioned this pull request Nov 29, 2018
MylesBorins pushed a commit that referenced this pull request Dec 3, 2018
Fixes: #23906
Refs: #22079

This change to ld.implicit.script moves libc static code to
.lpstub area and avoids the issue detailed in 23906

Quick performance comparision on web-tooling shows 3%
improvement for the combination over fully-static

cycles                       376,235,487,455  390,007,877,315
instructions                 700,341,146,973  714,773,201,182
itlb_misses_walk_completed        20,654,246       28,908,381
itlb_misses_walk_completed_4k     19,884,666       28,865,118
itlb_misses_walk_completed_2m_4m     769,391           43,251
Score                                   9.13             8.86

PR-URL: #23964
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
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++. lib / src Issues and PRs related to general changes in the lib or src directory. python PRs and issues that require attention from people who are familiar with Python.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet