-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
build: add support for section ordering #35272
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
Closed
gabrielschulhof
wants to merge
2
commits into
nodejs:master
from
gabrielschulhof:use-section-ordering-file2
Closed
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
build: add support for section ordering
Adds support for using a section ordering file with the gold linker. This makes it possible to reorder functions in a build to optimize for a specific workload. `hfsort` is a tool that can be used to generate such a file from perf- recorded last branch record (LBR) data by running Node.js as `node --perf-basic-prof`. Refs: https://github.com/facebook/hhvm/tree/9966d482c19c6120c621c6f3896525fb19fb3842/hphp/tools/hfsort Refs: https://software.intel.com/content/www/us/en/develop/articles/runtime-optimization-blueprint-IA-optimization-with-last-branch-record.html Refs: #16891 Signed-off-by: Gabriel Schulhof <gabriel.schulhof@intel.com>
- Loading branch information
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -502,6 +502,14 @@ | |
| dest='node_use_large_pages_script_lld', | ||
| help='This option has no effect. --use-largepages is now a runtime option.') | ||
|
|
||
| parser.add_option('--use-section-ordering-file', | ||
| action='store', | ||
| dest='node_section_ordering_file', | ||
| default='', | ||
| help='Pass a section ordering file to the linker. This requires that ' + | ||
| 'Node.js be linked using the gold linker. The gold linker must have ' + | ||
| 'version 1.2 or greater.') | ||
|
|
||
| intl_optgroup.add_option('--with-intl', | ||
| action='store', | ||
| dest='with_intl', | ||
|
|
@@ -1766,6 +1774,29 @@ def configure_inspector(o): | |
| options.without_ssl) | ||
| o['variables']['v8_enable_inspector'] = 0 if disable_inspector else 1 | ||
|
|
||
| def configure_section_file(o): | ||
| try: | ||
| proc = subprocess.Popen(['ld.gold'] + ['-v'], stdin = subprocess.PIPE, | ||
| stdout = subprocess.PIPE, stderr = subprocess.PIPE) | ||
| except OSError: | ||
| return 0 | ||
|
cclauss marked this conversation as resolved.
Outdated
|
||
|
|
||
| match = re.match(r"^GNU gold.*([0-9]+)\.([0-9]+)$", | ||
| proc.communicate()[0].decode("utf-8")) | ||
|
|
||
| if match: | ||
| gold_major_version = match.group(1) | ||
| gold_minor_version = match.group(2) | ||
| if int(gold_major_version) == 1 and int(gold_minor_version) <= 1: | ||
| error('''GNU gold version must be greater than 1.2 in order to use section | ||
| reordering''') | ||
|
|
||
| if options.node_section_ordering_file != "": | ||
| o['variables']['node_section_ordering_file'] = os.path.realpath( | ||
| str(options.node_section_ordering_file)) | ||
| else: | ||
| # An empty string here will cause gyp to fail. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's because gyp handles variables ending in |
||
| o['variables']['node_section_ordering_file'] = "-" | ||
|
|
||
| def make_bin_override(): | ||
| if sys.platform == 'win32': | ||
|
|
@@ -1831,6 +1862,7 @@ def make_bin_override(): | |
| configure_intl(output) | ||
| configure_static(output) | ||
| configure_inspector(output) | ||
| configure_section_file(output) | ||
|
|
||
| # Forward OSS-Fuzz settings | ||
| output['variables']['ossfuzz'] = b(options.ossfuzz) | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Since
common.gypiis also used to compile addons any variables referenced needs to have default values so addons can be compiled with older versions of Node.js where the variable isn’t present. See #33688 for an example.