Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: pass transpiled module to deno_core as known string #26555

Conversation

dsherret
Copy link
Member

@dsherret dsherret commented Oct 25, 2024

When using transpile cache:

% hyperfine --warmup 4 "../deno/target/release/deno run -A main.ts" "../deno/target/release/deno_main run -A main.ts"
Benchmark 1: ../deno/target/release/deno run -A main.ts
  Time (mean ± σ):     101.8 ms ±   1.0 ms    [User: 82.7 ms, System: 24.8 ms]
  Range (min … max):    99.6 ms … 103.9 ms    28 runs
 
Benchmark 2: ../deno/target/release/deno_main run -A main.ts
  Time (mean ± σ):     107.4 ms ±   1.6 ms    [User: 86.9 ms, System: 25.9 ms]
  Range (min … max):   104.3 ms … 112.1 ms    27 runs
 
Summary
  ../deno/target/release/deno run -A main.ts ran
    1.05 ± 0.02 times faster than ../deno/target/release/deno_main run -A main.ts

No transpile cache:

% DENO_DIR=$pwd/deno_dir hyperfine --prepare "rm -rf deno_dir" --warmup 4 "../deno/target/release/deno run -A main.ts" "../deno/target/release/deno_main run -A main.ts"
Benchmark 1: ../deno/target/release/deno run -A main.ts
  Time (mean ± σ):      2.479 s ±  0.016 s    [User: 4.259 s, System: 0.132 s]
  Range (min … max):    2.458 s …  2.508 s    10 runs
 
Benchmark 2: ../deno/target/release/deno_main run -A main.ts
  Time (mean ± σ):      2.493 s ±  0.012 s    [User: 4.273 s, System: 0.134 s]
  Range (min … max):    2.478 s …  2.514 s    10 runs
 
Summary
  ../deno/target/release/deno run -A main.ts ran
    1.01 ± 0.01 times faster than ../deno/target/release/deno_main run -A main.ts

I noticed this when working on the deno compile changes because I had a regression in performance when just providing deno_core with bytes.

Files

typescript1.ts and typescript2.ts are two copies of the typescript compiler as typescript files (not JS files)

import { ts as ts1 } from "./typescript1.ts";
import { ts as ts2 } from "./typescript2.ts";

console.log(ts1.version);
console.log(ts2.version);

Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, nice find

@dsherret dsherret merged commit f0f476e into denoland:main Oct 26, 2024
17 checks passed
@dsherret dsherret deleted the perf_pass_transpiled_modules_to_deno_core_as_string branch October 26, 2024 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants