feat: improve JavaScript performance by caching the runtime + polyfill #257
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Update the JS runtime to cache the runtime and the given polyfill. After caching it, the worker doesn't need to compile it to bytecode and evaluate it on every run. To accomplish it, we are following an approach similar to Javy. To precompile the polyfill, we use the
wizer
tool. It pre-initializes the JS runtime with the evaluated polyfill. On runtime, the engine only retrieves the preconfigured runtime and compile the user code.The results are pretty amazing 👇
It closes #242
Quick benchmarks
Note that I didn't prepare any special environment for the bechmarks, so they are illustrative
Js-basic example
5000 requests, 20 req/s
See "No Cache" logs
See "Cache" logs
Hono example
See "No Cache" logs
See "Cache" logs