denoland / deno_graph

The module graph logic for Deno CLI
https://docs.rs/deno_graph
MIT License
111 stars 39 forks source link

perf: make module analysis async #477

Closed dsherret closed 4 months ago

dsherret commented 4 months ago

This allows us to parse source files in parallel for the first run:

Benchmark 1: ../deno/deno_old run -A ts_morph.ts
  Time (mean ± σ):      2.332 s ±  0.017 s    [User: 2.193 s, System: 0.126 s]
  Range (min … max):    2.307 s …  2.366 s    10 runs

Benchmark 2: ../deno/target/release/deno run -A ts_morph.ts
  Time (mean ± σ):      1.052 s ±  0.006 s    [User: 2.259 s, System: 0.132 s]
  Range (min … max):    1.040 s …  1.060 s    10 runs

Summary
  ../deno/target/release/deno run -A ts_morph.ts ran
    2.22 ± 0.02 times faster than ../deno/deno_old run -A ts_morph.ts
scratch % cat ts_morph.ts
import "https://deno.land/x/ts_morph@22.0.0/mod.ts";
import "https://deno.land/x/ts_morph@21.0.0/mod.ts";
import "https://deno.land/x/ts_morph@20.0.0/mod.ts";
import "https://deno.land/x/ts_morph@19.0.0/mod.ts";

Same speed on second run:

Benchmark 1: ../deno/deno_old run -A ts_morph.ts
  Time (mean ± σ):     419.2 ms ±   3.7 ms    [User: 390.3 ms, System: 40.7 ms]
  Range (min … max):   415.1 ms … 428.8 ms    10 runs

Benchmark 2: ../deno/target/release/deno run -A ts_morph.ts
  Time (mean ± σ):     415.4 ms ±   4.6 ms    [User: 385.7 ms, System: 39.6 ms]
  Range (min … max):   412.2 ms … 425.1 ms    10 runs

  Warning: Statistical outliers were detected. Consider re-running this benchmark on a quiet system without any interferences from other programs. It might help to use the '--warmup' or '--prepare' options.

Summary
  ../deno/target/release/deno run -A ts_morph.ts ran
    1.01 ± 0.01 times faster than ../deno/deno_old run -A ts_morph.ts

Closes https://github.com/denoland/deno_graph/issues/474

ry commented 4 months ago

maybe this should rather be "perf: make module analysis async"