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

module: do less CJS module loader initialization at run time by joyeecheung · Pull Request #47194 · nodejs/node · GitHub

/ node Public

module: do less CJS module loader initialization at run time - #47194

Merged
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
joyeecheung:module-id
Apr 5, 2023
Merged

module: do less CJS module loader initialization at run time#47194
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
joyeecheung:module-id

Conversation

Copy link
Copy Markdown
Member

This patch:

  • Builds the set of modules that can be required by users with/without the node: prefix at snapshot building time. We only modify it when --expose-internals or the flag for experimental wasi module is true but the default set is now in the snapshot. At run time the CJS module loader only creates a frozen array out of it.
  • BuiltinModule.canBeRequiredWithoutScheme() is now enough to determine if an id can be required without node: without an additional call to BuiltinModule.canBeRequiredByUsers()
  • Replace the pending-to-deprecate methods on Module with an internal implementation that only queries the CLI flags when being invoked. So we can install these methods in the snapshot.

Local benchmark numbers:

                                                                                     confidence improvement accuracy (*)   (**)  (***)
misc/startup.js count=30 mode='process' script='benchmark/fixtures/require-builtins'                 0.32 %       ±0.40% ±0.53% ±0.69%
misc/startup.js count=30 mode='process' script='test/fixtures/semicolon'                    ***      1.27 %       ±0.57% ±0.76% ±0.99%
misc/startup.js count=30 mode='worker' script='benchmark/fixtures/require-builtins'                 -0.40 %       ±0.44% ±0.59% ±0.77%
misc/startup.js count=30 mode='worker' script='test/fixtures/semicolon'                              0.23 %       ±0.54% ±0.72% ±0.94%

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/loaders
  • @nodejs/modules
  • @nodejs/startup

nodejs-github-bot added lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Mar 21, 2023

Copy link
Copy Markdown
Collaborator

Copy link
Copy Markdown
Member Author

CI was happy. @nodejs/startup @nodejs/loaders can I have some reviews please?

GeoffreyBooth 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

I guess this doesn’t require any new tests?

Comment thread lib/internal/bootstrap/loaders.js Outdated
Comment thread lib/internal/bootstrap/loaders.js Outdated

Copy link
Copy Markdown
Member Author

I guess this doesn’t require any new tests?

Probably not, the public parts are already well-covered in the tests.

Comment thread lib/internal/modules/cjs/loader.js Outdated

Copy link
Copy Markdown
Member Author

Rebased to remove the wasi experimental flag now that #47286 landed, so the experimentalModuleList is now empty (I kept it here though, so that people can add experimental modules to it later, the isn't a runtime cost after this anyway)

Copy link
Copy Markdown
Collaborator

Copy link
Copy Markdown
Collaborator

This patch:

- Builds the set of modules that can be required by users with/without
  the `node:` prefix at snapshot building time. We only modify it when
  `--expose-internals` but the default set is now in the snapshot. At
  run time the CJS module loader only creates a frozen array out of it.
- `BuiltinModule.canBeRequiredWithoutScheme()` is now enough to
  determine if an id can be required without `node:` without an
  additional call to `BuiltinModule.canBeRequiredByUsers()`
- Replace the pending-to-deprecate methods on `Module` with an internal
  implementation that only queries the CLI flags when being invoked.
  So we can install these methods in the snapshot.

Copy link
Copy Markdown
Member Author

Rebased to move the changes to loaders.js to realm.js

Copy link
Copy Markdown
Collaborator

joyeecheung added the commit-queue Add this label to land a pull request using GitHub Actions. label Apr 5, 2023
nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Apr 5, 2023
nodejs-github-bot merged commit 5572f8f into nodejs:main Apr 5, 2023

Copy link
Copy Markdown
Collaborator

Landed in 5572f8f

RafaelGSS pushed a commit that referenced this pull request Apr 5, 2023
This patch:

- Builds the set of modules that can be required by users with/without
  the `node:` prefix at snapshot building time. We only modify it when
  `--expose-internals` but the default set is now in the snapshot. At
  run time the CJS module loader only creates a frozen array out of it.
