Closed Bug 1837666 Opened 2 years ago Closed 2 years ago

Check the size of metadata with wasm-GC modules

Categories

(Core :: JavaScript: WebAssembly, task, P3)

task

Tracking

()

RESOLVED FIXED
119 Branch
Tracking Status
firefox119 --- fixed

People

(Reporter: rhunt, Assigned: jpages)

References

Details

Attachments

(3 files)

We have metadata for wasm modules which consume some memory overhead at runtime and size overhead when serializing the module.

With wasm-GC, modules are going to have many more stackmaps than before. We should make sure we're not blowing up our metadata size.

StackMaps are part of wasm::MetadataTier. They're an ordered list of bitmaps.

One thing we could do as part of this is to land some debug-only size tracking methods for modules. This would make it easier to track this over time.

We do have some 'sizeOf' methods already that are part of our about:memory reporting infrastructure [1]. It'd be nice to re-use those, but they work using a callback provided by our embedders which returns the size of memory blocks allocated using malloc.

[1] https://searchfox.org/mozilla-central/rev/d8c5478bd730644dab4336fdb83271ac1ca1d6b5/js/src/wasm/WasmCode.cpp#706

Here are some statistics about metadata sizes for a collection of wasm programs.

https://docs.google.com/spreadsheets/d/1Ykp-WGXF6dO7ITdpEQh_2TWiGnxFZ6uDUH9RsJiSGJ8/edit?usp=sharing

File size are as follow:
4.9M acrobat.wasm
832K amazon-ivs.wasm
52M autocad.wasm
5.0M bergamot.wasm
6.7M canvaskit.wasm
45M clang.wasm
2.4M dotnet.wasm,
21M earth.wasm
155K element.wasm
16M figma.wasm
366K google-meet-echo.wasm
11M google-meet-media.wasm
21K hyphenopoly-en-us.wasm
8.8M js.wasm
115K libopenjph_simd.wasm
80M photoshop.wasm
11M pspdfkit.wasm
9.1M pyodide.wasm
5.6M ruffle-1.wasm
5.7M ruffle-2.wasm
595K sql.wasm
13M stockfish-nnue.wasm
340K stockfish.wasm
374K tensorflow.wasm
990 ublock-biditrie.wasm
1.1K ublock-hntrie.wasm
1.2K ublock-lz4-block-codec.wasm
408 ublock-publicsuffixlist.wasm
1.7M zoom-audio.wasm
3.0M zoom-video.wasm

In general, metadata size seems to be substantial. Metadata represent a 20 to 30% of generated code size for the baseline compiler.
Ion generates less code but the same amount of metadata, this proportion is even higher with 30 to 40% on average.

Also add a function to get trap sites length in metadata.

Use the --wasm-test-metadata to get an analysis of metadata size.
The wasmMetadataAnalysis() function returns a JS dictionary containing
various statistics related to metadata size.

Depends on D187944

Attachment #9352578 - Attachment description: WIP: Bug 1837666 - wasm: Add StackMaps to sizeOfExcludingThis in metadata. → Bug 1837666 - wasm: Add StackMaps to sizeOfExcludingThis in metadata.
Attachment #9352579 - Attachment description: WIP: Bug 1837666 - wasm: Add an option to analyze metadata size. → Bug 1837666 - wasm: Add an option to analyze metadata size.

I've updated the statistics here https://docs.google.com/spreadsheets/d/1Ykp-WGXF6dO7ITdpEQh_2TWiGnxFZ6uDUH9RsJiSGJ8/edit?usp=sharing

I've also tried to run the analysis in debug and release, and got the same results (same sizes).

Attached file profile.js

Here is the script I'm using for collecting statistics in various wasm applications.

Pushed by jpages@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/e27238af0e74 wasm: Add StackMaps to sizeOfExcludingThis in metadata. r=jseward https://hg.mozilla.org/integration/autoland/rev/53f39978c827 wasm: Add an option to analyze metadata size. r=jseward
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 119 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: