Skip to content

Commit 5fc801d

Browse files
committed
fix(runtime): no-op explicit compiles without workers
1 parent 1d7b836 commit 5fc801d

2 files changed

Lines changed: 24 additions & 3 deletions

File tree

crates/revmc-runtime/src/runtime/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,9 @@ impl JitBackend {
250250
///
251251
/// Blocks if the command channel is full to guarantee delivery.
252252
pub fn compile_jit(&self, req: LookupRequest) {
253+
if self.inner.tuning.jit_worker_count == 0 {
254+
return;
255+
}
253256
let _ = self.ensure_started();
254257
let cmd = Command::CompileJit(CompileJitRequest {
255258
key: req.key,
@@ -265,6 +268,9 @@ impl JitBackend {
265268
/// or when the compilation fails. Use [`get_compiled`](Self::get_compiled) to
266269
/// retrieve the result after this returns.
267270
pub fn compile_jit_sync(&self, req: LookupRequest) -> eyre::Result<()> {
271+
if self.inner.tuning.jit_worker_count == 0 {
272+
return Ok(());
273+
}
268274
self.ensure_started()?;
269275
let (tx, rx) = chan::bounded(1);
270276
let cmd = Command::CompileJit(CompileJitRequest {
@@ -289,6 +295,9 @@ impl JitBackend {
289295
///
290296
/// Blocks if the command channel is full to guarantee delivery.
291297
pub fn prepare_aot_batch(&self, reqs: Vec<AotRequest>) {
298+
if self.inner.tuning.jit_worker_count == 0 {
299+
return;
300+
}
292301
let _ = self.ensure_started();
293302
let owned: Vec<PrepareAotRequest> = reqs
294303
.into_iter()

crates/revmc-runtime/src/runtime/tests.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -325,13 +325,21 @@ fn backend_clone() {
325325

326326
#[test]
327327
fn compile_jit_enqueue() {
328-
let tb = TestBackend::with_tuning(RuntimeTuning { jit_worker_count: 0, ..Default::default() });
328+
let tb = TestBackend::new(RuntimeConfig {
329+
enabled: false,
330+
tuning: RuntimeTuning { jit_worker_count: 0, ..Default::default() },
331+
..Default::default()
332+
});
329333
tb.compile_jit(TestBackend::req_cancun(BYTECODE_RET42));
330334
}
331335

332336
#[test]
333337
fn prepare_aot_enqueue() {
334-
let tb = TestBackend::with_tuning(RuntimeTuning { jit_worker_count: 0, ..Default::default() });
338+
let tb = TestBackend::new(RuntimeConfig {
339+
enabled: false,
340+
tuning: RuntimeTuning { jit_worker_count: 0, ..Default::default() },
341+
..Default::default()
342+
});
335343
tb.prepare_aot(AotRequest {
336344
code_hash: alloy_primitives::keccak256(BYTECODE_RET42),
337345
code: Bytes::copy_from_slice(BYTECODE_RET42),
@@ -341,7 +349,11 @@ fn prepare_aot_enqueue() {
341349

342350
#[test]
343351
fn prepare_aot_batch_enqueue() {
344-
let tb = TestBackend::with_tuning(RuntimeTuning { jit_worker_count: 0, ..Default::default() });
352+
let tb = TestBackend::new(RuntimeConfig {
353+
enabled: false,
354+
tuning: RuntimeTuning { jit_worker_count: 0, ..Default::default() },
355+
..Default::default()
356+
});
345357
let reqs = vec![
346358
AotRequest {
347359
code_hash: alloy_primitives::keccak256(BYTECODE_RET42),

0 commit comments

Comments
 (0)