bytecodealliance / bytecodealliance/wit-bindgen
Ownership of resource handles
- Lingua principale
- Rust
- Stelle
- 1.5k
- Fork
- 286
- Merge medio
- 6h 32m
- PR unite (30g)
- 19
Descrizione
I'm would like to use wit to generate host/wasmtime and guest/rust bindings for [lunatic](https://github.com/lunatic-solutions/lunatic). However, I'm still not sure how to correctly model a specific use case.
In lunatic some of the host resources can be sent between different instances. This means that they are consumed by some host functions and removed from the resource table. This doesn't work well with the current [Canonical ABI proposal](https://github.com/WebAssembly/interface-types/blob/40f157ad429772c2b6a8b66ce7b4df01e83ae76d/proposals/interface-types/CanonicalABI.md) that requires all resources to expose a `clone` and `drop` API and implies reference counting.
One workaround is to keep the host resource inside of an `Option` and remove it once it needs to be sent to another instance. Then on every invocation of a host function dealing with the resource check if the value is `Some(T)`. This works okish.
The bigger issues here is that the guest side generated code also generates a `Clone` and `Drop` implementation. We would like to avoid exposing the `Clone` functionality to developers though. It would make the API better reflect the underlaying properties of the resource. Is there a way of disabling this `Clone` option, and ideally not even use reference counting inside of the host in this case?
I guess my question i more general. How to handle this specific scenario with interface types, when the function "consumes" the resource?
I also feel like I didn't completely understand the difference between a resource and a resource handle. Maybe the automatic cloning can be avoided if using resources directly, instead of handles?
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Direzione di ricerca
Inizia con la proposta Canonical ABI collegata e i bindings host/wasmtime e guest/rust descritti nell’issue. Determina come dovrebbero essere modellati il consumo delle risorse, la disabilitazione delle implementazioni generate di Clone e Drop e l’evitamento del conteggio dei riferimenti sull’host; documenta l’approccio supportato e i relativi criteri di completamento.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- rust, wasm
- Ambito
- devtools
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 25/100