-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create wasmtime::Config from toml #9811
base: main
Are you sure you want to change the base?
Conversation
d53fabf
to
23b1984
Compare
23b1984
to
5427eeb
Compare
Label Messager: wasmtime:configIt looks like you are changing Wasmtime's configuration options. Make sure to
To modify this label's message, edit the To add new label messages or remove existing label messages, edit the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this! I'm liking how this is shaping up pretty cleanly so far. Would you be up for integrating this into a CLI flag itself as well? For example wasmtime --config cfg.toml
or something like that
crates/cli-flags/src/lib.rs
Outdated
pub trait FromFile { | ||
fn from_file<P: AsRef<Path>>(path: P) -> Result<Self> | ||
where | ||
Self: Sized; | ||
} | ||
|
||
impl FromFile for Config { | ||
fn from_file<P: AsRef<Path>>(path: P) -> Result<Self> { | ||
let file_contents = fs::read_to_string(path.as_ref())?; | ||
let mut common_options: CommonOptions = toml::from_str(&file_contents)?; | ||
common_options.config(None) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might perhaps be best as an inherent method on CommonOptions
as an alternative constructor? That would still require the caller call .config(...)
but that seems like a reasonable tradeoff to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, moved to CommonOption::from_file instead. Happy to rename it to something different as well
crates/cli-flags/src/lib.rs
Outdated
|
||
impl FromFile for Config { | ||
fn from_file<P: AsRef<Path>>(path: P) -> Result<Self> { | ||
let file_contents = fs::read_to_string(path.as_ref())?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mind updating the error using .with_context(...)
to attach the name of the file here and below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, addressed!
Thanks for looking at this. I added a --config flag. Any suggestions on how to best test this? |
For tests I'd recommend |
This PR makes it possible to create a
wasmtime::Config
from a toml file and is a first step toward resolving #8784. Overall, I think the path forward is as follows:wasmtime::Config
from a toml file, by makingCommonOptions
deriveDeserialize
. For example,opt_level
is deserialized from values 0, 1, 2, "s" (same as cli flags) instead of "None", "Speed", "SpeedAndSize". Same applies toregalloc_algorithm
,compiler
andcollector
. Feedback appreciated on this.Feedback greatly appreciated, especially regarding how to deal with
nn_graph
, as wellconfig_var
andkeyvalue_in_memory_data
, which are all markedserde(skip)
for now