Stream: git-wasmtime

Topic: wasmtime / PR #8531 wasmtime: Make table lazy-init config...


view this post on Zulip Wasmtime GitHub notifications bot (May 02 2024 at 22:39):

jameysharp opened PR #8531 from jameysharp:table-lazy-init to bytecodealliance:main:

Lazy initialization of tables has trade-offs that we haven't explored in a while. Making it configurable makes it easier to test the effects of these trade-offs on a variety of WebAssembly programs, and allows embedders to decide whether the trade-offs are worth-while for their use cases.

TODO:

I've tested this by temporarily setting the flag to disable lazy-init by default and verifying that the test suite still passes, except for a bunch of Winch tests (as expected), as well as the amusing case of code_too_large::code_too_large_without_panic, which fails because disabling lazy-init deletes enough code that the code is no longer too large.

With lazy-init disabled, the disas tests show that this shaves off six or seven CLIF instructions and a cold block per call_indirect or table_get. The typed-funcrefs.wat test becomes branch-free, with two loads and an indirect call per call_indirect, making it equivalent to the version that uses globals instead of tables.

cc: @cfallin

view this post on Zulip Wasmtime GitHub notifications bot (May 02 2024 at 23:44):

github-actions[bot] commented on PR #8531:

Subscribe to Label Action

cc @saulecabrera

<details>
This issue or pull request has been labeled: "wasmtime:api", "wasmtime:config", "winch"

Thus the following users have been cc'd because of the following labels:

To subscribe or unsubscribe from this label, edit the <code>.github/subscribe-to-label.json</code> configuration file.

Learn more.
</details>

view this post on Zulip Wasmtime GitHub notifications bot (May 02 2024 at 23:44):

github-actions[bot] commented on PR #8531:

Label Messager: wasmtime:config

It looks like you are changing Wasmtime's configuration options. Make sure to
complete this check list:

[fuzzing-config]: https://github.com/bytecodealliance/wasmtime/blob/ca0e8d0a1d8cefc0496dba2f77a670571d8fdcab/crates/fuzzing/src/generators.rs#L182-L194
[fuzzing-docs]: https://docs.wasmtime.dev/contributing-fuzzing.html


<details>

To modify this label's message, edit the <code>.github/label-messager/wasmtime-config.md</code> file.

To add new label messages or remove existing label messages, edit the
<code>.github/label-messager.json</code> configuration file.

Learn more.

</details>

view this post on Zulip Wasmtime GitHub notifications bot (May 03 2024 at 01:13):

jameysharp edited PR #8531:

Lazy initialization of tables has trade-offs that we haven't explored in a while. Making it configurable makes it easier to test the effects of these trade-offs on a variety of WebAssembly programs, and allows embedders to decide whether the trade-offs are worth-while for their use cases.

TODO:

I've tested this by temporarily setting the flag to disable lazy-init by default (in crates/environ/src/tunables.rs) and verifying that the test suite still passes, except for a bunch of Winch tests (as expected), as well as the amusing case of code_too_large::code_too_large_without_panic, which fails because disabling lazy-init deletes enough code that the code is no longer too large.

With lazy-init disabled, the disas tests show that this shaves off six or seven CLIF instructions and a cold block per call_indirect or table_get. The typed-funcrefs.wat test becomes branch-free, with two loads and an indirect call per call_indirect, making it equivalent to the version that uses globals instead of tables.

cc: @cfallin

view this post on Zulip Wasmtime GitHub notifications bot (May 03 2024 at 19:06):

alexcrichton submitted PR review:

I like the idea of adding this, good idea!

Some other bits I might recommend:

view this post on Zulip Wasmtime GitHub notifications bot (May 03 2024 at 19:06):

alexcrichton created PR review comment:

