Add experimental support for loading snapshots in the embedder API by adding a public opaque wrapper for our `SnapshotData` struct and allowing embedders to pass it to the relevant setup functions. Where applicable, use these helpers to deduplicate existing code in Node.js’s startup path. This has shown a 40 % startup performance increase for a real-world application, even with the somewhat limited current support for built-in modules. The documentation includes a note about no guarantees for API or ABI stability for this feature while it is experimental. PR-URL: https://github.com/nodejs/node/pull/45888 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
12 lines
240 B
JavaScript
12 lines
240 B
JavaScript
const {
|
|
setDeserializeMainFunction,
|
|
} = require('v8').startupSnapshot;
|
|
|
|
const originalArgv = [...process.argv];
|
|
|
|
setDeserializeMainFunction(() => {
|
|
console.log(JSON.stringify({
|
|
currentArgv: process.argv,
|
|
originalArgv
|
|
}));
|
|
});
|