How do I analyze bundles without symbols?
Closed this issue · 2 comments
I've tried analyzing the bundle I'm building for caniuse.rs with wasm-pack build --target web
but the output is not particularily helpful for any of the subcommands, presumably because symbols have been stripped. Am I doing something wrong?
% twiggy dominators pkg/caniuse_rs_bg.wasm | head -n20
Retained Bytes │ Retained % │ Dominator Tree
────────────────┼────────────┼────────────────────────────────────────────────
320753 ┊ 69.97% ┊ table[0]
292939 ┊ 63.90% ┊ ⤷ elem[2]
40900 ┊ 8.92% ┊ ⤷ code[652]
40892 ┊ 8.92% ┊ ⤷ code[0]
1904 ┊ 0.42% ┊ ⤷ code[135]
1380 ┊ 0.30% ┊ ⤷ code[37]
22224 ┊ 4.85% ┊ ⤷ code[28]
20610 ┊ 4.50% ┊ ⤷ code[116]
19954 ┊ 4.35% ┊ ⤷ code[15]
6521 ┊ 1.42% ┊ ⤷ code[41]
2522 ┊ 0.55% ┊ ⤷ code[124]
1468 ┊ 0.32% ┊ ⤷ code[29]
461 ┊ 0.10% ┊ ⤷ code[147]
1083 ┊ 0.24% ┊ ⤷ code[72]
688 ┊ 0.15% ┊ ⤷ code[108]
611 ┊ 0.13% ┊ ⤷ code[125]
4029 ┊ 0.88% ┊ ⤷ code[32]
1070 ┊ 0.23% ┊ ⤷ code[73]
error: I/O error: Broken pipe (os error 32)
caused by: Broken pipe (os error 32)
(side note: you probably want to copy roughly what ripgrep does to not crash when twiggy's output is piped into another program)
% twiggy top pkg/caniuse_rs_bg.wasm | head -n20
Shallow Bytes │ Shallow % │ Item
───────────────┼───────────┼──────────────────────────────────────────────────
38988 ┊ 8.50% ┊ code[0]
36558 ┊ 7.97% ┊ data[806]
21496 ┊ 4.69% ┊ data[803]
15095 ┊ 3.29% ┊ code[1]
9039 ┊ 1.97% ┊ code[2]
8238 ┊ 1.80% ┊ code[3]
7059 ┊ 1.54% ┊ data[2233]
6920 ┊ 1.51% ┊ code[6]
6837 ┊ 1.49% ┊ code[8]
6631 ┊ 1.45% ┊ code[4]
6357 ┊ 1.39% ┊ code[5]
5775 ┊ 1.26% ┊ code[7]
5426 ┊ 1.18% ┊ code[9]
4927 ┊ 1.07% ┊ code[10]
4766 ┊ 1.04% ┊ code[11]
4458 ┊ 0.97% ┊ data[1]
3656 ┊ 0.80% ┊ data[2231]
2833 ┊ 0.62% ┊ code[13]
error: I/O error: Broken pipe (os error 32)
caused by: Broken pipe (os error 32)
% twiggy monos pkg/caniuse_rs_bg.wasm
Apprx. Bloat Bytes │ Apprx. Bloat % │ Bytes │ % │ Monomorphizations
────────────────────┼────────────────┼───────┼───────┼──────────────────
0 ┊ 0.00% ┊ 0 ┊ 0.00% ┊ Σ [0 Total Rows]
Unfortunately, this is the best information we can give when the custom name section is not present.
wasm-pack build --target web
You may want to configure wasm-pack
to either skip running wasm-opt
entirely, or to make sure that it is passing the -g
flag so that it doesn't strip the custom name section.
See https://rustwasm.github.io/docs/wasm-pack/cargo-toml-configuration.html for details on configuring wasm-pack
.
Skipping wasm-opt
seems like it would make any size profiling pretty pointless, no? Thanks for the the link though! :)