Open Bug 1939039 Opened 2 months ago Updated 1 month ago

Using UniFFI on desktop often bloats the installer size

Categories

(Toolkit :: UniFFI Bindings, defect, P2)

defect

Tracking

()

People

(Reporter: markh, Unassigned)

References

Details

eg, landing tabs caused bug 1798266, converting webext-storage to use uniffi caused bug 1939022. We probably need to avoid this happening for every new component, and ideally work out how to address the 2 mentioned.

See Also: → 1939258
See Also: 1939258

Sorry about the duplicate above. Just adding one more for webext-storage. If I am mistaken, feel free to undo.

I did a bit of digging on why this is. The result is I have no idea, but I don't think it's UniFFI directly.

readelf does a pretty good job at listing symbols and their sizes. On my machine readelf --syms obj-x86_64-pc-linux-gnu/dist/bin/libxul.so -W | grep -i webext prints out a lot of symbols, including:

  • UniFFI generated scaffolding: uniffi_webext_storage_checksum_method_webextstoragebridgedengine_sync_finished)
  • UniFFI metadata: UNIFFI_META_UDL_WEBEXTSTORAGE (there's not a lot here since webext storage uses UDL).
  • Rust functions: _ZN14webext_storage4sync6bridge26WebExtStorageBridgedEngine12set_uploaded17hf65181f31073eee9E
  • uniffi-bindgen-gecko-js generated code: _ZN7mozilla6uniffi72ScaffoldingCallHandlerUniffiWebextStorageFnMethodWebextstoragestoreClearD0Ev

Estimated sizes

  • All UniFFI generated symbols: ~34k
  • uniffi-bindgen-gecko-js symbols: ~19k
  • Rust symbols: ~71K
  • I took a look and saw that the metadata for suggest was about 11k

Methodology

I started each shell pipeline with readelf --syms obj-x86_64-pc-linux-gnu/dist/bin/libxul.so -W | grep -i uniffi
I ended each with | awk -F' ' '{sum+=$3;} END{print sum;}'

In the middle was an extra grep filter:

  • Rust symbols: grep 'ZN.*webext' (I'm somewhat confident I got this right, but I might be missing something)
  • UniFFI: grep -i uniffi
    • Then I noticed that some of our symbols have the form ffi_*. I used in grep ' ffi_webext_storage to capture those.
  • Rust symbols: Filtered using grep 'mozilla.*uniffi'

Conclusions

  • I don't think the UniFFI generated code was a significant contributor to this size increase.
  • Stripping metadata symbols would give us a free win (if this isn't already happening somewhere further down the pipeline)
  • The size of the generated C++ code is somewhat significant and it would be nice to lower this.
You need to log in before you can comment on or make changes to this bug.