-
Notifications
You must be signed in to change notification settings - Fork 16
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
Add support for wasi:config/runtime
virtualization
#82
Add support for wasi:config/runtime
virtualization
#82
Conversation
Thanks so much for looking into this. Nice to see it implemented as a separate adapter component, to verify - if it's not used, are we able to DCE the adapter similarly to the environment subsystem? I will aim to review in the next few days. |
Currently following the same pattern used for The config adapter is only injected into the module when the config option is enabled. ...and stripped out when not active Something that needs to be handled better is Have you thought about limiting the imported interfaces on the module to not exceed the imports on the wrapped module? I can't think of a reason to expose an import that will never be consumed. |
This makes a lot of sense - a DCE of the virtual module to the known module it is adapting, when the virtual module is not being generated on its own but in this composition. Would you be interested in doing that here or are you thinking of a follow-up perhaps? |
A separate PR that lands first makes sense. I'll be offline for a few days, but can take a look next week. |
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.
Something that needs to be handled better is --allow-all, which adds the wasi:config/runtime import to the resulting module even if the wrapped module doesn't import that interface. Hosts that don't provide the interface (like wasi:http/proxy and wasi:cli/command) will no longer be able to satisfy the module imports.
I wonder if we should change this to support "WASI sets", something like --allow-all
--allow-core
? Where this would be in the all
set but not the core
set?
This PR looks great to me though to land, we just need to ensure we have a test case that covers at least standard configuration use cases. Let me know if I can assist further at all.
b1d6040
to
e6b55aa
Compare
The `wasi:config/runtime` interface is a way to pass configuration to other components with a standard interface. Similar to `wasi:cli/environment` the core data model is a set of key-value pairs. The proposed API and CLI support in WASI-Virt mirrors the support for environment variables that currently exists. The config runtime proposal is currently stage 2 and does not a have a release. Signed-off-by: Scott Andrews <[email protected]>
e6b55aa
to
8313bf9
Compare
let result = Ok(self.props.clone()); | ||
let result = std::future::ready(result); | ||
let result = Box::new(result); | ||
let result = Pin::new(result); |
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.
there's probably a more idiomatic way to construct the result. Async rust is a bit beyond me at the moment.
Rebased on main and added tests/doc. |
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 seems to be the right approach to me. If you can confirm it's definitely not being pulled in for other subsystems I think we're good to land.
I'm exactly sure what you're looking for, so here's a few examples: no host accesswasi-virt -o virt.wasm
package root:component;
world root {
export wasi:cli/environment@0.2.0;
export wasi:config/runtime@0.2.0-draft;
export wasi:cli/exit@0.2.0;
export wasi:random/insecure-seed@0.2.0;
export wasi:random/insecure@0.2.0;
export wasi:random/random@0.2.0;
export wasi:io/error@0.2.0;
export wasi:io/poll@0.2.0;
export wasi:io/streams@0.2.0;
export wasi:clocks/monotonic-clock@0.2.0;
export wasi:clocks/wall-clock@0.2.0;
export wasi:sockets/network@0.2.0;
export wasi:sockets/ip-name-lookup@0.2.0;
export wasi:sockets/tcp@0.2.0;
export wasi:sockets/udp@0.2.0;
export wasi:sockets/instance-network@0.2.0;
export wasi:sockets/tcp-create-socket@0.2.0;
export wasi:sockets/udp-create-socket@0.2.0;
export wasi:http/types@0.2.0;
export wasi:http/incoming-handler@0.2.0;
export wasi:http/outgoing-handler@0.2.0;
export wasi:cli/stdin@0.2.0;
export wasi:cli/stdout@0.2.0;
export wasi:cli/stderr@0.2.0;
export wasi:cli/terminal-input@0.2.0;
export wasi:cli/terminal-output@0.2.0;
export wasi:cli/terminal-stdin@0.2.0;
export wasi:cli/terminal-stdout@0.2.0;
export wasi:cli/terminal-stderr@0.2.0;
export wasi:filesystem/types@0.2.0;
export wasi:filesystem/preopens@0.2.0;
} stdio onlywasi-virt --allow-stdio -o virt.wasm
package root:component;
world root {
import wasi:io/error@0.2.0;
import wasi:io/poll@0.2.0;
import wasi:io/streams@0.2.0;
import wasi:cli/stdin@0.2.0;
import wasi:cli/stdout@0.2.0;
import wasi:cli/stderr@0.2.0;
import wasi:cli/terminal-input@0.2.0;
import wasi:cli/terminal-output@0.2.0;
import wasi:cli/terminal-stdin@0.2.0;
import wasi:cli/terminal-stdout@0.2.0;
import wasi:cli/terminal-stderr@0.2.0;
export wasi:cli/environment@0.2.0;
export wasi:config/runtime@0.2.0-draft;
export wasi:cli/exit@0.2.0;
export wasi:random/insecure-seed@0.2.0;
export wasi:random/insecure@0.2.0;
export wasi:random/random@0.2.0;
export wasi:io/error@0.2.0;
export wasi:io/poll@0.2.0;
export wasi:io/streams@0.2.0;
export wasi:clocks/monotonic-clock@0.2.0;
export wasi:clocks/wall-clock@0.2.0;
export wasi:sockets/network@0.2.0;
export wasi:sockets/ip-name-lookup@0.2.0;
export wasi:sockets/tcp@0.2.0;
export wasi:sockets/udp@0.2.0;
export wasi:sockets/instance-network@0.2.0;
export wasi:sockets/tcp-create-socket@0.2.0;
export wasi:sockets/udp-create-socket@0.2.0;
export wasi:http/types@0.2.0;
export wasi:http/incoming-handler@0.2.0;
export wasi:http/outgoing-handler@0.2.0;
export wasi:cli/stdin@0.2.0;
export wasi:cli/stdout@0.2.0;
export wasi:cli/stderr@0.2.0;
export wasi:cli/terminal-input@0.2.0;
export wasi:cli/terminal-output@0.2.0;
export wasi:cli/terminal-stdin@0.2.0;
export wasi:cli/terminal-stdout@0.2.0;
export wasi:cli/terminal-stderr@0.2.0;
export wasi:filesystem/types@0.2.0;
export wasi:filesystem/preopens@0.2.0;
} runtime config onlywasi-virt --allow-config -o virt.wasm
package root:component;
world root {
import wasi:config/runtime@0.2.0-draft;
export wasi:cli/environment@0.2.0;
export wasi:config/runtime@0.2.0-draft;
export wasi:cli/exit@0.2.0;
export wasi:random/insecure-seed@0.2.0;
export wasi:random/insecure@0.2.0;
export wasi:random/random@0.2.0;
export wasi:io/error@0.2.0;
export wasi:io/poll@0.2.0;
export wasi:io/streams@0.2.0;
export wasi:clocks/monotonic-clock@0.2.0;
export wasi:clocks/wall-clock@0.2.0;
export wasi:sockets/network@0.2.0;
export wasi:sockets/ip-name-lookup@0.2.0;
export wasi:sockets/tcp@0.2.0;
export wasi:sockets/udp@0.2.0;
export wasi:sockets/instance-network@0.2.0;
export wasi:sockets/tcp-create-socket@0.2.0;
export wasi:sockets/udp-create-socket@0.2.0;
export wasi:http/types@0.2.0;
export wasi:http/incoming-handler@0.2.0;
export wasi:http/outgoing-handler@0.2.0;
export wasi:cli/stdin@0.2.0;
export wasi:cli/stdout@0.2.0;
export wasi:cli/stderr@0.2.0;
export wasi:cli/terminal-input@0.2.0;
export wasi:cli/terminal-output@0.2.0;
export wasi:cli/terminal-stdin@0.2.0;
export wasi:cli/terminal-stdout@0.2.0;
export wasi:cli/terminal-stderr@0.2.0;
export wasi:filesystem/types@0.2.0;
export wasi:filesystem/preopens@0.2.0;
} allwasi-virt --allow-all -o virt.wasm
package root:component;
world root {
import wasi:cli/environment@0.2.0;
import wasi:config/runtime@0.2.0-draft;
import wasi:io/error@0.2.0;
import wasi:io/poll@0.2.0;
import wasi:io/streams@0.2.0;
import wasi:clocks/monotonic-clock@0.2.0;
import wasi:sockets/network@0.2.0;
import wasi:sockets/ip-name-lookup@0.2.0;
import wasi:sockets/tcp@0.2.0;
import wasi:sockets/udp@0.2.0;
import wasi:http/types@0.2.0;
import wasi:http/outgoing-handler@0.2.0;
import wasi:cli/stdin@0.2.0;
import wasi:cli/stdout@0.2.0;
import wasi:cli/stderr@0.2.0;
import wasi:cli/terminal-input@0.2.0;
import wasi:cli/terminal-output@0.2.0;
import wasi:cli/terminal-stdin@0.2.0;
import wasi:cli/terminal-stdout@0.2.0;
import wasi:cli/terminal-stderr@0.2.0;
import wasi:clocks/wall-clock@0.2.0;
import wasi:filesystem/types@0.2.0;
import wasi:filesystem/preopens@0.2.0;
export wasi:cli/environment@0.2.0;
export wasi:config/runtime@0.2.0-draft;
export wasi:io/error@0.2.0;
export wasi:io/poll@0.2.0;
export wasi:io/streams@0.2.0;
export wasi:clocks/monotonic-clock@0.2.0;
export wasi:sockets/ip-name-lookup@0.2.0;
export wasi:sockets/tcp@0.2.0;
export wasi:sockets/udp@0.2.0;
export wasi:http/types@0.2.0;
export wasi:http/outgoing-handler@0.2.0;
export wasi:cli/stdin@0.2.0;
export wasi:cli/stdout@0.2.0;
export wasi:cli/stderr@0.2.0;
export wasi:cli/terminal-input@0.2.0;
export wasi:cli/terminal-output@0.2.0;
export wasi:cli/terminal-stdin@0.2.0;
export wasi:cli/terminal-stdout@0.2.0;
export wasi:cli/terminal-stderr@0.2.0;
export wasi:filesystem/types@0.2.0;
export wasi:filesystem/preopens@0.2.0;
} composedThe same component is wrapped for each of the examples below.
package root:component;
world root {
import wasi:logging/logging;
import wasi:config/runtime@0.2.0-draft;
export wasi:cli/run@0.2.0;
} no host accesswasi-virt -o virt.wasm component.wasm
package root:component;
world root {
import wasi:logging/logging;
export wasi:cli/run@0.2.0;
} runtime config onlywasi-virt --allow-config -o virt.wasm component.wasm
package root:component;
world root {
import wasi:logging/logging;
import wasi:config/runtime@0.2.0-draft;
export wasi:cli/run@0.2.0;
} allwasi-virt --allow-all -o virt.wasm component.wasm
package root:component;
world root {
import wasi:logging/logging;
import wasi:config/runtime@0.2.0-draft;
export wasi:cli/run@0.2.0;
} all (without filtering added in #83)wasi-virt --allow-all -o virt.wasm component.wasm
package root:component;
world root {
import wasi:logging/logging;
import wasi:cli/environment@0.2.0;
import wasi:config/runtime@0.2.0-draft;
import wasi:io/error@0.2.0;
import wasi:io/poll@0.2.0;
import wasi:io/streams@0.2.0;
import wasi:clocks/monotonic-clock@0.2.0;
import wasi:sockets/network@0.2.0;
import wasi:sockets/ip-name-lookup@0.2.0;
import wasi:sockets/tcp@0.2.0;
import wasi:sockets/udp@0.2.0;
import wasi:http/types@0.2.0;
import wasi:http/outgoing-handler@0.2.0;
import wasi:cli/stdin@0.2.0;
import wasi:cli/stdout@0.2.0;
import wasi:cli/stderr@0.2.0;
import wasi:cli/terminal-input@0.2.0;
import wasi:cli/terminal-output@0.2.0;
import wasi:cli/terminal-stdin@0.2.0;
import wasi:cli/terminal-stdout@0.2.0;
import wasi:cli/terminal-stderr@0.2.0;
import wasi:clocks/wall-clock@0.2.0;
import wasi:filesystem/types@0.2.0;
import wasi:filesystem/preopens@0.2.0;
export wasi:cli/run@0.2.0;
} |
- clarify config is runtime config in doc Signed-off-by: Scott Andrews <[email protected]>
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.
Ahh, thanks for the summary, it seems this comment got overlooked still:
I wonder if we should change this to support "WASI sets", something like --allow-all --allow-core? Where this would be in the all set but not the core set?
I think we should separate the concept of "wasi core" here somehow, via something like --draft-proposals
or otherwise through the options to act as another layer to avoid this being output for standard workflows that don't specifically have access to this subsystem.
The risk specifically being that a virt component wouldn't run on Wasmtime since it would expect these imports under the flags in use today.
What if we drop it from The interface would still show up on the exports of the virt component, but that should be safe. |
I believe we don't ever include subsystems that aren't explicitly included, are you sure this would still be the case? Cutting the bytes is important I think when features aren't needed. |
I followed the pattern from environment. When the subsystem isn't enabled the interface still exists but the functions are replaced. Lines 273 to 278 in c451261
Lines 233 to 250 in c451261
I generated a set of virt components with this branch and from main@c451261. The latent capability adds 3K over the equivlent., actually using
|
Thanks for confirming - so the exports are still written even when the subsystem is unused, but that isn't an issue for compatibility because exports are always optional for importers. And from a size perspective, we get exactly the same DCE situation as for env. The case where an unused subsystem generates exports are always stub exports anyway and this is the standard approach already, and this PR fully implements strip and stub virt operations to align with that. Appreciated for sharing the numbers as well to verify the DCE! |
The
wasi:config/runtime
interface is a way to pass configuration to other modules with a standard interface. Similar towasi:cli/environment
the core data model is a set of key-value pairs.The proposed API and CLI support in WASI-Virt mirrors the support for environment variables that currently exists.
The config runtime proposal is currently stage 2 and does not a have a release. Because of that, I understand it may not be desirable to land support inside wasi-virt at this time. However, if there is a willingness to move forward, I can refine this PR to DRY-up the similarities between env and config, and flesh out docs, tests, etc.