mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-10 14:48:27 +00:00
Many performance and memory optimizations
- Avoiding a memory copy on all socket reads and writes using a new `copy_from_slice` instead - File openers no longer box the implementation avoiding a memory allocation on all file access - Polling sockets rather than using an async function which significantly reduces locking contention and removes an box operation - Futex now uses wakers rather than broadcasts which makes them more efficient and durable - Converted many async functions into sync functions in vnet - Sleeping no longer allocates memory - Avoiding a number of WasiEnv clones which was impacting performance and memory efficiency
This commit is contained in:
committed by
Christoph Herzog
parent
7f8c0858b3
commit
26d4a6a0de
@@ -311,6 +311,17 @@ impl<'a, T: ValueType> WasmSlice<'a, T> {
|
||||
self.buffer.write(self.offset, bytes)
|
||||
}
|
||||
|
||||
/// Reads this `WasmSlice` into a `slice`.
|
||||
#[inline]
|
||||
pub fn read_to_slice<'b>(
|
||||
self,
|
||||
buf: &'b mut [MaybeUninit<u8>],
|
||||
) -> Result<usize, MemoryAccessError> {
|
||||
let len = self.len.try_into().expect("WasmSlice length overflow");
|
||||
self.buffer.read_uninit(self.offset, buf)?;
|
||||
Ok(len)
|
||||
}
|
||||
|
||||
/// Reads this `WasmSlice` into a `Vec`.
|
||||
#[inline]
|
||||
pub fn read_to_vec(self) -> Result<Vec<T>, MemoryAccessError> {
|
||||
|
||||
@@ -313,6 +313,17 @@ impl<'a, T: ValueType> WasmSlice<'a, T> {
|
||||
self.buffer.write(self.offset, bytes)
|
||||
}
|
||||
|
||||
/// Reads this `WasmSlice` into a `slice`.
|
||||
#[inline]
|
||||
pub fn copy_to_slice<'b>(
|
||||
self,
|
||||
buf: &'b mut [MaybeUninit<u8>],
|
||||
) -> Result<usize, MemoryAccessError> {
|
||||
let len = self.len.try_into().expect("WasmSlice length overflow");
|
||||
self.buffer.read_uninit(self.offset, buf)?;
|
||||
Ok(len)
|
||||
}
|
||||
|
||||
/// Reads this `WasmSlice` into a `Vec`.
|
||||
#[inline]
|
||||
pub fn read_to_vec(self) -> Result<Vec<T>, MemoryAccessError> {
|
||||
|
||||
Reference in New Issue
Block a user