0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-10-29 08:58:01 -04:00
denoland-deno/cli/cache
Bert Belder de5b47b13c
perf(startup): use WAL journal for sqlite databases in DENO_DIR (#23955)
While investigating poor cold start performance on my GCP VM (32 cores,
130GB SSD), I found that writing to the various sqlite databases in
DENO_DIR was quite slow. The slowness seems to primarily be caused by
excessive latency from a number of `fsync()` calls.

The performance difference is best demonstrated by deleting the sqlite
databases from DENO_DIR while leaving the downloaded sources in place.

The benchmark (see notes below):

```
piscisaureus@bert-us:~/erofs/source$ export DENO_DIR=./.deno
piscisaureus@bert-us:~/erofs/source$ hyperfine --warmup 3   \
  --prepare "rm -rf .deno/*_v1*"                            \
  "deno run -A --cached-only demo.ts"                       \
  "eatmydata deno run -A --cached-only demo.ts"             \
  "~/deno/target/release/deno run -A --cached-only demo.ts"
Benchmark 1: deno run -A --cached-only demo.ts
  Time (mean ± σ):      1.174 s ±  0.037 s    [User: 0.153 s, System: 0.184 s]
  Range (min … max):    1.104 s …  1.212 s    10 runs
 
Benchmark 2: eatmydata deno run -A --cached-only demo.ts
  Time (mean ± σ):     265.5 ms ±   3.6 ms    [User: 138.5 ms, System: 135.1 ms]
  Range (min … max):   260.6 ms … 271.2 ms    11 runs
 
Benchmark 3: ~/deno/target/release/deno run -A --cached-only demo.ts
  Time (mean ± σ):     226.2 ms ±   9.2 ms    [User: 136.7 ms, System: 93.3 ms]
  Range (min … max):   218.8 ms … 247.1 ms    13 runs
 
Summary
  ~/deno/target/release/deno run -A --cached-only demo.ts ran
    1.17 ± 0.05 times faster than eatmydata deno run -A --cached-only demo.ts
    5.19 ± 0.27 times faster than deno run -A --cached-only demo.ts
```

Notes:
* Benchmark 1: unmodified Deno 1.43.6
* Benchmark 2: unmodified Deno 1.43.6 wrapped with `eatmydata` (which is
a tool to neuter `fsync()` calls)
* Benchmark 3: this PR applied on top of Deno 1.43.6


The script that got benchmarked:

```typescript
// demo.ts
import * as express from "npm:express@4.16.3";
import * as postgres from "https://deno.land/x/postgres/mod.ts";

let _dummy = [express, postgres]; // Force use of imports.
console.log("hello world");
```
2024-05-23 00:33:47 -04:00
..
cache_db.rs perf(startup): use WAL journal for sqlite databases in DENO_DIR (#23955) 2024-05-23 00:33:47 -04:00
caches.rs perf: v8 code cache (#23081) 2024-04-17 07:19:55 -07:00
check.rs chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
code_cache.rs perf: v8 code cache (#23081) 2024-04-17 07:19:55 -07:00
common.rs chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
deno_dir.rs refactor(lsp): unify caching into LspCache (#23746) 2024-05-09 20:22:27 +01:00
disk_cache.rs refactor(lsp): unify caching into LspCache (#23746) 2024-05-09 20:22:27 +01:00
emit.rs chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
fast_check.rs perf(jsr): fast check cache and lazy fast check graph (#22485) 2024-02-20 21:29:57 +00:00
incremental.rs chore: update copyright to 2024 (#21753) 2024-01-01 19:58:21 +00:00
mod.rs chore: add tests for moduleGraph2 (#23603) 2024-04-29 14:09:58 -04:00
module_info.rs perf: v8 code cache (#23081) 2024-04-17 07:19:55 -07:00
node.rs feat(node): load ES modules defined as CJS (#22945) 2024-03-21 11:35:51 -07:00
parsed_source.rs chore: add test to ensure parsing only happens once on first load (#23837) 2024-05-21 16:12:40 -04:00