nodejs / nodejs/performance

Fast path for CommonJS on Module._compile

Open
#139 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Shell
Stars
399
Forks
11
Avg merge
29m
Merged PRs (30d)
1

Description

In theory, we can move the load of content of a module to C++ when:

  • the experimental policy is not enabled
  • and when the module is not ESM
  • and when the module is not patched

Since the content goes directly to the C++ without modification:


Also, I don't have any idea if worth or is viable but maybe we could use StreamedSource instead of Source, in this way, we probably can save some memory and load the script much faster.

Let me know what you think, this is something that was in my mind for a while and I just wanna to share it with more people to understand if is possible or not.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with lib/internal/modules/cjs/loader.js at the referenced content-loading and Module._compile paths, then follow lib/internal/vm.js and src/node_contextify.cc. Review the V8 StreamedSource reference to determine whether either optimization is viable. Done would require an agreed scope, implementation measurements, and evidence of improved loading or memory use.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, javascript, node.js
Domain
performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.