From 0cce9c2bcc9667935a571d30847e66ef5d01a196 Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Wed, 8 Mar 2023 22:21:14 +0530 Subject: feat(core): prevent isolate drop for CLI main worker (#18059) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ``` Benchmark 1: deno run -A ../empty.js Time (mean ± σ): 20.5 ms ± 0.5 ms [User: 13.4 ms, System: 5.1 ms] Range (min … max): 19.8 ms … 24.0 ms 119 runs Benchmark 2: target/release/deno run -A ../empty.js Time (mean ± σ): 18.8 ms ± 0.3 ms [User: 13.0 ms, System: 4.9 ms] Range (min … max): 18.3 ms … 19.9 ms 129 runs ``` --------- Co-authored-by: Bartek Iwańczuk --- runtime/examples/hello_runtime.rs | 1 + runtime/worker.rs | 3 +++ 2 files changed, 4 insertions(+) (limited to 'runtime') diff --git a/runtime/examples/hello_runtime.rs b/runtime/examples/hello_runtime.rs index fca7ff2c9..a47e9c908 100644 --- a/runtime/examples/hello_runtime.rs +++ b/runtime/examples/hello_runtime.rs @@ -66,6 +66,7 @@ async fn main() -> Result<(), AnyError> { shared_array_buffer_store: None, compiled_wasm_module_store: None, stdio: Default::default(), + leak_isolate: true, }; let js_path = diff --git a/runtime/worker.rs b/runtime/worker.rs index e624cb2b4..42ff6b0f9 100644 --- a/runtime/worker.rs +++ b/runtime/worker.rs @@ -141,6 +141,7 @@ pub struct WorkerOptions { /// `WebAssembly.Module` objects cannot be serialized. pub compiled_wasm_module_store: Option, pub stdio: Stdio, + pub leak_isolate: bool, } impl Default for WorkerOptions { @@ -177,6 +178,7 @@ impl Default for WorkerOptions { startup_snapshot: Default::default(), bootstrap: Default::default(), stdio: Default::default(), + leak_isolate: false, } } } @@ -304,6 +306,7 @@ impl MainWorker { extensions_with_js: options.extensions_with_js, inspector: options.maybe_inspector_server.is_some(), is_main: true, + leak_isolate: options.leak_isolate, ..Default::default() }); -- cgit v1.2.3