What do you think about perhaps returning enum Funcrefs<'a> { Tagged(&'a [TaggedFuncRef]), Untagged(&'a [*mut VMFuncRef]) } here? That feels a bit more "type safe" if a bit wordier and reflects how this is a boolean decision at runtime as well

view this post on Zulip Wasmtime GitHub notifications bot (May 03 2024 at 19:06):

alexcrichton submitted PR review:

I like the idea of adding this, good idea!

Some other bits I might recommend:

view this post on Zulip Wasmtime GitHub notifications bot (May 03 2024 at 19:06):

alexcrichton created PR review comment:

If this remains (which I think is fine) mind adding a check in Config::validate that returns an error if winch is enabled but lazy init is disabled?

view this post on Zulip Wasmtime GitHub notifications bot (May 03 2024 at 20:33):

jameysharp edited PR #8531:

Lazy initialization of tables has trade-offs that we haven't explored in a while. Making it configurable makes it easier to test the effects of these trade-offs on a variety of WebAssembly programs, and allows embedders to decide whether the trade-offs are worth-while for their use cases.

TODO:

I've tested this by temporarily setting the flag to disable lazy-init by default (in crates/environ/src/tunables.rs) and verifying that the test suite still passes, except for a bunch of Winch tests (as expected), as well as the amusing case of code_too_large::code_too_large_without_panic, which fails because disabling lazy-init deletes enough code that the code is no longer too large.

With lazy-init disabled, the disas tests show that this shaves off six or seven CLIF instructions and a cold block per call_indirect or table_get. The typed-funcrefs.wat test becomes branch-free, with two loads and an indirect call per call_indirect, making it equivalent to the version that uses globals instead of tables.

cc: @cfallin

view this post on Zulip Wasmtime GitHub notifications bot (May 03 2024 at 23:07):

jameysharp submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (May 03 2024 at 23:07):

jameysharp created PR review comment:

I like this idea, but while testing it out, I found so many more things I want to change about how the lazy-tagging invariants are maintained in these modules that I don't think I want to change any of them in this PR. :sweat_smile: A few:

view this post on Zulip Wasmtime GitHub notifications bot (May 06 2024 at 19:30):

alexcrichton submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (May 06 2024 at 19:30):

alexcrichton created PR review comment:

That all sounds great to me yeah, and seems fine to leave this as-is returning a bool in the meantime

view this post on Zulip Wasmtime GitHub notifications bot (May 14 2024 at 03:08):

jameysharp updated PR #8531.

view this post on Zulip Wasmtime GitHub notifications bot (May 14 2024 at 03:09):

jameysharp edited PR #8531:

Lazy initialization of tables has trade-offs that we haven't explored in a while. Making it configurable makes it easier to test the effects of these trade-offs on a variety of WebAssembly programs, and allows embedders to decide whether the trade-offs are worth-while for their use cases.

TODO:

I've tested this by temporarily setting the flag to disable lazy-init by default (in crates/environ/src/tunables.rs) and verifying that the test suite still passes, except for a bunch of Winch tests (as expected), as well as the amusing case of code_too_large::code_too_large_without_panic, which fails because disabling lazy-init deletes enough code that the code is no longer too large.

With lazy-init disabled, the disas tests show that this shaves off six or seven CLIF instructions and a cold block per call_indirect or table_get. The typed-funcrefs.wat test becomes branch-free, with two loads and an indirect call per call_indirect, making it equivalent to the version that uses globals instead of tables.

cc: @cfallin

view this post on Zulip Wasmtime GitHub notifications bot (May 14 2024 at 03:09):

jameysharp has marked PR #8531 as ready for review.

view this post on Zulip Wasmtime GitHub notifications bot (May 14 2024 at 03:09):

jameysharp requested fitzgen for a review on PR #8531.

view this post on Zulip Wasmtime GitHub notifications bot (May 14 2024 at 03:09):

jameysharp requested wasmtime-fuzz-reviewers for a review on PR #8531.

view this post on Zulip Wasmtime GitHub notifications bot (May 14 2024 at 03:09):

jameysharp requested wasmtime-compiler-reviewers for a review on PR #8531.

view this post on Zulip Wasmtime GitHub notifications bot (May 14 2024 at 03:09):

jameysharp requested wasmtime-core-reviewers for a review on PR #8531.

view this post on Zulip Wasmtime GitHub notifications bot (May 14 2024 at 03:27):

jameysharp commented on PR #8531:

I think I've addressed all of your suggestions, Alex; thank you for them!

I'm trying to coax the fuzzer to discover an artificial bug I added in the non-lazy-init configuration just to make sure it can, and it's been running for a while without finding it. So maybe you (or whoever reviews this) can double-check if I did something wrong in the fuzzer configuration?

view this post on Zulip Wasmtime GitHub notifications bot (May 14 2024 at 04:04):

jameysharp commented on PR #8531:

Okay, I've learned that the table_ops fuzzer can't test this because it only uses externref tables, but lazy-init only applies to funcref tables. And the single-inst module-builder for differential doesn't generate tables or table instructions at all.

But I'm still not sure why wasm-smith isn't finding my asserts with either differential or instantiate. I tried both asserting that lazy-init is enabled, and that it's disabled, during codegen in wasmtime-cranelift, and neither one is getting hit.

view this post on Zulip Wasmtime GitHub notifications bot (May 14 2024 at 04:33):

jameysharp commented on PR #8531:

Nevermind, instantiate found my assert a few minutes after I wrote that, and then found the opposite assert after another 20 minutes. And I've also once again run cargo test --test all with table_lazy_init set false, and the only tests that failed were Winch-related (now with the error message from Config::validate) and the code_too_large_without_panic test again.

So I think this is ready to land.

view this post on Zulip Wasmtime GitHub notifications bot (May 14 2024 at 06:44):

github-actions[bot] commented on PR #8531:

Subscribe to Label Action

cc @fitzgen

<details>
This issue or pull request has been labeled: "fuzzing"

Thus the following users have been cc'd because of the following labels:

To subscribe or unsubscribe from this label, edit the <code>.github/subscribe-to-label.json</code> configuration file.

Learn more.
</details>

view this post on Zulip Wasmtime GitHub notifications bot (May 14 2024 at 15:01):

alexcrichton submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (May 14 2024 at 15:27):

alexcrichton merged PR #8531.

view this post on Zulip Wasmtime GitHub notifications bot (May 14 2024 at 16:46):

fitzgen commented on PR #8531:

We should really add a top-down generation mode to wasm-smith...


Last updated: Dec 23 2024 at 13:07 UTC