Repository navigation
vm: allow createCachedData() after module evaluation - #67508
magurotuna wants to merge 1 commit into
Conversation
|
Review requested:
|
|
Welcome to Node.js, and thank you for your first contribution! Before review, please take a moment to read:
Please make sure every commit is signed off. For a first pull request, GitHub Actions require collaborator approval and Jenkins CI must be started by a collaborator or triager, so an initial wait is normal. |
2f22f01 to
ad44309
Compare
|
The V8 change that fixes the stale comment of |
|
I checked that Node's bundled V8 already supports this: |
|
FYI, the |
sourceTextModule.createCachedData() threw ERR_VM_MODULE_CANNOT_CREATE_CACHED_DATA after the module was evaluated. V8 removed this restriction in 2020. A code cache that is created after evaluation can also contain the functions that V8 compiled lazily during the evaluation, so a new module that uses this code cache can compile less. Allow the call after the module has been evaluated. The call still throws while the module is evaluating, and after the evaluation of the module failed. Assisted-by: claude:opus-5.5 Signed-off-by: Yusuke "YT" Tanaka <ytanaka@cloudflare.com>
ad44309 to
cc9cecf
Compare
|
@inoway46 Thanks for the info! rebased |
sourceTextModule.createCachedData()throwsERR_VM_MODULE_CANNOT_CREATE_CACHED_DATAif the module is already evaluated. This check came from #31278, which matched a V8 check at that time. V8 removed its check in https://crrev.com/c/2504256 in Nov 2020, but Node has not caught up with it. So this PR allows the call tocreateCachedData()when the status is'evaluated'. The call still throws while the module is evaluating and after the evaluation failed.This will help speed up the vm pools of Vitest. A code cache created after evaluation can also contain the functions that V8 compiled lazily, so a module that uses it can compile less. A Vitest prototype that uses cached data after evaluation in subsequent test files took 12-24% less wall-clock time on a 500-file benchmark.
I used an AI coding assistant to help write the patch and the tests. I reviewed them.
Refs: https://chromium-review.googlesource.com/c/v8/v8/+/2504256
Refs: https://chromium-review.googlesource.com/c/v8/v8/+/8811778