FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

src: cache the result of GetOptions() in JS land by joyeecheung · Pull Request #24091 · nodejs/node · GitHub

/ node Public

src: cache the result of GetOptions() in JS land - #24091

Closed
joyeecheung wants to merge 2 commits into
nodejs:masterfrom
joyeecheung:options-map
Closed

src: cache the result of GetOptions() in JS land#24091
joyeecheung wants to merge 2 commits into
nodejs:masterfrom
joyeecheung:options-map

Conversation

Copy link
Copy Markdown
Member

Instead of calling into C++ each time we need to check the value
of a command line option, cache the option map in a new
internal/options module for faster access to the values in JS land.

Instead of calling into C++ each time we need to check the value
of a command line option, cache the option map in a new
`internal/options` module for faster access to the values in JS land.
joyeecheung requested a review from addaleax November 4, 2018 21:05

Copy link
Copy Markdown
Collaborator

nodejs-github-bot added the lib / src Issues and PRs related to general changes in the lib or src directory. label Nov 4, 2018

Copy link
Copy Markdown
Member Author

addaleax left a comment

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM with 1 comment

return id.startsWith('internal/') ||
(id === 'worker_threads' &&
!internalBinding('options').getOptions('--experimental-worker'));
(id === 'worker_threads' && !config.experimentalWorker);

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Can we avoid going back to process.config? 😕

joyeecheung Nov 4, 2018
edited
Loading

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

There are also two other reference to config in here, I think a better option would probably be to just specialize something for NativeModule here - maybe just directly generate the whole map when the process starts and pass it to the loader bootstrapper here and let NativeModule short-circuit the internal/options implementation. That also opens up the opportunity to emit all the warning for experimental modules in one place here instead of emitting them everywhere across the code base.

EDIT: wait, we emit them regardless of the cli options..so never mind I guess

Copy link
Copy Markdown
Member Author

Fixed linter and the bootstrap module list test: https://ci.nodejs.org/job/node-test-pull-request/18336/

Copy link
Copy Markdown
Member Author

Comment thread lib/internal/options.js

refack commented Nov 5, 2018

Copy link
Copy Markdown
Contributor

Instead of calling into C++ each time

I get that motivation, but couldn't we make it simpler? I'd be happy to share your reasoning.

refack added process Issues and PRs related to the process subsystem. cli Issues and PRs related to the Node.js command line interface. labels Nov 5, 2018

Copy link
Copy Markdown
Member Author

@refack See #24091 (comment) my reasoning is we could just eliminate calling into C++ at all eventually by creating the map before bootstrapping loaders so it will be made available in loafers.js as an argument directly. This PR just moves the calls to a central place that can be manipulated in loaders.js

refack commented Nov 5, 2018

Copy link
Copy Markdown
Contributor

Resume: https://ci.nodejs.org/job/node-test-commit/22901/
(previous fail was infra, should be resolved)

refack added the author ready PRs that have at least one approval, no outstanding review comments, and a CI started. label Nov 5, 2018

joyeecheung commented Nov 6, 2018
edited
Loading

Copy link
Copy Markdown
Member Author

Just FYI there are others who disagree (that's one of the reasons test/parallel/test-bootstrap-modules.js exists

@refack Just to explore about this point a bit further - I think the reason why test/parallel/test-bootstrap-modules.js exists is to make sure we load less stuff during the bootstrap if they are not really necessary. In this case, the options have to be loaded during the bootstrap no matter what since it is conceptually a dependency of the bootstrap process (whereas things like TCPWrap really are not and they are the main targets that test/parallel/test-bootstrap-modules.js tests against).
In that regard, the length of the module load list is not a very effective measure, as the compilation of a very simple module like options.js that does not depend on too many other modules only incurs a very small overhead (whereas other bigger modules may incur a much bigger overhead by running code synchronously and even invoking bindings that do much more). But again, we don't actually have a better measure to evaluate the "weight" of these native modules..so that remains to be investigated.

refack commented Nov 6, 2018

Copy link
Copy Markdown
Contributor

I think the reason why test/parallel/test-bootstrap-modules.js exists is to make sure we load less stuff during the bootstrap if they are not really necessary.

Main reason sure, but it's also been quoted as a braier for adding new (trivial) modules - #23081 (review)

Again, I'm slightly in favor... Encapsulation/Performance is just a balance we should keep in mind.

refack commented Nov 6, 2018

Copy link
Copy Markdown
Contributor

ubuntu-on-arm had a flake, so resume again: https://ci.nodejs.org/job/node-test-commit/22902/

Trott closed this Nov 8, 2018
Trott pushed a commit to Trott/io.js that referenced this pull request Nov 8, 2018
Instead of calling into C++ each time we need to check the value
of a command line option, cache the option map in a new
`internal/options` module for faster access to the values in JS land.

PR-URL: nodejs#24091
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Refael Ackermann <refack@gmail.com>

Trott commented Nov 8, 2018

Copy link
Copy Markdown
Member

Landed in f895b5a

BridgeAR pushed a commit that referenced this pull request Nov 14, 2018
Instead of calling into C++ each time we need to check the value
of a command line option, cache the option map in a new
`internal/options` module for faster access to the values in JS land.

PR-URL: #24091
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Refael Ackermann <refack@gmail.com>
kiyomizumia pushed a commit to kiyomizumia/node that referenced this pull request Nov 15, 2018
Instead of calling into C++ each time we need to check the value
of a command line option, cache the option map in a new
`internal/options` module for faster access to the values in JS land.

PR-URL: nodejs#24091
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Refael Ackermann <refack@gmail.com>
codebytere pushed a commit that referenced this pull request Dec 13, 2018
Instead of calling into C++ each time we need to check the value
of a command line option, cache the option map in a new
`internal/options` module for faster access to the values in JS land.

PR-URL: #24091
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Refael Ackermann <refack@gmail.com>
MylesBorins pushed a commit that referenced this pull request Dec 22, 2018
Instead of calling into C++ each time we need to check the value
of a command line option, cache the option map in a new
`internal/options` module for faster access to the values in JS land.

PR-URL: #24091
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Refael Ackermann <refack@gmail.com>
MylesBorins mentioned this pull request Dec 22, 2018
MylesBorins pushed a commit that referenced this pull request Dec 25, 2018
Instead of calling into C++ each time we need to check the value
of a command line option, cache the option map in a new
`internal/options` module for faster access to the values in JS land.

PR-URL: #24091
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Refael Ackermann <refack@gmail.com>
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no outstanding review comments, and a CI started. cli Issues and PRs related to the Node.js command line interface. lib / src Issues and PRs related to general changes in the lib or src directory. process Issues and PRs related to the process subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants


Back | FazBrowse Home | New Git URL