-
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
Linux large pages - after rebase #22079
Conversation
@gireeshpunathil I've rebased the code. Please let me know if I'm missing anything. Thanks. |
@uttampawar - thanks. Given that this is opened in lieu of #21064,
|
@gireeshpunathil The code is exactly the same. And yes #21064 can be closed. |
Last change (addition of new line) is the only difference between original code and the one I submitted. |
@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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI with --use-largepages
: https://ci.nodejs.org/job/node-test-commit/20173/
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style nit: redundant ()
?
src/node_large_page.cc
Outdated
iss >> permission; | ||
|
||
if (permission.compare("r-xp") == 0) { | ||
start = reinterpret_cast<unsigned int64_t>(&__nodetext); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style nit: uint64_t
src/node_large_page.cc
Outdated
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)); |
There was a problem hiding this comment.
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 >
src/node_large_page.cc
Outdated
} | ||
|
||
inline int64_t hugepage_align_up(int64_t addr) { | ||
const size_t hps = 2L * 1024 * 1024; |
There was a problem hiding this comment.
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
src/node_large_page.cc
Outdated
__attribute__((__aligned__(2 * 1024 * 1024))) | ||
__attribute__((__noinline__)) | ||
__attribute__((__optimize__("2"))) | ||
MoveTextRegionToLargePages(struct text_region r) { |
There was a problem hiding this comment.
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
return -1; | ||
} | ||
|
||
if (r.from > reinterpret_cast<void* > (&MoveTextRegionToLargePages)) |
There was a problem hiding this comment.
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 >
src/node_large_page.cc
Outdated
int MapStaticCodeToLargePages() { | ||
struct text_region r = FindNodeTextRegion(); | ||
if (r.found_text_region == false) { | ||
fprintf(stderr, "Hugepages WARNING: failed to find text region \n"); |
There was a problem hiding this comment.
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
src/node_large_page.h
Outdated
|
||
namespace node { | ||
bool IsLargePagesEnabled(); | ||
int MapStaticCodeToLargePages(); |
There was a problem hiding this comment.
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
src/node_large_page.cc
Outdated
// If successful copy the code there and unmap the original region. | ||
|
||
extern char __executable_start; | ||
extern char __etext; |
There was a problem hiding this comment.
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?
I'm not sure if this has security implications, but out of caution: @nodejs/security-wg |
@addaleax Thanks for the review. You are correct, this is re-submission since original author is on vacation. I'll address suggested changes. |
From the test log I see "test-trace-event-promises" test failed as shown below, |
@uttampawar It’s unrelated (was due to a broken |
@addaleax Do I need to re-base again and resubmit? |
@uttampawar yeah, just rebase on current master and force push to your branch ( |
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)') |
There was a problem hiding this comment.
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'
?
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
src/node_large_page.cc
Outdated
return -1; | ||
} | ||
|
||
if (r.from > reinterpret_cast<void*> (&MoveTextRegionToLargePages)) |
There was a problem hiding this comment.
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*>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0a4ace2
to
21bc4a1
Compare
@addaleax @lundibundi Finished re-base of large pages support patch. Also, "make test-ci" shows no failures. |
The build log says failure due to "no space left" error. See details below, not ok 2294 sequential/test-fs-watchduration_ms: 0.111
|
@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). |
raising exception on irrelevant platforms looks like a good option to me. |
ping @uttampawar, PTAL #22079 (comment). |
21bc4a1
to
0e30f77
Compare
@lundibundi Rebased it. |
@gireeshpunathil @addaleax @gabrielschulhof Can someone start CI with --use-largepages option please? |
There was a problem hiding this 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)
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? |
PR-URL: #22079 Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Denys Otrishko <[email protected]> Reviewed-By: Refael Ackermann <[email protected]>
Thanks, yes we will work on raising a PR @uttampawar |
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
Backport-PR-URL: nodejs#23861 PR-URL: nodejs#22079 Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Denys Otrishko <[email protected]> Reviewed-By: Refael Ackermann <[email protected]>
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 <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
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 <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
Backport-PR-URL: #23861 PR-URL: #22079 Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Denys Otrishko <[email protected]> Reviewed-By: Refael Ackermann <[email protected]>
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 <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
Backport-PR-URL: #23861 PR-URL: #22079 Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Denys Otrishko <[email protected]> Reviewed-By: Refael Ackermann <[email protected]>
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 <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
Backport-PR-URL: #23861 PR-URL: #22079 Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Denys Otrishko <[email protected]> Reviewed-By: Refael Ackermann <[email protected]>
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 <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
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 <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
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), orvcbuild test
(Windows) passes