-
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
feat: align wasi-http with component linker #6195
feat: align wasi-http with component linker #6195
Conversation
470e792
to
cf9945a
Compare
@pchickey and @brendandburns , could you review this PR, please? Ideally, we should merge this prior to #6091. |
crates/wasi-http/src/http_impl.rs
Outdated
@@ -54,7 +63,7 @@ fn port_for_scheme(scheme: &Option<Scheme>) -> &str { | |||
} | |||
} | |||
|
|||
impl WasiHttp { | |||
impl WasiHttpCtx { |
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.
Is there a reason for 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.
just to follow the pattern in the other modules, and also to show that there is a breaking change to the API
I think it is probably worth splitting this into two PRs, one containing all of the common implementations and one with the refactors to the HTTP implementation. Using the common code for things like streams seems reasonable. I don't really see the point of the HTTP refactors, they seem to add a bunch of complexity without really reducing the amount of code that is required. |
This is important to integrate with preview2, but also to have less code change whenever the resources will be auto-generated by wit-bindgen. We will be a step further in that direction instead of diverging more and more from the expected pattern. |
This looks to me like a reasonable path to align with some of the changes coming down the pipe from preview2-prototyping. It doesn't make those changes totally drop-in, but using the streams and table abstraction does take us part of the way there. I agree that, without that context, it looks like added complexity without reducing the amount of code required. So really the question is whether adding this now is appropriate, or if we try to land Brendan's other patches first. Unfortunately I am still deep in the preview 2 filesystem work over in p2-p and I haven't context switched back to HTTP to review Brendan's PRs yet. #6228 is pretty straightforward but #6091 has been sitting for longer and I haven't dug into it yet. |
I'm going to list @pchickey as the reviewer for this since I think he's got this in his wheelhouse |
@pchickey , I can understand if we want to first merge the other PRs. After they are, I will integrate the changes back here then. |
Just for my own understanding, I don't think that anything in |
I would expect the http_impl.rs to be modified, yes. If you look into this example here and other parts of the host implementation, you will see that the table abstraction is being assumed to be available and it is the default place to store the id for each handle and associated resource instance. By doing the same for the HTTP module in this PR, we would only hold specific data in its context (right now there is none) and rely on the common context instead. This simplification is not that evident here because I copied the shared code to avoid creating a dependency to the preview2-prototyping repo. |
Another wrinkle is that we'll be spreading this implementation across multiple crates.
We may end up needing to pull some additional tricks to get wasi-common and wasmtime-wasi-http to each access the table via |
It seems like much of the refactor is unrelated to streams, I get that consistent stream handling makes sense, but doesn't seem like using a Moreover, given that there are multiple other wasi-modules in wasmtime that are even further from being component-linker compatible, I'd rather we focused energy on getting the HTTP implementation correct in terms of user-facing surface area and wait for preview2 to arrive in wasmtime before we worry about these kind of changes. |
The problem is that currently we cannot use a Wasm component (+ preview2) in different runtimes (in my case wasmtime, Node.js and browser). I guess other people/companies are facing the same issue. The way I see, we have two options:
I actually preferred the second option, which was the one decided originally. Although, you can take this PR as a compromise where we will temporarily maintain those in two places in order to bring the learnings upstream and they will eventually converge. |
340056a
to
7ddf592
Compare
11b5583
to
edf518b
Compare
Adding prtest:full to ensure that we've seen a successful build before queuing.
fddc0a1
to
c374996
Compare
c374996
to
33400f6
Compare
80773ae
to
2a3e90f
Compare
* feat: align wasi-http with component linker * feat(wasi-http): allow bidirectional stream * feat(wasi-http): clean up children when dropping resource * chore: update based on feedback * chore: replace wasi http context references * chore: fix logical issue with outgoing body stream * chore: use thread-safe reference-counting pointer * chore: cleanup resources using table * fix(wasi-preview1-component-adapter): sync command extended wit * fix(wasi-preview1-component-adapter): sync command extended wit * fix(wasmtime-wasi): sync wit for http types * chore: refactor using wasmtime-wasi crate fix(wasi-http): misconfiguration in wasmtime linkers chore: keep streams details chore: fix wasi http tests * chore: use pollable from wasmtime-wasi * chore: update wasi http linker for module * chore: update test programs for wasi http * fix(wasi-http): ensure proper errors are surfaced * chore: split wasi http tests into individual files * chore: ensure protocol error is mapped correctly * chore: disable temporarily wasi http in wasmtime cli * chore: comment out wasi http in wasmtime cli * chore(ci): ensure wit definitions in sync * feat(wasi-http): generate async host binding * chore: make wasi http tests async * chore: update ci workflow based on suggestion Co-authored-by: Pat Hickey <pat@moreproductive.org> * feat(wasmtime-wasi): update logging world to latest * feat(wasmtime): update proxy world to latest * feat(wasmtime-wasi): add back command extended world * fix(wasi-http): sync wit definitions * chore: update tests with latest wit definitions * Update src/commands/run.rs * Update src/commands/run.rs * Update src/commands/run.rs * Update src/commands/run.rs * Update src/commands/run.rs * Update src/commands/run.rs * Update src/commands/run.rs * Update src/commands/run.rs * Update src/commands/run.rs * chore: fix formatting * Ignore flaky test * chore: fix compilation error for riscv64 arch * Avoid `cp -T` on macos Adding prtest:full to ensure that we've seen a successful build before queuing. * Don't build the wasi-http test programs for the native target * Debug the wit consistency check * Update streams.wit in wasi-http * Mark the component outbound_request_post test flaky * Disable flaky wasi-http-tests on windows only * Use diff instead of rm/cp/git diff * Disable more tests on windows --------- Co-authored-by: Eduardo Rodrigues <eduardomourar@users.noreply.github.com> Co-authored-by: Pat Hickey <pat@moreproductive.org> Co-authored-by: Trevor Elliott <telliott@fastly.com>
This was removed in bytecodealliance#6195 but re-added in bytecodealliance#6877, I believe by accident, so this re-deletes it. I've also edited `.gitmodules` a bit while I was here to remove it and additionally keep other entries up-to-date with matching paths.
This was removed in bytecodealliance#6195 but re-added in bytecodealliance#6877, I believe by accident, so this re-deletes it. I've also edited `.gitmodules` a bit while I was here to remove it and additionally keep other entries up-to-date with matching paths.
…13.0 (#7009) * WASI preview 2 output-streams: new backpressure and flushing design (#6877) * Stream backpressure v2 Co-authored-by: Pat Hickey <phickey@fastly.com> Co-authored-by: Trevor Elliott <telliott@fastly.com> Co-authored-by: Dan Gohman <dev@sunfishcode.online> Stop testing pseudocode Restructure when notifications are sent, and make sure to flush the writer Fix the wasi-http module versions of flush and blocking_flush Use blocking_write_and_flush for blocking writes in the adapters Fix a warning in wasi-http Remove an unused DropPollable add comment explaining try_write for tcpstream refactor: separate struct for representing TcpReadStream by factoring into HostTcpSocket a little bit tcp read stream: handle stream closing tcp tests: use blocking_read where its expecting to wait for input move common test body into wasi-sockets-tests/src/lib.rs ensure parent socket outlives pollable input and output streams can be children now tcp's streams are the sockets children tcp.wit: document child relationships tcp tests: fix to drop socket after its child streams review feedback: propogate worker task panic style error source fix tcp: use preview2::spawn, and propogate worker panics join handle await always propogates panic background task handles ewouldblock as well document choice of constant * sync wit notes into wasi-http * improve wit docs for output-stream * doc: document `HostOutputStream` (#6980) * doc: document `HostOutputStream` Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net> Co-authored-by: Pat Hickey <pat@moreproductive.org> * fix(wasi): fail when `MemoryOutputStream` buffer is full Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net> --------- Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net> Co-authored-by: Pat Hickey <pat@moreproductive.org> * rustfmt prtest:full * windows and doc fixes * cli test wasi-http: use blocking-write-and-flush * Disable some tests, and adjust timeouts when running under qemu * Try to reproduce the riscv64 failures * Update riscv to LLVM 17 with beta rust * Revert "Try to reproduce the riscv64 failures" This reverts commit 8ac6781. * Pin the beta version for riscv64 * Fix a warning on nightly --------- Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net> Co-authored-by: Roman Volosatovs <rvolosatovs@users.noreply.github.com> Co-authored-by: Trevor Elliott <telliott@fastly.com> Co-authored-by: Alex Crichton <alex@alexcrichton.com> * Un-ignore now-passing test With the merging of #6877 prints to stdout with preview2 should now work without requiring extra sleeps or such. * Remove submodule re-added by accident This was removed in #6195 but re-added in #6877, I believe by accident, so this re-deletes it. I've also edited `.gitmodules` a bit while I was here to remove it and additionally keep other entries up-to-date with matching paths. * add to release notes --------- Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net> Co-authored-by: Roman Volosatovs <rvolosatovs@users.noreply.github.com> Co-authored-by: Trevor Elliott <telliott@fastly.com> Co-authored-by: Alex Crichton <alex@alexcrichton.com>
This was removed in bytecodealliance#6195 but re-added in bytecodealliance#6877, I believe by accident, so this re-deletes it. I've also edited `.gitmodules` a bit while I was here to remove it and additionally keep other entries up-to-date with matching paths.
In the context of
wasi-http
, this PR will use the shared functionality fromwasmtime-wasi
will prepare the ground for the migration from the preview2-prototyping repo to wasmtime. A table is being defined to simulate the futureresource
type. Additionally, it will simplify using Component Linker with the wasi-http module.Usage example with WASI Preview2
Depends on: #6836.