-
Notifications
You must be signed in to change notification settings - Fork 2
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
fixed epoch_interruption on new wasm instance creation #89
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ use std::path::Path; | |
use std::sync::atomic::{AtomicU32, AtomicU64, Ordering}; | ||
use std::sync::{Arc, Barrier}; | ||
use std::thread; | ||
use wasmtime::{AsContext, AsContextMut, Caller, ExternType, Linker, Module, SharedMemory, Store, Val, OnCalledAction, RewindingReturn, StoreOpaque, InstanceId}; | ||
use wasmtime::{AsContext, AsContextMut, Caller, Engine, ExternType, InstanceId, Linker, Module, OnCalledAction, RewindingReturn, SharedMemory, Store, StoreOpaque, Val}; | ||
|
||
use wasmtime_environ::MemoryIndex; | ||
|
||
|
@@ -316,6 +316,7 @@ impl<T: Clone + Send + 'static + std::marker::Sync, U: Clone + Send + 'static + | |
|
||
let lind_manager = child_ctx.lind_manager.clone(); | ||
let mut store = Store::new_with_inner(&engine, child_host, store_inner); | ||
store.set_epoch_deadline(1); | ||
|
||
// if parent is a thread, so does the child | ||
if is_parent_thread { | ||
|
@@ -556,6 +557,7 @@ impl<T: Clone + Send + 'static + std::marker::Sync, U: Clone + Send + 'static + | |
let instance_pre = Arc::new(child_ctx.linker.instantiate_pre(&child_ctx.module).unwrap()); | ||
|
||
let mut store = Store::new_with_inner(&engine, child_host, store_inner); | ||
store.set_epoch_deadline(1); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
|
||
// mark as thread | ||
store.set_is_thread(true); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -634,6 +634,10 @@ impl Engine { | |
self.inner.epoch.fetch_add(1, Ordering::Relaxed); | ||
} | ||
|
||
pub fn decrement_epoch(&self) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also comment this |
||
self.inner.epoch.fetch_sub(1, Ordering::Relaxed); | ||
} | ||
|
||
/// Returns a [`std::hash::Hash`] that can be used to check precompiled WebAssembly compatibility. | ||
/// | ||
/// The outputs of [`Engine::precompile_module`] and [`Engine::precompile_component`] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ use std::sync::atomic::AtomicU64; | |
use std::sync::{Arc, Mutex}; | ||
use std::thread; | ||
use wasi_common::sync::{ambient_authority, Dir, TcpListener, WasiCtxBuilder}; | ||
use wasmtime::{AsContextMut, Engine, Func, Module, Store, StoreLimits, Val, ValType}; | ||
use wasmtime::{AsContextMut, Engine, Func, Module, Store, StoreLimits, UpdateDeadline, Val, ValType}; | ||
use wasmtime_wasi::WasiView; | ||
|
||
use wasmtime_lind_utils::LindCageManager; | ||
|
@@ -424,6 +424,8 @@ impl RunCommand { | |
thread::sleep(timeout); | ||
engine.increment_epoch(); | ||
}); | ||
} else if self.run.common.wasm.epoch_interruption.is_some() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is a good comment |
||
store.set_epoch_deadline(1); | ||
} | ||
|
||
Ok(Box::new(|_store| {})) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a one line comment here about what this is doing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these comments don't really explain why we would do this or what this is