Stream: git-wasmtime

Topic: wasmtime / PR #4584 Use a `SmallVec` for `ABIArg`s


view this post on Zulip Wasmtime GitHub notifications bot (Aug 02 2022 at 21:37):

fitzgen opened PR #4584 from abi-arg-small-vec to main:

Instead of a regular Vec.

These vectors are usually very small, for example here is the histogram of sizes
when running Sightglass's pulldown-cmark benchmark:

;; Number of samples = 10332
;; Min = 0
;; Max = 11
;;
;; Mean = 2.496128532713901
;; Standard deviation = 2.2859559855427243
;; Variance = 5.225594767838607
;;
;; Each  is a count of 62
;;
 0 ..  1 [ 3134 ]: ∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
 1 ..  2 [ 2032 ]: ∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
 2 ..  3 [  159 ]: ∎∎
 3 ..  4 [  838 ]: ∎∎∎∎∎∎∎∎∎∎∎∎∎
 4 ..  5 [  970 ]: ∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
 5 ..  6 [ 2566 ]: ∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎∎
 6 ..  7 [  303 ]: ∎∎∎∎
 7 ..  8 [  272 ]: ∎∎∎∎
 8 ..  9 [   40 ]:
 9 .. 10 [   18 ]:

By using a SmallVec with capacity of 6 we avoid the vast majority of heap
allocations and get some nice benchmark wins of up to ~1.11x faster compilation.

<h3>Sightglass Benchmark Results</h3>

compilation :: nanoseconds :: benchmarks/spidermonkey/benchmark.wasm

  Δ = 340361395.90 ± 63384608.15 (confidence = 99%)

  main.so is 0.88x to 0.92x faster than smallvec.so!
  smallvec.so is 1.09x to 1.13x faster than main.so!

  [3101467423 3425524333.41 4060621653] main.so
  [2820915877 3085162937.51 3375167352] smallvec.so

compilation :: cycles :: benchmarks/spidermonkey/benchmark.wasm

  Δ = 988446098.59 ± 184075718.89 (confidence = 99%)

  main.so is 0.88x to 0.92x faster than smallvec.so!
  smallvec.so is 1.09x to 1.13x faster than main.so!

  [9006994951 9948091070.66 11792481990] main.so
  [8192243090 8959644972.07 9801848982] smallvec.so

compilation :: nanoseconds :: benchmarks/bz2/benchmark.wasm

  Δ = 7854567.87 ± 2215491.16 (confidence = 99%)

  main.so is 0.89x to 0.94x faster than smallvec.so!
  smallvec.so is 1.07x to 1.12x faster than main.so!

  [80354527 93864666.76 119789198] main.so
  [77554917 86010098.89 94726994] smallvec.so

compilation :: cycles :: benchmarks/bz2/benchmark.wasm

  Δ = 22810509.85 ± 6434024.63 (confidence = 99%)

  main.so is 0.89x to 0.94x faster than smallvec.so!
  smallvec.so is 1.07x to 1.12x faster than main.so!

  [233358190 272593088.57 347880715] main.so
  [225227821 249782578.72 275097380] smallvec.so

compilation :: nanoseconds :: benchmarks/pulldown-cmark/benchmark.wasm

  Δ = 10849521.41 ± 4324757.85 (confidence = 99%)

  main.so is 0.90x to 0.96x faster than smallvec.so!
  smallvec.so is 1.04x to 1.10x faster than main.so!

  [133875427 156859544.47 222455440] main.so
  [126073854 146010023.06 181611647] smallvec.so

compilation :: cycles :: benchmarks/pulldown-cmark/benchmark.wasm

  Δ = 31508176.97 ± 12559561.91 (confidence = 99%)

  main.so is 0.90x to 0.96x faster than smallvec.so!
  smallvec.so is 1.04x to 1.10x faster than main.so!

  [388788638 455536988.31 646034523] main.so
  [366132033 424028811.34 527419755] smallvec.so

<!--

Please ensure that the following steps are all taken care of before submitting
the PR.

Please ensure all communication adheres to the code of conduct.
-->

view this post on Zulip Wasmtime GitHub notifications bot (Aug 02 2022 at 21:37):

fitzgen requested cfallin for a review on PR #4584.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 02 2022 at 21:41):

cfallin submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 02 2022 at 21:41):

cfallin submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 02 2022 at 21:41):

cfallin created PR review comment:

Can we put a type ABIArgVec SmallVec<[ABIArg; 6]> in machinst::abi_impl then use it here (and ABIArgVec::new()` below)? That would allow us to tweak the size later more easily without updating each backend.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 02 2022 at 21:41):

cfallin edited PR review comment.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 02 2022 at 21:52):

fitzgen updated PR #4584 from abi-arg-small-vec to main.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 02 2022 at 21:57):

cfallin submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 02 2022 at 21:57):

cfallin created PR review comment:

little nit: we can use ABIArgVec here too I think...

view this post on Zulip Wasmtime GitHub notifications bot (Aug 02 2022 at 21:58):

fitzgen updated PR #4584 from abi-arg-small-vec to main.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 02 2022 at 21:58):

fitzgen submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Aug 02 2022 at 21:58):

fitzgen created PR review comment:

Thanks! missed that one

view this post on Zulip Wasmtime GitHub notifications bot (Aug 02 2022 at 22:53):

fitzgen merged PR #4584.


Last updated: Dec 23 2024 at 12:05 UTC