-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create an old program to be used in snapshot. #3644
Conversation
@kitsonk if snapshot isolate needs that op you'll probably want to create it in If you have troubles I can look into that in the morning. |
Hmmm, it looks like that's not the problem. I think it's already used. To be hones the error in CI looks like I got intrigued let me tinker with it |
@bartlomieju ah, that is true, I think some of the boilerplate ops stuff hasn't run yet in the compiler.ts. I need to move it to |
@kitsonk this patch will get you further
This is really band-aid and it just ask to do stuff described in #3116 |
Ok, thanks... yeah, moving to |
@bartlomieju got further, but hitting some sort of strange snapshot error in
|
I thought maybe it was because I wasn't setting an I narrowed it down, to if I call I've run into other problems with re-using the old program, but they are now just TypeScript compiler related. |
benchmarks on my machine with master:
with this patch:
🎉 🎉 Still not as quick as I would like it, but hey, that is pretty good. |
@@ -180,7 +180,6 @@ SharedQueue Binary Layout | |||
} | |||
|
|||
function dispatch(opId, control, zeroCopy = null) { | |||
maybeInit(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very tricky and brittle, ideally we'd want to remove this completely, but if tests are green for now I'm okay 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shove maybeInit()
eveywhere because we weren't sure... clearly it is overkill. I can't see of a code path that gets here and initting the shared queue during snapshotting causes a serialization problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's right it's very convoluted. I already started playing with completely removing shared_queue
but surprisingly I get horrible performance and need to put some more work. Ditto, if it passes tests I'm okay with that
@@ -204,6 +204,10 @@ pub fn mksnapshot_bundle_ts( | |||
state: Arc<Mutex<TSState>>, | |||
) -> Result<(), ErrBox> { | |||
let runtime_isolate = &mut Isolate::new(StartupData::None, true); | |||
runtime_isolate.register_op( | |||
"fetch_asset", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It may be worth adding a comment there that this op is added just to handle hydration of oldProgram
- ideally we'll use CompilerIsolate
here (after landing #3116)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually, I realised we don't need this OP as part of the cli when we do it this way, I can strip that out... because everything gets parsed and becomes part of the snapshot, basically the op never fires and doesn't need to be registered in the compiler isolate.
17d70cf
to
52d296b
Compare
@bartlomieju I went back to fix my patch (removing the
|
I'll try locally and get back to you |
@kitsonk my bad, please apply this patch:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
/** **WARNING:** This is only available during the snapshotting process and is | ||
* unavailable at runtime. */ | ||
export let OP_FETCH_ASSET: number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 nice
@kitsonk really impressive!
It also caused a big decrement in syscall count when compilation occurs. However executable size grew from 52Mb to 56,6Mb (because compiler snapshot grew). I wonder if now we could not include all the assets in binary after snapshot step. Anyway, awesome results! |
Ref denoland#3712. This change allowed the deno_typescript crate to reference cli/js/lib.deno_runtime.d.ts which breaks "cargo package". We intend to reintroduce this a revised version of this patch later once "cargo package" is working and tested. This reverts commit 737ab94.
Resolves #3111
This PR caches an "oldProgram" which is effectively the AST of all the foundational libraries as part of the snapshot, which then is re-used when an additional compiler invocation happens.
Original PR text for context
@ry @bartlomieju I'm pretty sure this approach will speed up TypeScript compilation, but I am running across a couple of issues that aren't easy for me to figure out how to resolve. The build is failing during the creation of the compiler snapshot at the unwrap in core bindings:
deno/core/bindings.rs
Lines 438 to 440 in 525784e
I am not really getting a good error message here (feels like we might want to improve that), but I suspect this is because the code in the snapshot actually needs access to a single op from the CLI:
deno/cli/ops/compiler.rs
Lines 23 to 26 in 525784e
Which also would need to have access to all the inlined text resources. It needs to read out some of that, to generate the AST, so that that AST can be reused later (warming up the compiler). I am not sure how to provide OPS to an isolate during snapshotting.