-
Notifications
You must be signed in to change notification settings - Fork 9
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
Why not a fill()
-type API?
#27
Comments
WASI is moving to the Wit IDL and the component-model type system, and at the IDL level, the component model uses pass-by-value semantics for all values. It doesn't have a mutable reference type at the IDL level. This ensures that the interfaces are usable from all languages, including languages that use GC instead of linear memory, and it avoids lifetime and thread synchronization questions that would arise with a mutable buffer, especially in languages that don't have a borrow checker. That said, are a few ways that we could generate more clever bindings at the Rust level that would allow users to pass in a buffer and have |
Gotcha! That makes sense. I figured I was missing something. I suppose you can close this issue then, since that answers my question. I also don't think that is is terribly important to optimize this API for speed, the bottleneck is usually the kernel generating the random data. One side question: what is a good way to get involved in this effort? I really like where WebAssembly is going, and would not mind getting involved. |
WebAssembly/component-model#175 is an issue tracking this optimization in the bindings. It'd be great to have more people involved. We don't have many resources yet for newcomers, though we're starting to work on that. Right now, https://github.com/bytecodealliance/preview2-prototyping is a place where I and others are working on prototyping the new APIs, which may be interesting to follow. |
Closing, as per the discussion above, the way wit works, this is more a question for the bindings than for WASI itself. |
Hey guys! Awesome work here. I'm working on passgen in my free time and I'm trying to make this work well within WASM/WASI. For that, I obviously need access to good random data. Right now, I'm using Linux's
getrandom()
andarc4_random()
on macOS. So much for context.In my code, I have a ring buffer of random data that I use up and then replenish by filling it with random data, overwriting what was in it previously. Hence my question: why not a
fill()
-style API?vs
I might be missing something here — kind of new to this WASM/WASI thing. Please excuse me if this does not make sense.
The advantage of this would obviously be that I don't need to create a new buffer of random data every time, but I can just have one buffer around. The other advantage is that by continuously overwriting the random data, you can't accidentally leak it, like you could with new allocations. This might not be an issue for WebAssembly, however.
Cheers,
Patrick
The text was updated successfully, but these errors were encountered: