Motoko WASM size diagnosing tips?

I am trying to find the best way to diagnose why one of my Motoko wasm output files is huge

I have tried wasm2wat to see if i could manually inspect it but i get the error 002919d: error: unexpected opcode: 0xc0, so thats not helpful

It probably is one of my dependencies, but I am having to manually go through and see if removing dependencies fixes it.

Was wondering if there were any tips for figuring out size issues besides guessing and checking

NOTE: dfx build 0.15.1 it was ~1.67MB, then after building with 0.15.2, the size is just over 2MB. So not sure whats going on with that? but it made me investigate since it was too large to deploy

Hmm. Also it might be good to know how imports work

When i just have a commented out file and just have actor {} as code i get 126 KB file
With uncommented just the import statements, with no actor code, i get 330 KB file
With everything uncommented i get the over 2MB file

Is this an import optimization? where if its not used it wont be included? Or would there just be something with the code itself?

This is my file that I’m trying to figure out

Seems with my specific issue is that I am including multiple actor classes which end up being ~500KB in size each.
Made a new thread for that

But still interested in the original question about how to figure this out easier

Replace your actor references with actor interfaces unless you are deploying the actor codebase.(And even then you may want to use a factory canister to generate those so you don’t have to import the actor). When you import the actor it puts the compiled wasm into your canister, so you get all the system code in there(possibly multiple times if you have multiple actors).

1 Like