-
Notifications
You must be signed in to change notification settings - Fork 1.4k
refactor: move wasip2 implementation to wasmtime_wasi::p2
#10073
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
Conversation
815b81a
to
29b9cad
Compare
cec5af9
to
94e95e6
Compare
Thanks for this! I'm going to continue the discussion from #10061 over here since this looks like it's going to be first. I'll note that whatever we end up doing here for p3 is a relatively big change to consider depending on how it ends up which sort of borders along the lines of "maybe this should have an RFC". For example upon reading reading Pat's comment I initially reacted thinking that we should instead do something else. After thinking more though this seems like a more reasonable approach. That being said though I'd at least personally still have thoughts on this, for example:
I'll also note though that I'm not necessarily saying this requires an RFC. I find though that it's not always the greatest medium to have a design discussion when there's a PR because it's easy to get into the mindset of "well the PR does it this way so I guess we'll just go with that". RFCs have their own downsides of course though. In the abstract though I think we should ideally design for where we want to end up a year or two from now. At that point WASIp3 is stable and will be the "primary" APIs that folks use. Given our destination end point first then I think we can work backwards and consider things like breaking changes, refactorings, migration paths, etc. I've historically found that only designing in incremental steps from where we are today, for example trying to minimize breaking changes, doesn't always result in the best design. |
I agree with all of Alex's broad strokes here. I also want to point out that landing PRs to support wasip3 in wasmtime
Agree, I don't like
Eventually to never would also be my prioritization. Consistency is nice in the abstract, but in this case I don't think its very important, since the interfaces being exposed by preview0 and 1 are for witx, and the rest are for components anyway. And its definitely not urgent to change this, since it would break existing users.
Agree - lets come up with a repeatable pattern that can be applied to other crates as needed, but lets start by only applying it to wasmtime-wasi now and apply it to others immediately before landing a 0.3-draft impl in those. That way, if we discover in the buildout of wasmtime-wasi that the pattern isnt quite right, we can course-correct with a minimum of thrash. |
Oh to clarify for the pub use personally I prefer names to only be in one location as opposed to multiple, so I would advocate for moving most of the preexisting crate to Roman would you be up for making that change and reverting other crates to their original state? That I think should create enough space to start experimenting with p3 in the main crate would be my hope. |
For my third attempt starting from
Each of the crates contains From the embedder's perspective:
The exact same strategy is taken for other proposals, like clocks, random etc. The benefit is that embedders can select which WASI interface implementations to link in as opposed to all-or-nothing approach (or, all/nothing/wasi:io now that #10036 is merged). This approach also insulates the p3 work from changes in With the above in mind, I feel like it may be premature to break all downstream I'll add an agenda item to next Wasmtime bi-weekly meeting to discuss this proposal in more detail. For now I'll continue with crate-per-package approach. |
I'm not sure I'm sold on the idea of multiple crates here, but if you'd prefer to discuss in a meeting I think that's reasonable too. The I'm also not personally sold on an |
058218c
to
6c5d7a2
Compare
5e2ae49
to
963210f
Compare
p2
modulewasmtime_wasi::p2
@alexcrichton @pchickey since majority of wasip3 implementation work is done, I've came back to this PR to hopefully integrate it in https://github.com/bytecodealliance/wasip3-prototyping. I've reworked this PR and marking it as ready for review now, please take a look! |
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'm 50/50 on renaming WasiCtxBuilder, WasiCtx, WasiView to all have P2 in their name. They are already in the p2:: namespace which should be enough. On the other hand it feels like bikeshedding. @alexcrichton wdyt? I'm basically fine either way but not renaming them makes the diffs simpler in this crate and in users.
@@ -0,0 +1,573 @@ | |||
use crate::p2::bindings::filesystem::types; |
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.
It looks like this got tracked by git as a delete and re-creation, can you change that into a rename so that we retain history prior to the rename?
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.
You're right @rvolosatovs that with the squash-and-merge strategy we have the history here won't get preserved even if the PR preserves the history. That being said could you try renaming src/filesystem.rs
to something like src/fs.rs
? That might tip heuristics the other direction to see the rename here. I think the issue is that some of src/filesystem.rs
was retained while most was moved here, and by having the original copy still preserved it might be confusing the rename detection.
We could then follow-up with a commit to rename src/fs.rs
to src/filesystem.rs
if we really wanted too which I think would fixup the git history here.
@@ -0,0 +1,44 @@ | |||
use crate::p2::bindings::sockets::network::{ErrorCode, Ipv4Address, Ipv6Address}; |
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 also should be a rename, rather than delete and creation
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.
Unfortunately, that can't be done with the squash merge strategy.
FWIW, I'm actually in favor of not including the Should I drop the top 3 commits? |
OK, if you're not in favor of putting P2 in the name its easy to just say, lets not do that, drop those commits. |
963210f
to
1554ff1
Compare
I've used the "merge" trick I've adapted from https://dev.to/deckstar/how-to-git-copy-copying-files-while-keeping-git-history-1c9j to duplicate |
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.
Agreed leaving "P2" out of the names, and some follow-ups we can do after this are to remove "P1" from names and rename preview{0,1}
to p{0,1}
as well I think. In the future it might make sense to lift more of p2/*.rs
to the root level as well, things like tcp/udp sockets etc. That's purely for internal organization though and can be deferred to later as-needed.
@@ -1,272 +1,23 @@ | |||
//! # Wasmtime's WASI Implementation |
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 keeping some of the crate comment here? My rough goal has been to make the landing page relatively informative. No need to duplicate p1/p2 docs, but having pointers/links to those modules and an outline of the high-level organization here I think would be good.
@@ -0,0 +1,573 @@ | |||
use crate::p2::bindings::filesystem::types; |
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.
You're right @rvolosatovs that with the squash-and-merge strategy we have the history here won't get preserved even if the PR preserves the history. That being said could you try renaming src/filesystem.rs
to something like src/fs.rs
? That might tip heuristics the other direction to see the rename here. I think the issue is that some of src/filesystem.rs
was retained while most was moved here, and by having the original copy still preserved it might be confusing the rename detection.
We could then follow-up with a commit to rename src/fs.rs
to src/filesystem.rs
if we really wanted too which I think would fixup the git history here.
Signed-off-by: Roman Volosatovs <[email protected]>
1554ff1
to
c0ed81a
Compare
Signed-off-by: Roman Volosatovs <[email protected]>
Signed-off-by: Roman Volosatovs <[email protected]>
c0ed81a
to
de3803b
Compare
Closing and reopening to hopefully get CI to work... |
Pull request was closed
Introduce a
p2
module in WASI crates as suggested in #10061 (review)I've moved to
wasmtime_wasi::p2
submodule:I've left a few non-p2 specific things in
wasmtime_wasi
top-level, which I was able to reuse for p3 impl in bytecodealliance/wasip3-prototyping#115I currently do not see a way to reuse
WasiCtx
for wasip3, specifically due to the difference in I/O handling, which would introduce the incompatibility for stdio config between wasip2 and wasip3. It is possible that we can introduce some shared abstraction, which could be reused by both (future)WasiP3Ctx
andWasiP2Ctx
, but for now I've just moved the context intop2
submodule, since I think we will always have a wasip{N}-specificWasiP{N}Ctx
, particularly because set of interfaces included in WASI, as well as their semantics, might change across versionsI've added 3 more commits on top of the move, which seemed to make sense for consistency:
WasiCtx
->WasiP2Ctx
WasiView
->WasiP2View
WasiImpl
->WasiP2Impl
I opted not to rename existing
preview1
andpreview0
modules/features to avoid breaking changes.cc @pchickey