Repository navigation
feat: backend comparison benchmarks - #2299
vados-cosmonic wants to merge 6 commits into
Conversation
4aef636 to
feaa7d2
Compare
| | -------------------------------- | ------------: | -------------: | | ||
| | Perry | 11.42 MiB | 7.40 MiB | | ||
| | componentize-js (StarlingMonkey) | 15.99 MiB | 15.42 MiB | | ||
| | componentize-qjs (QuickJS) | 6.79 MiB | 6.66 MiB | |
There was a problem hiding this comment.
Size of Perry and QuickJS components is a bit surprising here. For example componentize-qjs@0.5.0 hello world is producing component that is ~1.4M, and just under 1M when you use --opt-size. I would expect Perry is even less than that? Is it the size of script or is it aot compiled with wasmtime?
There was a problem hiding this comment.
yeah I was incredibly confused by this as well which is why this hasn't merged -- trying to figure out what is causing I expected something in the 100s of kbs.
My guess is that Perry here is including all the nodejs compat by default, but I need to figure out if there's an easy minimal build.
There was a problem hiding this comment.
OK so yeah it looks like the main reason is primarily the included JS runtime that ends up being pulled in, and you can get down to 3.xMB... But how to consistently get it smaller might require more work.
Being able to do this dynamically for components (and get a small build) is going to be somewhat difficult, and those changes would also probably need to go up to perry-wit anyway if we pick that up).
There was a problem hiding this comment.
Interesting! Just for reference, here are componentize-qjs hello world sizes:
$ componentize-qjs --wit examples/hello.wit --js examples/hello.js -o hello.wasm
componentize-qjs
WIT: examples/hello.wit
JS: examples/hello.js
Output: hello.wasm
Component written to hello.wasm
Size: 1450762 bytes
$ componentize-qjs --wit examples/hello.wit --js examples/hello.js -o hello.wasm --opt-size
componentize-qjs
WIT: examples/hello.wit
JS: examples/hello.js
Output: hello.wasm
Component written to hello.wasm
Size: 966512 bytes
There was a problem hiding this comment.
When it comes to optimization, qjs comes with prebuilt runtime components which have already been optimized with wasm-opt for speed or size. --opt-size switches runtime component.
There was a problem hiding this comment.
Yeah it's a bit unfortunate but I think Perry isn't at a point where it can produce the size of binaries that match what we expect just yet.
I'm starting to think that actually what we want if we're going to AOT in the first place is not to bring a runtime at all and an approach like https://github.com/drogus/jawsm is what we want for truly small binaries.
Clearly there needs to be more work done in perry to make it more minimal!
There was a problem hiding this comment.
I wonder if there is an easy win here opt-ing all the prebuilt runtime components that perry uses as well.
There was a problem hiding this comment.
What about quickjs? Why is it 4x bigger than expected?
There was a problem hiding this comment.
Yeah so it looks like it's the node adapter code-- note that the code in question uses the node SDK as if it's real: https://github.com/vados-cosmonic/jco/blob/5d95cb6f3d60327a5b260d1a6a2ca1c20bf810e9/packages/jco/test/bench/fixtures/filesystem/guest.ts
Perry has built in NodeJS SDK support, but componentize-qjs doesn't so we use the jco-provided NodeJS SDK (at least only the parts pulled in by fliesystem stuff should be added).
I think the file system adapter may not be as tree-shakeable as I thought, and once you have that code initialized in the quickJS wasm snapshot it gets much bigger.
There was a problem hiding this comment.
I'm going to start a new branch and put some 🤖 s on whether jco-std can be refactored to tree shake better and reduce the size.
5d95cb6 to
44a574b
Compare
Signed-off-by: Victor Adossi <vadossi@cosmonic.com>
5237dcf to
3ebc5f7
Compare
No description provided.