diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2023-05-01 14:21:27 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-01 18:21:27 +0000 |
commit | 30628288ce2b411ca3def46129a4606073e16bac (patch) | |
tree | 5cae447bc92895f5e16359741416e733458a15de /runtime/ops/runtime.rs | |
parent | dcf391ffed3850f9026d88b146e156375c4619d4 (diff) |
perf: lazily retrieve ppid (#18940)
This is very apparent on Windows.
Before: 45.74ms (Hello world)
After: 33.92ms
Closes #18939
Diffstat (limited to 'runtime/ops/runtime.rs')
-rw-r--r-- | runtime/ops/runtime.rs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/runtime/ops/runtime.rs b/runtime/ops/runtime.rs index 8802f9cd6..9f2e48d7a 100644 --- a/runtime/ops/runtime.rs +++ b/runtime/ops/runtime.rs @@ -8,7 +8,7 @@ use deno_core::OpState; deno_core::extension!( deno_runtime, - ops = [op_main_module], + ops = [op_main_module, op_ppid], options = { main_module: ModuleSpecifier }, state = |state, options| { state.put::<ModuleSpecifier>(options.main_module); @@ -31,7 +31,10 @@ fn op_main_module(state: &mut OpState) -> Result<String, AnyError> { Ok(main_path) } -pub fn ppid() -> i64 { +/// This is an op instead of being done at initialization time because +/// it's expensive to retreive the ppid on Windows. +#[op] +pub fn op_ppid() -> i64 { #[cfg(windows)] { // Adopted from rustup: |