You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Persist the V8 code cache before spawning a child process #54465
NODE_COMPILE_CACHE persists the V8 code cache when the process is terminating which means that if the script spawns itself then that child process wont benefit from the cache.
What is the feature you are proposing to solve the problem?
Persist the V8 code cache before spawning a child process so it can benefit from the cache.
import{execFileSync}from"child_process";if(process.argv[2]==="foo"){console.log("foo");}else{// Persist the V8 code cacheconsole.log(execFileSync("node",["test.mjs","foo"]).toString());}
I wonder if we should just provide an API for the user to tell Node.js to persist the cache of modules already loaded (that would be similar to v8.takeCoverage() which flushes the coverage accumulated via NODE_V8_COVERAGE to disk). It can be tricky to persist the cache implicitly for any child process calls - either it needs to be blocking, then it could actually make the child process calls wait for it if the cache is big enough, or it needs to be non-blocking, then it's questionable whether the new child process actually get to pick it up - it might finish startup earlier than the persistence of the cache completes. Only the party spawning the child process knows what is the best for the kind of child process that they are spawning.
Also I am not sure how big of a problem this is - you won't get to pick up the cache the first time this application is launched, but you will get it the second time the application is launched anyway. Both the main and the child processes will pick it up from the same store, so the coverage is only missing for the child processes in the first launch.
Activity
joyeecheung commentedon Aug 21, 2024
I wonder if we should just provide an API for the user to tell Node.js to persist the cache of modules already loaded (that would be similar to
v8.takeCoverage()which flushes the coverage accumulated viaNODE_V8_COVERAGEto disk). It can be tricky to persist the cache implicitly for any child process calls - either it needs to be blocking, then it could actually make the child process calls wait for it if the cache is big enough, or it needs to be non-blocking, then it's questionable whether the new child process actually get to pick it up - it might finish startup earlier than the persistence of the cache completes. Only the party spawning the child process knows what is the best for the kind of child process that they are spawning.Also I am not sure how big of a problem this is - you won't get to pick up the cache the first time this application is launched, but you will get it the second time the application is launched anyway. Both the main and the child processes will pick it up from the same store, so the coverage is only missing for the child processes in the first launch.
joyeecheung commentedon Sep 16, 2024
Opened #54971
module: throw when invalid argument is passed to enableCompileCache()
module: implement flushCompileCache()
module: write compile cache to temporary file and then rename it
module: write compile cache to temporary file and then rename it
module: throw when invalid argument is passed to enableCompileCache()
module: implement flushCompileCache()