Stream: git-wasmtime

Topic: wasmtime / PR #4658 Deduplicate some size/align calculations


view this post on Zulip Wasmtime GitHub notifications bot (Aug 09 2022 at 16:43):

alexcrichton opened PR #4658 from deduplicate-size-align to main:

This commit is an effort to reduce the amount of complexity around
managing the size/alignment calculations of types in the canonical ABI.
Previously the logic for the size/alignment of a type was spread out
across a number of locations. While each individual calculation is not
really the most complicated thing in the world having the duplication in
so many places was constantly worrying me.

I've opted in this commit to centralize all of this within the runtime
at least, and now there's only one "duplicate" of this information in
the fuzzing infrastructure which is to some degree less important to
deduplicate. This commit introduces a new CanonicalAbiInfo type to
house all abi size/align information for both memory32 and memory64.
This new type is then used pervasively throughout fused adapter
compilation, dynamic Val management, and typed functions. This type
was also able to reduce the complexity of the macro-generated code
meaning that even wasmtime-component-macro is performing less math
than it was before.

One other major feature of this commit is that this ABI information is
now saved within a ComponentTypes structure. This avoids recursive
querying of size/align information frequently and instead effectively
caching it. This was a worry I had for the fused adapter compiler which
frequently sought out size/align information and would recursively
descend each type tree each time. The fact-valid-module fuzzer is now
nearly 10x faster in terms of iterations/s which I suspect is due to
this caching.

<!--

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 09 2022 at 16:43):

alexcrichton edited PR #4658 from deduplicate-size-align to main:

This commit is an effort to reduce the amount of complexity around
managing the size/alignment calculations of types in the canonical ABI.
Previously the logic for the size/alignment of a type was spread out
across a number of locations. While each individual calculation is not
really the most complicated thing in the world having the duplication in
so many places was constantly worrying me.

I've opted in this commit to centralize all of this within the runtime
at least, and now there's only one "duplicate" of this information in
the fuzzing infrastructure which is to some degree less important to
deduplicate. This commit introduces a new CanonicalAbiInfo type to
house all abi size/align information for both memory32 and memory64.
This new type is then used pervasively throughout fused adapter
compilation, dynamic Val management, and typed functions. This type
was also able to reduce the complexity of the macro-generated code
meaning that even wasmtime-component-macro is performing less math
than it was before.

One other major feature of this commit is that this ABI information is
now saved within a ComponentTypes structure. This avoids recursive
querying of size/align information frequently and instead effectively
caching it. This was a worry I had for the fused adapter compiler which
frequently sought out size/align information and would recursively
descend each type tree each time. The fact-valid-module fuzzer is now
nearly 10x faster in terms of iterations/s which I suspect is due to
this caching.

Closes #4592

<!--

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 09 2022 at 19:39):

fitzgen submitted PR review.

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

alexcrichton merged PR #4658.


Last updated: Oct 23 2024 at 20:03 UTC