Proposal to rework `MemoryCreator` and remove internal types.
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
Direzione di ricerca
Start with the FIXME in crates/wasmtime/src/runtime/vm/memory.rs and review the related public MemoryCreator API, RuntimeMemoryCreator, MemoryCreatorProxy, and DefaultMemoryCreator implementations. The proposal requires a breaking API change and coordination across memory creation paths; done means the public trait and internal implementation use MemoryRequest, with the internal types removed and the stated error handling and request fields resolved.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Building on #14885, I'd like to tackle the other half of the linear memory traits. This is already a FIXME in the memory code:
Since it involves a breaking public API change I thought I'd first go through an issue before I go into slashing the codebase.
Feature
The change would remove RuntimeMemoryCreator and MemoryCreatorProxy. The DefaultMemoryCreator struct would be implemented wholly in terms of the public MemoryCreator trait.
This requires a breaking change to the MemoryCreator. First, the DefaultMemoryCreator receives reservation_for_growth, which is currently not present on the public trait's new_memory. Second, more minor, the current trait requires to return a Result<_, String> instead of the standard wasmtime error type, so fidelity would be lost as the DefaultMemoryCreator would convert all strongly-typed errors to string.
Benefit
Simplifies the code base, fixes an outstanding FIXME, avoids running into issues similar to #10740 because of a mismatch of how the user can implement the memory backend from the outside and internal-only shortcuts.
Implementation
My proposal would be to change the public API so that new_memory task a single parameter, MemoryRequest. That way things can be added as functions on the type without breaking current implementations. Public accessors on the request would return all things the creator needs to serve the request:
impl<'a> MemoryRequest<'a> {
pub fn ty(&self) -> MemoryType;
pub fn minimum(&self) -> usize;
pub fn maximum(&self) -> Option<usize>;
pub fn reserved_size_in_bytes(&self) -> Option<usize>;
pub fn guard_size_in_bytes(&self) -> usize;
}
The return type turns into the standard wasmtime Error. This is not really an issue, a user of wasmtime already has to cope with the wasmtime Error anywhere, I don't think there's any advantage to allowing Result<_, String> as it currently is.
Internally, RuntimeMemoryCreator is gone, as is MemoryCreatorProxy. Config holds an Arc<dyn MemoryCreator> instead. The implementation that creates memory in vm::Memory will construct a MemoryRequest and route it to the creator.
Not all things are exposed publicly, I don't necessarily want to increase the public API surface here. The DefaultMemoryCreator needs MemoryTunables for some of the config as well as ty: &wasmtime_environ::Memory. These are not public types, so I'd keep them on MemoryRequest exposed as pub(crate), but not to the outside.
Alternatives
There's a few things one could consider changing:
- The documentation now doesn't mention that, but the custom creator is also used for GC heaps. An implementation might want to serve these differently, because their purpose and access patterns are different, but currently there's no way to distinguish that from the public parameters. A simple
pub fn kind(&self)returning a non-exhaustingMemoryKindenum withLinearMemoryandGcHeapfixes this. - The other parameters are passed via tunables and not exposed. For example,
MmapMemoryusesreservation_for_growthandguard_before_linear_memory, plussignals_based_trapsandmemory_init_cowto decide whether to use Mmap or Malloc-backed memory.
I also have one open question: reserved_size_in_bytes is an Option<usize>, but the engine always passes Some, with Some(0) meaning "no reservation". Is there any reason for this? What would be the semantic difference between Some(0) and None? Can we just make it a usize?
- Lingua principale
- Rust
- Stelle
- 18.8k
- Fork
- 1.9k
- Merge medio
- 1g 2m
- PR unite (30g)
- 392
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di bytecodealliance/wasmtime
-
bug wasm-proposal:exceptions wasmtime:debugging
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
bytecodealliance/wasmtime#14102 ·
I maintainer di solito rispondono entro 1 giorno
-
wasm-proposal:gc
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
bytecodealliance/wasmtime#13808 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 24/100
bytecodealliance/wasmtime#15036 ·
I maintainer di solito rispondono entro 1 giorno
-
bug wasi-http
Difficoltà 3/5 1-2 giorni Idoneità per principianti 32/100
bytecodealliance/wasmtime#15026 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Compile-time builtin composition resolves guest imports from host working directory & has path failuresForse già presa @dyslexicsteak l’ha presa 1 giorno fa. Apertabug
Difficoltà 5/5 Più di una settimana Idoneità per principianti 15/100
bytecodealliance/wasmtime#15024 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di bytecodealliance/wasmtime
Issue simili
-
desktop documentation
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
vfarcic/dot-agent-deck#2008 ·
I maintainer di solito rispondono entro 1 giorno
-
needs triage
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
pbakaus/impeccable#1210 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement ux-opportunities
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
area: ci priority: P4 ready-for-agent
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
shep-pm/shep#1249 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
`PartialEq` for `AssignedBigUint` treats different values as equalForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertastatus:untriaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
midnightntwrk/midnight-zk#600 ·
I maintainer di solito rispondono entro 2 giorni