-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
WASI support tracking #65895
Comments
Tagging subscribers to 'arch-wasm': @lewing Issue DetailsDescriptionThis issue is to track known issues in the early WASI-enabled runtime builds. These need to be resolved in order to have a proper supportable WASI-ready release.
Reproduction StepsExpected behaviorActual behaviorRegression?No response Known WorkaroundsNo response ConfigurationNo response Other informationNo response
|
Is exporting functions to wasi tracked here too? |
Added |
@pavelsavara Thanks! We also need the opposite: Exporting functions so that you can create a .NET library and compile it to wasm and consume it from the other languages. It's already possible from Go, C, C++, and Rust. See this sample: https://github.com/extism/csharp-pdk/blob/master/samples/SamplePlugin/Functions.cs#L9 Currently you have to write the C glue code manually: https://github.com/extism/csharp-pdk/blob/master/samples/SamplePlugin/native.c#L11 |
That would be Also there trouble is sharing memory between caller and called code. We will implement this assuming shared memory (with the host engine) and passing pointers. And the "WASI component model" with isolated memory, lowering/lifting etc will need different attributes in the future future. |
These are very good questions and I see too: what benefit has WASI that I can not already do with Native Applications? I see Wasmtime or different Wasm runners here as Platform that provides Networking, at least for now on a single maschine for Platform Owners. But here the WASI Commuity Group is not yet far enough with Networking and many other things... Alternativly frameworks like Aspire could abstract away the underlying Networking for WASI Runner-Platform and/or Kubernetes Platform. Where do I deploy? Everywhere, where I can start a Wasi Runner (Windows Server, Developer/Sales Laptop, What are the Advantages for the Developer: For Testing he doesn't need a whole Kubernetes Cluster on his Developer PC, only a WASI runner. But then still Who does Updating? there are WASI/WASM Container registries, but no Gitops Platforms yet like ArgoCD/Flux to automatically update... But as you said these are just Ideas and no concrete use cases |
I meant for distributed systems, not networking APIs that WASI may describe.
Sure but that has yet to manifest. I'm also not convinced it will be that different to Kubernetes at the core.
You can run your apps today locally on your PC without Kubernetes. This isn't a feature unique to WASI. I'm very supportive of the work to make .NET work with WASM on the server side, but the ecosystem barely exists so the benefits called out are hypothetical and in the early idea stage. There are a few platforms and tools that can run WASM binaries but from a .NET developer point of view, it seems like an implementation detail. |
This is a great conversation and helps to flush out a lot of the ambiguity that surrounds WASI today. It's important to know that WASI (i.e., a combination of API interface definitions for things like HTTP requests, plus tooling like Long term it's completely possible that K8s devs will commonly run WASI components in preference over traditional containers within their Kubernetes clusters. Or maybe that some WASI-first K8s alternative will emerge, though as @davidfowl says it would probably look the same as Kubernetes from the point of view of the person deploying and maintaining the cluster itself. However, neither of these things are definite, and the WASI ecosystem remains at an early stage. |
Having possibility to run ASP.NET WebApi project on system that don't have .net supported (ex. *BSD and/or exotic arch) would be +1 for me. It was possible using https://github.com/SteveSandersonMS/dotnet-wasi-sdk and implementing http host under wasmrunner to interop with .net or using the one with WASI tcp-level where available - is/will that be planned/supported in future? |
Right! I was hoping somebody would have a scenario around that.
Are you expecting a very small binary with a tiny performance hit? WASI is experimental and we don't be shipping anything non-experimental on top of it until it goes stable. Our path for WASM on the server should be based on the work we've been doing to make ASP.NET Core NativeAOT compatible (and this is a long journey 😄). |
FWIW we're currently experimenting with Wasm support via NativeAOT-LLVM experiment (https://github.com/dotnet/runtimelab/tree/feature/NativeAOT-LLVM) and had a very good experience performance-wise. The only blockers are that it's experimental and that it currently builds only on Windows. Other than that, it's pretty competitive with Wasm compiled from Rust (except for binary size, but that's not very important to us anyway), especially compared to the Mono interpreted version. Hoping that the cross-platform variant of NativeAOT will get to similar level feature- and performance-wise someday, or that NativeAOT-LLVM experiment will make it into mainstream. That said, in our project we're not interested in WASI but in pure Wasm as we provide custom host functions. WASI target is just means to an end because in .NET there is currently no option for |
Right, I was just hoping to use @davidfowl As for performance and binary size - that's something I wouldn't care for at the start, as having possibility to run .net code on new platform/os without "native" runtime would be more important IMO (sure NativeAOT would be way better, but as you said, it's a journey :) |
@sec Then the current support is likely fine for you without native aot 😄 |
Another usage scenario are server side plugins, @SteveSandersonMS showed it already in his demos, but wanted to mention it again. On self hosted environments by customers, computation is not that expensive and our server side applications can load Plugin DLLs (from us or third party) and run them into the server process. There is always the risk of memory leaks, infite loops and reduced performance but it can be tolerated. On Cloud environments this is not tolerable anymore, since one plugin DLL could bring down all customers, also there is the risk of data of other customers can be accessed. So third party Plugin Developers need to host REST/GRPC Services for their plugins which then need to be integrated. This is much more complex and much slower than a DLL. Or there need to be a whole infrastructure for hosting third party docker containers. With WASI, we could still load the WASI-File-Plugins in Our Application, data of other customers could not be accessed (or at least an acceptable risk if no error on our side), we could limit the amount of CPU resources to disable slow plugins It also would be importaint that it can be configured that only certain Rest/Socket resources can be accessed, or for example only external and no Lan-Endpoints. (be it by IP-Ranges or other means) |
AFAIK WASM runtimes (the ones I've seen) don't let you limit CPU usage of running code (you can limit the memory) .NET process host -> Some WASM runtimes-> .NET code compiled to WASM running inside of those runtimes. Of course, these systems are not "just secure" as you need to audit the host code and WASM runtime code to make sure bugs don't lead to leaking customer data across... I think we will see plugins using WASM more and more so that's a reasonable scenario. |
Wasmtime has the concept of "fuel": https://docs.rs/wasmtime/latest/wasmtime/struct.Config.html#method.consume_fuel But, it's different from docker's cpu limits, it's more about preventing infinite loops |
Another point - is debuggability of production environments vs. chiseled-docker In one project we switched to chinseled dotnet containers a few days ago and now we have the problem that debugging is much more limited of production environments since there is no shell. Now one could argue well then keep the shell installed for production, well then the container is bigger and its a potential security risk. Wasi would allow a "sidecar"-wasi written for example in rust for .NET, which could be included in the "wasi-container" But yes, most of this tooling doesn't exist yet. |
Is there any way to produce raw Wasm MVP files from .NET 9 after #104683 has landed? We've been "piggy-backing" on .NET's Wasi target to produce Wasm files targeted for custom hosts, as, unlike C/C++/Rust/etc .NET doesn't have support for raw ("hostless") Wasm output and WASI is the closest target where we could simply stub out all the imports during compilation and rely on This has been possible starting from the original @SteveSandersonMS' Wasi.Sdk and up until and including .NET 8. I now wanted to try and test how hard it would be to migrate to .NET 9 preview as it has some exciting Wasm features - in particular, AOT and Which brings me to the crux of my question - is there any way path to opt-out from Wasm component output or, even better, an official example that shows how to produce a raw "hostless" Wasm in plain old MVP format, going to be provided in .NET 9 or does this mean we're stuck with .NET 8 with its slow interpreter mode for IL bytecode for the foreseeable future? UPD: I should probably add that, by decomposing components into individual Wasm files using |
We switched to WASI preview 2 and component model in Net9 Preview 7. We now depend on wasi:http component import directly. We don't have dev bandwidth to support multiple build configurations, I'm sorry. |
I imagine that's going to break quite a few users in similar positions to us. Out of curiosity, what was the driver behind that decision? Wasm components are still in rather raw stages, and the engine support is pretty poor compared to regular Wasm. While it's interesting to watch its development, it seems rather too early to switch to it as the primary output format for stable .NET version, cutting off majority of engines other than I guess Wasmtime. Perhaps there is some
So, while I totally understand lack of bandwidth for actual development & support, perhaps there is a way to just provide a different link-stage flag so that .NET would produce just this one single file, which already has the required shape? We can do the rest of the stubbing ourselves. |
You could try disable We are also passing Here is WASM & WASI ABI, I'm not sure which of them would apply.
"Skate to where the puck is going, not where it has been." |
Thanks, this is helpful, going to take a look.
Yeah I suspect this is going to be a problem, too. I looked at it briefly before, and I think I could hack around it with MSBuild's
That is fine, since we are going to stub them out anyway, it doesn't matter which version is used. On the C ABI side it still behaves like a regular C import, after all, so declaring stubs isn't very different from the original preview. It's really just the components + WIT that cause issues, which is why I'm hopeful that what we want is achievable with purely a link-time change.
Heh, I agree with the sentiment, just saying it feels... risky / early for a switch, given the very limited native engine support. I liked WASI p1 for its simplicity and compatibility with any regular Wasm, and was one of probably dozens of people who made their own in-browser implementations at the time because it was just a matter of loading same Wasm file but with custom imports. Oh well, either way that's beside the point for this particular usecase. |
For Net10 possibly yes. But I'm afraid we will break it again ... let's give it a try. |
@RReverser Did you ever get this workaround working? I'm in the same boat where I'm trying to code to an existing host that only supports modules, not components. .NET 9 preview 6 was working for me, but for some reason I couldn't get it to include native assets. |
This definitely seems like a misstep. There is practically no use of WASI Preview 2[0] in the ecosystem, and very few runtime maintainers are interested in supporting this moving target. WASI Preview 1 is still in significant demand, and it would be a shame to have to drop .NET support in our projects because of this decision.
The puck definitely does not seem to be moving in the direction you're alluding to with this change. Based on the component model implementation across the runtime landscape, this severley limits the utility of .NET in the Wasm ecosystem. If that is the intention of the team here, then I suppose you are making the right call. [0]: from https://crates.io/crates/wasi
|
My personal position as one of the original creators of WebAssembly is that "skating towards where the puck is going" has always been necessary to deliver a good developer experience, and it will continue to be necessary. It's not always possible to predict where the puck is going to end up, but following the standards process is decent way to go about it.
By the same logic used here to argue for staying on p1 forever (look at this linear scale graph showing usage of a widely deployed piece of technology vs an emerging technology), it would i.e. be appropriate to only support a single dominant web browser and ignore every other browser, based on current usage statistics. At one point, the proven technology was asm.js - widely supported and widely used - while the emerging technology was WASM. In the same way, one could argue that WASI itself shouldn't be supported, since WASI usage is tiny in comparison to usage of client web browsers. Surely that's not the goal? Given the amount of time it takes for core runtime changes to percolate through the ecosystem into developers' hands, and then the time it takes for developers to adopt a new core runtime version and deploy it in their applications, it's not sufficient to ask "what does WASM look like today? what does WASI look like today?" because by the time your answer(s) end up on an end user's computer or on a server in the cloud, years have passed. It's not sufficient to just say "this is the wrong answer right now" and use that to close off any forward-looking development. Some key questions are:
Just off the top of my head, I don't see a good solution for HTTP in WASI p1, so I feel those three questions are illuminating in this context. My personal advice in this context would be to consider stating what the user needs are and how those needs are best served by staying still instead of moving forward, or alternately, suggest which direction the forward movement should be aimed in and how that will serve users. |
@nilslice Hi there, Rust Project member here. I'd be careful not to read too much into the download data of one specific Rust package. The WASI 0.1 (nee This is relevant because in order for crates to support both WASI 0.1 and also introduce support for WASI 0.2, a compiler target #[cfg(all(target_os = "wasi", target_env = "p1"))]
mod wasip1 { /* WASI 0.1 items go here */ }
#[cfg(all(target_os = "wasi", target_env = "p2"))]
mod wasip2 { /* WASI 0.2 items go here */ } In order for crates to test whether they work on CI they require a working WASI 0.2 toolchain, which in turn requires having a prebuilt compiler toolchain available. While it was technically possible to build your own WASI 0.2 toolchain for Rust before Rust 1.82, we've recommended against people doing that. That has meant that targeting WASI 0.2 from existing libraries essentially hasn't been possible. This will change with the upcoming Rust 1.82 release, at which point we will likely see a gradual roll-out of support for WASI 0.2 throughout the ecosystem. I hope that provides some insight into the evolution of Rust's WASI targets. If you'd like to read more, please see the post: Changes to Rust's WASI targets, as well as the draft for the upcoming release: The wasm32-wasip2 Target has Reached Tier 2 Support. Footnotes |
We use Wazero as our WASM host runtime. I was planning to offer C# as a target guest language, but I guess since Wazero has voted no to WASI-p2 and .NET has voted no to WASI-p1, that sadly we'll just have to tell our customers to pick a different language. See |
@yoshuawuyts, hi - I don't think the point you're making really lands here or is related to the .NET support concern, but thanks!
I have been reading and following these closely for a few years, it's always a good proxy to measure interest. Considering it's my job to know what users want from Wasm, I read a lot of crates.io and other package manager data.
Wasip2 launched in January of this year (WebAssembly/WASI#577), so I'd put the starting line for adoption metrics there. It's had nearly zero uptick, except from a few insiders within the Bytecode Alliance. This is despite countless strong pushes, conferences, and other evangelism. It's just not sticking. I deeply care about WebAssembly, and have its best interest in mind, and I do not see the ecosystem having voted with their usage of Wasip2. Now, maybe if it really is that the Rust target alone is the winning solution, then that will change. But it still does NOT address anything to do with this thread, which is squarely about .NET tooling compiling to core standard Wasm Modules vs. non-standard unadopted Wasm components. This is where the problem lays, and I worry will further fragment the ecosystem and at the same time strip .NET languages from their utility to Wasm projects.
I have read this, and saw the problematic release and reversal of this announcement. It's not the most reassuring state of things to now think about depending on this target in any way. |
@nilslice ? - I was directly responding to your comment in #65895 (comment), where you claim that the downloads of a single Rust ecosystem crate are indicative of broader WASI 0.2 ecosystem adoption. You use that to further the argument that the dotnet maintainers should shy away from supporting WASI 0.2. I didn't make the connection between Rust and dotnet, you did. Posting just the screenshot on its own can be misleading as it omits context. If you're going to discuss download counts, it seems relevant to explain that library authors can't practically add a dep on |
Description
This issue is to track known issues in the early WASI-enabled runtime builds. These need to be resolved in order to have a proper supportable WASI-ready release.
wasi-wasm
RIDOperatingSystem.IsWasi()
#78389 API changeSystem.Native
using WASI SDK instead of using the Emscripten-built binary.wasm_m2n_invoke.g.h
System.Native
. Currently there's a small hardcoded list.dotnet/wasi-sdk
)dotnet/wasi-sdk
packages #95086mono_gc_finalize_notify
ingc.c
).synthetic-pthread.c
code to support having separate pthread keys for each thread instead of a single global list.ves_icall_System_Reflection_Assembly_InternalLoad
. #95137[DLLImport]
which doesn't match known static native symbols #86984[UnmanagedCallersOnly]
#86985Build
and a public distribution mechanism.wasi-experimental
workload,wasiconsole
template, andWasi.Build.Tests
#81849)wasi-experimental
workload,wasiconsole
template, andWasi.Build.Tests
#81849)wasi-experimental
workload,wasiconsole
template, andWasi.Build.Tests
#81849)wasi-experimental
workload,wasiconsole
template, andWasi.Build.Tests
#81849)wasi-experimental
workload,wasiconsole
template, andWasi.Build.Tests
#81849)The text was updated successfully, but these errors were encountered: