GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||
GeezerVison is showing github.com — sea: snapshot support in single executable applications by joyeecheung · Pull Request #46824 · nodejs/node Conversation
|
|
Review requested:
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Thanks for doing this!
I personally really like this approach. I've opened a discussion in nodejs/single-executable#58, so that we can have a decision on this. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
d830718 to
e94ac97
Compare
e94ac97 to
8dec8b7
Compare
|
Rebased using the new SnapshotBuilder::Generate() overload added in #48242 and added a test. Will add more doc and tests next week but the implementation is there. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
What's the difference between snapshot and code cache (bytenode)? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
8dec8b7 to
eb703f7
Compare
There was an error while loading. Please reload this page.
If you have a bunch of top level code with a bunch of inner functions, usually when building the snapshot you run all the top level code and compile some of the inner functions, the snapshot contains the state of the heap after the top-level code is run and the bytecode of the inner functions that would be run again later. When deserializing the snapshot, you deserialize the state of an initialized heap (so there is no need to run the top-level code at all), and maybe later when the application invokes some of the inner functions, V8 deserialize the bytecode in the snapshot during the compilation of the function to speed things up. If there's just the code cache, what usually happens is that you have the bytecode of the top-level code and some inner functions. At runtime V8 deserializes the bytecode in the code cache to speed up compilation of the top-level code, but it still needs to run the top-level code to set up the heap. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
eb703f7 to
b91bfcd
Compare
b91bfcd to
a71e4ac
Compare
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
CI is almost green (with some flakes that look irrelevant). Can I have some reviews please? @nodejs/single-executable thanks! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Thank you @joyeecheung for your detailed explain :-) So, if I understood it correctly, a snapshoot is a combo of a module compiled and bytecode functions plus heap after executing the module top level code, while the code cache only have the bytecode of all the module code, isn't it? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Roughly yes. V8 does not always emit bytecode for all the code it encounters (e.g. inner-inner functions are usually just parsed for syntax checks, but no bytecode is generated until they actually get executed). In some cases snapshots may contain more bytecode if during the snapshot building cases these functions are invoked. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Maybe bytenode is forcing its generation? Could it of our interest when generating the snapshots, so no Javascript code is included in it? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@RaisenTen can you please confirm you are comfortable with this based on nodejs/single-executable#58 and nodejs/single-executable#58 (reply in thread) landing |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
I would say that's not always a win, you could also have a lot of dead code in that application, or code that never gets run in many use cases, then eagerly generating code may result in a memory/size overhead that's not always worth it. As a configurable thing that might be useful though. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I can try to take a look day after tomorrow. (I'll be traveling pretty much the entire day tomorrow) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Agree on that 👍🏻 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Commit Queue failed- Loading data for nodejs/node/pull/46824 ✔ Done loading data for nodejs/node/pull/46824 ----------------------------------- PR info ------------------------------------ Title sea: snapshot support in single executable applications (#46824) Author Joyee Cheung (@joyeecheung) Branch joyeecheung:sea-snapshot -> nodejs:main Labels c++, lib / src, needs-ci, commit-queue-squash, single-executable Commits 4 - src: support snapshot in single executable applications - fixup! src: support snapshot in single executable applications - fixup! fixup! src: support snapshot in single executable applications - fixup! fixup! fixup! src: support snapshot in single executable appli… Committers 1 - Joyee Cheung PR-URL: https://github.com/nodejs/node/pull/46824 Refs: https://github.com/nodejs/single-executable/discussions/57 Reviewed-By: Benjamin Gruenbaum Reviewed-By: Darshan Sen ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/46824 Refs: https://github.com/nodejs/single-executable/discussions/57 Reviewed-By: Benjamin Gruenbaum Reviewed-By: Darshan Sen -------------------------------------------------------------------------------- ℹ This PR was created on Fri, 24 Feb 2023 18:28:13 GMT ✔ Approvals: 2 ✔ - Benjamin Gruenbaum (@benjamingr) (TSC): https://github.com/nodejs/node/pull/46824#pullrequestreview-1482036842 ✔ - Darshan Sen (@RaisinTen) (TSC): https://github.com/nodejs/node/pull/46824#pullrequestreview-1538950503 ✘ Last GitHub CI failed ℹ Last Full PR CI on 2023-07-20T18:44:40Z: https://ci.nodejs.org/job/node-test-pull-request/52874/ - Querying data for job/node-test-pull-request/52874/ ✔ Last Jenkins CI successful -------------------------------------------------------------------------------- ✔ Aborted `git node land` session in /home/runner/work/node/node/.ncuhttps://github.com/nodejs/node/actions/runs/5615590467 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Landed in ac34e75 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| ### Startup snapshot support | ||
| The `useSnapshot` field can be used to enable startup snapshot support. In this | ||
| case the `main` script would not be when the final executable is launched. |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
It's missing a run: "would not be run"
Sorry, something went wrong.
There was an error while loading. Please reload this page.
This patch adds snapshot support to single executable applications.
To build a snapshot from the main script when preparing the
blob that will be injected into the single executable application,
add `"useSnapshot": true` to the configuration passed to
`--experimental-sea-config`. For example:
```
{
"main": "snapshot.js",
"output": "sea-prep.blob",
"useSnapshot": true
}
```
The main script used to build the snapshot must invoke
`v8.startupSnapshot.setDeserializeMainFunction()` to configure the
entry point. The generated startup snapshot would be part of the
preparation blob and get injected into the final executable.
When the single executable application is launched, instead of running
the `main` script from scratch, Node.js would instead deserialize the
snapshot to get to the state initialized during build-time directly.
PR-URL: nodejs#46824
Refs: nodejs/single-executable#57
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Darshan Sen <[email protected]>
This patch adds snapshot support to single executable applications.
To build a snapshot from the main script when preparing the
blob that will be injected into the single executable application,
add `"useSnapshot": true` to the configuration passed to
`--experimental-sea-config`. For example:
```
{
"main": "snapshot.js",
"output": "sea-prep.blob",
"useSnapshot": true
}
```
The main script used to build the snapshot must invoke
`v8.startupSnapshot.setDeserializeMainFunction()` to configure the
entry point. The generated startup snapshot would be part of the
preparation blob and get injected into the final executable.
When the single executable application is launched, instead of running
the `main` script from scratch, Node.js would instead deserialize the
snapshot to get to the state initialized during build-time directly.
PR-URL: nodejs#46824
Refs: nodejs/single-executable#57
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Darshan Sen <[email protected]>
This patch adds snapshot support to single executable applications.
To build a snapshot from the main script when preparing the
blob that will be injected into the single executable application,
add `"useSnapshot": true` to the configuration passed to
`--experimental-sea-config`. For example:
```
{
"main": "snapshot.js",
"output": "sea-prep.blob",
"useSnapshot": true
}
```
The main script used to build the snapshot must invoke
`v8.startupSnapshot.setDeserializeMainFunction()` to configure the
entry point. The generated startup snapshot would be part of the
preparation blob and get injected into the final executable.
When the single executable application is launched, instead of running
the `main` script from scratch, Node.js would instead deserialize the
snapshot to get to the state initialized during build-time directly.
PR-URL: nodejs#46824
Refs: nodejs/single-executable#57
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Darshan Sen <[email protected]>
This patch adds snapshot support to single executable applications.
To build a snapshot from the main script when preparing the
blob that will be injected into the single executable application,
add `"useSnapshot": true` to the configuration passed to
`--experimental-sea-config`. For example:
```
{
"main": "snapshot.js",
"output": "sea-prep.blob",
"useSnapshot": true
}
```
The main script used to build the snapshot must invoke
`v8.startupSnapshot.setDeserializeMainFunction()` to configure the
entry point. The generated startup snapshot would be part of the
preparation blob and get injected into the final executable.
When the single executable application is launched, instead of running
the `main` script from scratch, Node.js would instead deserialize the
snapshot to get to the state initialized during build-time directly.
PR-URL: #46824
Refs: nodejs/single-executable#57
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Darshan Sen <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.