- `BuiltinModule.canBeRequiredWithoutScheme()` is now enough to
  determine if an id can be required without `node:` without an
  additional call to `BuiltinModule.canBeRequiredByUsers()`
- Replace the pending-to-deprecate methods on `Module` with an internal
  implementation that only queries the CLI flags when being invoked.
  So we can install these methods in the snapshot.

PR-URL: #47194
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
RafaelGSS mentioned this pull request Apr 6, 2023
RafaelGSS pushed a commit that referenced this pull request Apr 6, 2023
This patch:

- Builds the set of modules that can be required by users with/without
  the `node:` prefix at snapshot building time. We only modify it when
  `--expose-internals` but the default set is now in the snapshot. At
  run time the CJS module loader only creates a frozen array out of it.
- `BuiltinModule.canBeRequiredWithoutScheme()` is now enough to
  determine if an id can be required without `node:` without an
  additional call to `BuiltinModule.canBeRequiredByUsers()`
- Replace the pending-to-deprecate methods on `Module` with an internal
  implementation that only queries the CLI flags when being invoked.
  So we can install these methods in the snapshot.

PR-URL: #47194
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>

Copy link
Copy Markdown
Member

Hi @joyeecheung this commit also didn't land cleanly, could you please backport it?

RafaelGSS pushed a commit that referenced this pull request Apr 13, 2023
This patch:

- Builds the set of modules that can be required by users with/without
  the `node:` prefix at snapshot building time. We only modify it when
  `--expose-internals` but the default set is now in the snapshot. At
  run time the CJS module loader only creates a frozen array out of it.
- `BuiltinModule.canBeRequiredWithoutScheme()` is now enough to
  determine if an id can be required without `node:` without an
  additional call to `BuiltinModule.canBeRequiredByUsers()`
- Replace the pending-to-deprecate methods on `Module` with an internal
  implementation that only queries the CLI flags when being invoked.
  So we can install these methods in the snapshot.

PR-URL: #47194
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
targos pushed a commit that referenced this pull request Nov 10, 2023
This patch:

- Builds the set of modules that can be required by users with/without
  the `node:` prefix at snapshot building time. We only modify it when
  `--expose-internals` but the default set is now in the snapshot. At
  run time the CJS module loader only creates a frozen array out of it.
- `BuiltinModule.canBeRequiredWithoutScheme()` is now enough to
  determine if an id can be required without `node:` without an
  additional call to `BuiltinModule.canBeRequiredByUsers()`
- Replace the pending-to-deprecate methods on `Module` with an internal
  implementation that only queries the CLI flags when being invoked.
  So we can install these methods in the snapshot.

PR-URL: #47194
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
sercher added a commit to sercher/graaljs that referenced this pull request Apr 25, 2024
This patch:

- Builds the set of modules that can be required by users with/without
  the `node:` prefix at snapshot building time. We only modify it when
  `--expose-internals` but the default set is now in the snapshot. At
  run time the CJS module loader only creates a frozen array out of it.
- `BuiltinModule.canBeRequiredWithoutScheme()` is now enough to
  determine if an id can be required without `node:` without an
  additional call to `BuiltinModule.canBeRequiredByUsers()`
- Replace the pending-to-deprecate methods on `Module` with an internal
  implementation that only queries the CLI flags when being invoked.
  So we can install these methods in the snapshot.

PR-URL: nodejs/node#47194
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
sercher added a commit to sercher/graaljs that referenced this pull request Apr 25, 2024
This patch:

- Builds the set of modules that can be required by users with/without
  the `node:` prefix at snapshot building time. We only modify it when
  `--expose-internals` but the default set is now in the snapshot. At
  run time the CJS module loader only creates a frozen array out of it.
- `BuiltinModule.canBeRequiredWithoutScheme()` is now enough to
  determine if an id can be required without `node:` without an
  additional call to `BuiltinModule.canBeRequiredByUsers()`
- Replace the pending-to-deprecate methods on `Module` with an internal
  implementation that only queries the CLI flags when being invoked.
  So we can install these methods in the snapshot.

PR-URL: nodejs/node#47194
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
Reviewed-By: Chengzhong Wu <legendecas@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

lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants


Back | FazBrowse Home | New Git URL