Stream: git-wasmtime

Topic: wasmtime / PR #10665 Allow creation of a CacheConfig with...


view this post on Zulip Wasmtime GitHub notifications bot (Apr 24 2025 at 09:27):

benbrandt opened PR #10665 from benbrandt:expose-cache-config to bytecodealliance:main:

Addresses issue #10638

Since creating a CacheConfig also creates the worker thread, I opted for a Builder pattern, so that this worker thread, validation, and default values could be created in the build method, much like what happens when deserializing from a file.

If there is a preferred alternate approach though, let me know.

One thing that came to mind is that we may make it easier to create these worker threads, because it is easier to construct the CacheConfig, but since these threads get cleaned up once the CacheConfig is dropped, maybe this is not an issue?

I'm also not sure if there is any danger in having multiple CacheConfigs pointing to the same directory in terms of the worker threads. But this issue could have existed with multiple Config with the same default config, so I assume this is not a huge issue.

If there are any changes needed, let me know, especially around coding guidelines or best testing practices.

Thanks!
<!--
Please make sure you include the following information:

Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.html

Please ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->

view this post on Zulip Wasmtime GitHub notifications bot (Apr 24 2025 at 09:27):

benbrandt requested alexcrichton for a review on PR #10665.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 24 2025 at 09:27):

benbrandt requested wasmtime-core-reviewers for a review on PR #10665.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 24 2025 at 09:29):

benbrandt updated PR #10665.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 24 2025 at 10:47):

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

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 (Apr 24 2025 at 21:26):

alexcrichton submitted PR review:

Thanks again for this! FWIW the caching system hasn't really been substantially touched since its inception in 2019 so while reading over this I've noticed some other things that I think might be worth implementing, but I also don't want to hitch you with unnecessary work you don't have time to do. In that sense I'd like to see if you're interested in some of these adjacent cleanups perhaps? If not no worries we can go ahead and land this and I can work on some cleanups later.

Would you be up for those changes as well? I've got a few comments on this change in particular below too as well, and again I'm happy to defer the above improvements for later if you'd prefer to not take that on.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 24 2025 at 21:26):

alexcrichton created PR review comment:

While we don't have hard-and-fast conventions in Wasmtime I at least personally prefer builders to take &mut self and return &mut Self (like Config methods). Would you be up to changing to that pattern?

view this post on Zulip Wasmtime GitHub notifications bot (Apr 24 2025 at 21:26):

alexcrichton created PR review comment:

Mind adding some docs to this method since it'll be public-facing in the wasmtime crate API?

view this post on Zulip Wasmtime GitHub notifications bot (Apr 24 2025 at 21:26):

alexcrichton created PR review comment:

Mind adding some documentation here? I'm thinking specifically about some error cases for example.

Additionally if you're ok with the &mut self suggestion above, this would change to either &self (ideally) or &mut self if necessary.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 24 2025 at 21:26):

alexcrichton created PR review comment:

If you're ok I'd prefer to leave this not exposed, it's a bit weird to me to go through the rigamarole of creating a config just to say it's disabled. In that sense I think we should consider CacheConfigBuilder as "always create something with the enabled flag set to true".

view this post on Zulip Wasmtime GitHub notifications bot (Apr 24 2025 at 21:30):

benbrandt commented on PR #10665:

@alexcrichton thanks for the thorough review!
I think all of these changes definitely make sense, and also address some weirdness I felt in implementing this. I can give the changes a try and see how far I get!

view this post on Zulip Wasmtime GitHub notifications bot (Apr 25 2025 at 20:54):

benbrandt updated PR #10665.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 25 2025 at 20:54):

benbrandt submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 25 2025 at 20:54):

benbrandt created PR review comment:

Agreed this indeed felt weird as well, I think we can go with an option on the main config and handle it that way

view this post on Zulip Wasmtime GitHub notifications bot (Apr 25 2025 at 20:55):

benbrandt submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 25 2025 at 20:55):

benbrandt created PR review comment:

