|
1 | 1 | use self::module_host_actor::ReducerOp; |
2 | 2 |
|
3 | 3 | use super::wasm_instance_env::WasmInstanceEnv; |
4 | | -use super::{Mem, WasmtimeFuel}; |
| 4 | +use super::{Mem, WasmtimeFuel, EPOCH_TICKS_PER_SECOND}; |
5 | 5 | use crate::energy::ReducerBudget; |
6 | 6 | use crate::host::instance_env::InstanceEnv; |
7 | 7 | use crate::host::wasm_common::module_host_actor::{DescribeError, InitializationError}; |
@@ -99,8 +99,18 @@ impl module_host_actor::WasmInstancePre for WasmtimeModule { |
99 | 99 | let mem = Mem::extract(&instance, &mut store).unwrap(); |
100 | 100 | store.data_mut().instantiate(mem); |
101 | 101 |
|
| 102 | + store.epoch_deadline_callback(|store| { |
| 103 | + let env = store.data(); |
| 104 | + let database = env.instance_env().replica_ctx.database_identity; |
| 105 | + let reducer = env.reducer_name(); |
| 106 | + let dur = env.reducer_start().elapsed(); |
| 107 | + tracing::warn!(reducer, ?database, "Wasm has been running for {dur:?}"); |
| 108 | + Ok(wasmtime::UpdateDeadline::Continue(EPOCH_TICKS_PER_SECOND)) |
| 109 | + }); |
| 110 | + |
102 | 111 | // Note: this budget is just for initializers |
103 | 112 | set_store_fuel(&mut store, ReducerBudget::DEFAULT_BUDGET.into()); |
| 113 | + store.set_epoch_deadline(EPOCH_TICKS_PER_SECOND); |
104 | 114 |
|
105 | 115 | for preinit in &func_names.preinits { |
106 | 116 | let func = instance.get_typed_func::<(), ()>(&mut store, preinit).unwrap(); |
@@ -193,6 +203,7 @@ impl module_host_actor::WasmInstance for WasmtimeInstance { |
193 | 203 | // otherwise, we'd return something like `used: i128::MAX - u64::MAX`, which is inaccurate. |
194 | 204 | set_store_fuel(store, budget.into()); |
195 | 205 | let original_fuel = get_store_fuel(store); |
| 206 | + store.set_epoch_deadline(EPOCH_TICKS_PER_SECOND); |
196 | 207 |
|
197 | 208 | // Prepare sender identity and connection ID, as LITTLE-ENDIAN byte arrays. |
198 | 209 | let [sender_0, sender_1, sender_2, sender_3] = bytemuck::must_cast(op.caller_identity.to_byte_array()); |
|
0 commit comments