-
Notifications
You must be signed in to change notification settings - Fork 116
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
Reduce loading time #1073
Reduce loading time #1073
Conversation
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.
Note for reviewers: all the non-trivial changes are in the linked PRs (Mina, bindings, snarky)
@@ -1,3 +1,4 @@ | |||
import './bindings/crypto/bindings.js'; |
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.
so, here's how this is supposed to work:
the new bindings.ts
file imported here is written in TS, and contains code integrated with our normal codebase. It is exposed to JSOO by populating a global variable with an object. It gets imported as the first thing here so that the global variable is ready by the time JSOO code gets executed.
It may not be the cleanest thing to have an implicit dependency like that, but it's a huge improvement over the status quo, where all JS code used in JSOO has to be part of an ugly file containing outdated syntax which can use neither TS nor normal imports.
Can't you do the parsing lazily? You could use a dynamic import instead. If you use the separate jsoo compilation, you can maybe even import each separately lazily. |
we can (we do) but then you can't use the lib directly after import. we'd get back |
PR to reduce the startup time of SnarkyJS
Closes #1065
Bindings: o1-labs/o1js-bindings#116
Mina: MinaProtocol/mina#13925
Snarky: o1-labs/snarky#829
Benchmark (node):
Time to import at various steps:
Web flame graph of the first ~2 seconds, before:
Same flame graph after:
Note: There's basically no way to reduce this further within the current architecture. After this PR, most of the loading time of ~0.5sec comes from compiling the JS bundle, which is large. Of the time spent executing that bundle, most happens in core JSOO / OCaml libs. There's only about 50ms of top-level computation caused by Mina code. Some of which is just instantiating modules that we need. There's almost nothing left that we can get rid of.