Reduce dependencies on cap-std-family crates#13872
Open
alexcrichton wants to merge 2 commits into
Open
Conversation
This commit is an attempt to reduce the number of layers of abstraction that we have for the `wasmtime-wasi` crate and implementation, in particular around the dependencies that we have. Historically `wasmtime-wasi` has primarily depended on `cap-std` which provides a `std`-like API for using the native filesystem and other features (e.g. networking). Over time networking has largely moved away from `cap-std`, however. I've additionally historically found it difficult to trace through the tree of dependencies for figuring out what a WASI call does. This requires following code in `wasmtime-wasi`, to `cap-std`, to `cap-*-ext` sometimes, to `cap-primitives`, then to `rustix`. The goal of this commit is to shorten this chain and instead primarily rely on the "meat" of `cap-std`, the `cap-primitives` crate. The `cap-std` crate additionally serves a bit of a dual purpose of providing filesystem sandboxing and abstracting the underlying platform. This abstraction though is a bit leaky where the API is different enough across platforms that it can come at a performance cost on some platforms while also still needing `#[cfg]`s on others. This commit additionally is intended to reduce the reliance on this portability layer since the API that we're implementing, WASI, is the definition of what we want portability-wise which doesn't always match what `cap-std` does. Overall this commit removes the `cap-std` and `io-lifetimes` dependencies from the Wasmtime workspace itself. A dependency is left on `cap-fs-ext` out of necessity but it's only to access an otherwise-private API located in the `cap-primitives` crate. Implementations throughout `wasmtime-wasi` have shifted to using their `std` counterparts (e.g. clocks), encapsulating more platform-specific logic (e.g. unix-vs-windows filesystem behavior), and refactoring to avoid dependencies (e.g. networking). This commit is not intended to introduce any new behavior nor change any preexisting behavior. The goal of this commit is to reduce the dependency tree of Wasmtime to the bare minimum necessary through the `cap-primitives` crate.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit is an attempt to reduce the number of layers of abstraction that we have for the
wasmtime-wasicrate and implementation, in particular around the dependencies that we have. Historicallywasmtime-wasihas primarily depended oncap-stdwhich provides astd-like API for using the native filesystem and other features (e.g. networking). Over time networking has largely moved away fromcap-std, however. I've additionally historically found it difficult to trace through the tree of dependencies for figuring out what a WASI call does. This requires following code inwasmtime-wasi, tocap-std, tocap-*-extsometimes, tocap-primitives, then torustix. The goal of this commit is to shorten this chain and instead primarily rely on the "meat" ofcap-std, thecap-primitivescrate.The
cap-stdcrate additionally serves a bit of a dual purpose of providing filesystem sandboxing and abstracting the underlying platform. This abstraction though is a bit leaky where the API is different enough across platforms that it can come at a performance cost on some platforms while also still needing#[cfg]s on others. This commit additionally is intended to reduce the reliance on this portability layer since the API that we're implementing, WASI, is the definition of what we want portability-wise which doesn't always match whatcap-stddoes.Overall this commit removes the
cap-stdandio-lifetimesdependencies from the Wasmtime workspace itself. A dependency is left oncap-fs-extout of necessity but it's only to access an otherwise-private API located in thecap-primitivescrate. Implementations throughoutwasmtime-wasihave shifted to using theirstdcounterparts (e.g. clocks), encapsulating more platform-specific logic (e.g. unix-vs-windows filesystem behavior), and refactoring to avoid dependencies (e.g. networking).This commit is not intended to introduce any new behavior nor change any preexisting behavior. The goal of this commit is to reduce the dependency tree of Wasmtime to the bare minimum necessary through the
cap-primitivescrate.