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/js/99_main.js | |
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/js/99_main.js')
-rw-r--r-- | runtime/js/99_main.js | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/runtime/js/99_main.js b/runtime/js/99_main.js index 854a0029e..f0c63df74 100644 --- a/runtime/js/99_main.js +++ b/runtime/js/99_main.js @@ -427,12 +427,11 @@ function bootstrapMainRuntime(runtimeOptions) { 8: tsVersion, 9: unstableFlag, 10: pid, - 11: ppid, - 12: target, - 13: v8Version, - 14: userAgent, - 15: inspectFlag, - // 16: enableTestingFeaturesFlag + 11: target, + 12: v8Version, + 13: userAgent, + 14: inspectFlag, + // 15: enableTestingFeaturesFlag } = runtimeOptions; performance.setTimeOrigin(DateNow()); @@ -495,9 +494,16 @@ function bootstrapMainRuntime(runtimeOptions) { setUserAgent(userAgent); setLanguage(locale); + let ppid = undefined; ObjectDefineProperties(finalDenoNs, { pid: util.readOnly(pid), - ppid: util.readOnly(ppid), + ppid: util.getterOnly(() => { + // lazy because it's expensive + if (ppid === undefined) { + ppid = ops.op_ppid(); + } + return ppid; + }), noColor: util.readOnly(noColor), args: util.readOnly(ObjectFreeze(args)), mainModule: util.getterOnly(opMainModule), @@ -535,12 +541,11 @@ function bootstrapWorkerRuntime( 8: tsVersion, 9: unstableFlag, 10: pid, - // 11: ppid, - 12: target, - 13: v8Version, - // 14: userAgent, - // 15: inspectFlag, - 16: enableTestingFeaturesFlag, + 11: target, + 12: v8Version, + // 13: userAgent, + // 14: inspectFlag, + 15: enableTestingFeaturesFlag, } = runtimeOptions; performance.setTimeOrigin(DateNow()); |