I had a feeling this one might come up, and I figured it was a 50/50 chance I got it right :)
Not a problem

view this post on Zulip Wasmtime GitHub notifications bot (Apr 25 2025 at 21:07):

benbrandt updated PR #10665.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 27 2025 at 14:39):

benbrandt updated PR #10665.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 27 2025 at 15:52):

benbrandt updated PR #10665.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 27 2025 at 18:59):

benbrandt updated PR #10665.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 28 2025 at 09:05):

benbrandt updated PR #10665.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 28 2025 at 09:48):

benbrandt updated PR #10665.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 28 2025 at 12:28):

benbrandt updated PR #10665.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 29 2025 at 11:06):

benbrandt updated PR #10665.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 29 2025 at 11:27):

benbrandt updated PR #10665.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 29 2025 at 11:34):

benbrandt updated PR #10665.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 29 2025 at 11:58):

benbrandt updated PR #10665.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 29 2025 at 12:03):

benbrandt updated PR #10665.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 29 2025 at 12:08):

benbrandt updated PR #10665.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 29 2025 at 12:08):

benbrandt has marked PR #10665 as ready for review.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 29 2025 at 12:08):

benbrandt requested wasmtime-default-reviewers for a review on PR #10665.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 29 2025 at 12:08):

benbrandt requested pchickey for a review on PR #10665.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 29 2025 at 12:11):

benbrandt updated PR #10665.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 29 2025 at 12:15):

benbrandt commented on PR #10665:

@alexcrichton Ok I think it is ready for review again. I also think this is all a lot, lot nicer than before, as well as being more flexible.

Notes of breaking changes:

The latter felt kind of weird to leave as an option, since now there is either a Cache or there is not, and it simplified things to not have to worry if it was enabled or not.

However, because of #[serde(deny_unknown_fields)], this will cause existing config files to not work.

If we want to support this old behavior, I am fine with doing so. Users who embed wasmtime will need to update their code regardless, so this might be acceptable.
However, CLI users would have to fix this themselves.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 29 2025 at 12:19):

benbrandt edited a comment on PR #10665:

@alexcrichton Ok I think it is ready for review again. I also think this is all a lot, lot nicer than before, as well as being more flexible.

Notes of breaking changes:

Other notable changes:

The enabled flag felt kind of weird to leave as an option, since now there is either a Cache or there is not, and it simplified things to not have to worry if it was enabled or not.

However, because of #[serde(deny_unknown_fields)], this will cause existing config files to not work.

If we want to support this old behavior, I am fine with doing so. Users who embed wasmtime will need to update their code regardless, so this might be acceptable.
However, CLI users would have to fix this themselves.

Happy to address any and all feedback, I went in circles a bit trying out different things here, so there is likely room for improvement!

view this post on Zulip Wasmtime GitHub notifications bot (Apr 29 2025 at 12:24):

benbrandt updated PR #10665.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 29 2025 at 14:50):

alexcrichton submitted PR review:

Thanks again for your work on this! All the changes here look reasonable to me, and thinking about it I think it's reasonable to leave deny_unknown_fields and drop enabled = true as well. That's a pretty old setting which predated the current CLI flags and configuration system, so I think it's reasonable to take this time to bring it forward to the current era.

view this post on Zulip Wasmtime GitHub notifications bot (Apr 29 2025 at 15:12):

alexcrichton merged PR #10665.

view this post on Zulip Wasmtime GitHub notifications bot (May 29 2025 at 08:16):

dev-null-undefined commented on PR #10665:

The documentation seems outdated https://github.com/bytecodealliance/wasmtime/blob/0fabedfece020cab90124768c3dc94b8d95ca4ab/docs/cli-cache.md#setting-enabled

view this post on Zulip Wasmtime GitHub notifications bot (May 29 2025 at 14:18):

benbrandt commented on PR #10665:

@dev-null-undefined good catch! Made a follow up PR here: https://github.com/bytecodealliance/wasmtime/pull/10859


Last updated: Dec 06 2025 at 07:03 UTC