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

feat(query-engine-wasm): slimmer core on wasm32 target arch #4624

Closed
wants to merge 24 commits into from

Conversation

jkomyno
Copy link
Contributor

@jkomyno jkomyno commented Jan 2, 2024

This PR contributes to https://github.com/prisma/team-orm/issues/584, and it impacts core.

It:

  • reduces the amount of .clone()s
  • removes some mut markers which are no longer necessary
  • fixes the JSON protocol on wasm32 (similarly to how it's done already in query-engine-wasm).

Copy link
Contributor

github-actions bot commented Jan 2, 2024

WASM Size

Engine This PR Base branch Diff
WASM 2.744MiB 2.744MiB -714.000B
WASM (gzip) 1.005MiB 1.006MiB -481.000B

Copy link
Contributor

github-actions bot commented Jan 2, 2024

🚨 WASM query-engine: 2 benchmark(s) have regressed at least 2%

Full benchmark report
DATABASE_URL="postgresql://postgres:postgres@localhost:5432/bench?schema=imdb_bench&sslmode=disable" \
node --experimental-wasm-modules query-engine/driver-adapters/executor/dist/bench.mjs
cpu: AMD EPYC 7763 64-Core Processor
runtime: node v18.19.0 (x64-linux)

benchmark                   time (avg)             (min … max)       p75       p99      p995
-------------------------------------------------------------- -----------------------------
• movies.findMany() (all - 25000)
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline  308.39 ms/iter  (305.5 ms … 319.21 ms) 308.88 ms 319.21 ms 319.21 ms
Web Assembly: Latest    310.42 ms/iter (305.61 ms … 318.87 ms) 312.87 ms 318.87 ms 318.87 ms
Web Assembly: Current    306.6 ms/iter (303.86 ms … 312.56 ms) 307.01 ms 312.56 ms 312.56 ms
Node API: Current       235.27 ms/iter (221.19 ms … 258.34 ms) 240.95 ms 258.34 ms 258.34 ms

summary for movies.findMany() (all - 25000)
  Web Assembly: Current
   1.3x slower than Node API: Current
   1.01x faster than Web Assembly: Baseline
   1.01x faster than Web Assembly: Latest

• movies.findMany({ take: 2000 })
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline   12.85 ms/iter   (11.92 ms … 19.96 ms)  12.69 ms  19.96 ms  19.96 ms
Web Assembly: Latest     12.48 ms/iter    (12.2 ms … 20.32 ms)  12.35 ms  20.32 ms  20.32 ms
Web Assembly: Current    12.55 ms/iter   (11.96 ms … 21.57 ms)  12.34 ms  21.57 ms  21.57 ms
Node API: Current         9.57 ms/iter    (9.25 ms … 14.39 ms)   9.68 ms  14.39 ms  14.39 ms

summary for movies.findMany({ take: 2000 })
  Web Assembly: Current
   1.31x slower than Node API: Current
   1.01x slower than Web Assembly: Latest
   1.02x faster than Web Assembly: Baseline

• movies.findMany({ where: {...}, take: 2000 })
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline    2.02 ms/iter     (1.87 ms … 3.46 ms)   1.96 ms    3.4 ms   3.41 ms
Web Assembly: Latest      2.08 ms/iter     (1.84 ms … 3.54 ms)   2.02 ms   3.38 ms    3.4 ms
Web Assembly: Current     2.11 ms/iter     (1.84 ms … 3.61 ms)    2.1 ms   3.37 ms   3.42 ms
Node API: Current         1.58 ms/iter       (1.5 ms … 2.2 ms)   1.59 ms    1.8 ms   1.98 ms

summary for movies.findMany({ where: {...}, take: 2000 })
  Web Assembly: Current
   1.34x slower than Node API: Current
   1.04x slower than Web Assembly: Baseline
   1.01x slower than Web Assembly: Latest

• movies.findMany({ include: { cast: true } take: 2000 }) (m2m)
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline   12.28 ms/iter   (11.92 ms … 13.74 ms)  12.35 ms  13.74 ms  13.74 ms
Web Assembly: Latest     12.26 ms/iter   (12.09 ms … 13.65 ms)  12.24 ms  13.65 ms  13.65 ms
Web Assembly: Current    12.72 ms/iter   (11.75 ms … 21.97 ms)   12.2 ms  21.97 ms  21.97 ms
Node API: Current         9.56 ms/iter    (9.18 ms … 11.28 ms)    9.7 ms  11.28 ms  11.28 ms

summary for movies.findMany({ include: { cast: true } take: 2000 }) (m2m)
  Web Assembly: Current
   1.33x slower than Node API: Current
   1.04x slower than Web Assembly: Latest
   1.04x slower than Web Assembly: Baseline

• movies.findMany({ where: {...}, include: { cast: true } take: 2000 }) (m2m)
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline    1.94 ms/iter     (1.84 ms … 3.17 ms)   1.93 ms   2.52 ms   2.54 ms
Web Assembly: Latest      1.96 ms/iter     (1.83 ms … 4.45 ms)   1.91 ms    3.2 ms   3.34 ms
Web Assembly: Current     1.96 ms/iter     (1.83 ms … 3.27 ms)   1.91 ms    3.1 ms   3.22 ms
Node API: Current         1.61 ms/iter      (1.5 ms … 2.54 ms)   1.61 ms   1.88 ms   2.25 ms

summary for movies.findMany({ where: {...}, include: { cast: true } take: 2000 }) (m2m)
  Web Assembly: Current
   1.22x slower than Node API: Current
   1.01x slower than Web Assembly: Baseline
   1x faster than Web Assembly: Latest

• movies.findMany({ take: 2000, include: { cast: { include: { person: true } } } })
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline   12.27 ms/iter   (11.97 ms … 14.37 ms)  12.33 ms  14.37 ms  14.37 ms
Web Assembly: Latest     12.56 ms/iter   (12.15 ms … 18.35 ms)  12.33 ms  18.35 ms  18.35 ms
Web Assembly: Current    12.18 ms/iter   (11.81 ms … 15.01 ms)  12.21 ms  15.01 ms  15.01 ms
Node API: Current         9.46 ms/iter     (9.11 ms … 9.93 ms)   9.57 ms   9.93 ms   9.93 ms

summary for movies.findMany({ take: 2000, include: { cast: { include: { person: true } } } })
  Web Assembly: Current
   1.29x slower than Node API: Current
   1.01x faster than Web Assembly: Baseline
   1.03x faster than Web Assembly: Latest

• movie.findMany({ where: { ... }, take: 2000, include: { cast: { include: { person: true } } } })
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline    1.91 ms/iter     (1.82 ms … 2.56 ms)   1.91 ms   2.42 ms   2.52 ms
Web Assembly: Latest      1.95 ms/iter     (1.81 ms … 5.46 ms)   1.92 ms   2.86 ms   3.01 ms
Web Assembly: Current      1.9 ms/iter     (1.82 ms … 2.73 ms)   1.88 ms   2.52 ms   2.61 ms
Node API: Current         1.61 ms/iter      (1.5 ms … 2.03 ms)   1.62 ms    1.9 ms   2.02 ms

summary for movie.findMany({ where: { ... }, take: 2000, include: { cast: { include: { person: true } } } })
  Web Assembly: Current
   1.18x slower than Node API: Current
   1.01x faster than Web Assembly: Baseline
   1.03x faster than Web Assembly: Latest

• movie.findMany({ where: { reviews: { author: { ... } }, take: 100 }) (to-many -> to-one)
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline  930.67 µs/iter   (858.55 µs … 1.64 ms)  918.8 µs   1.54 ms   1.57 ms
Web Assembly: Latest    950.33 µs/iter   (874.31 µs … 2.82 ms) 932.78 µs   1.53 ms   1.57 ms
Web Assembly: Current   921.55 µs/iter   (850.42 µs … 1.59 ms)  910.3 µs   1.52 ms   1.55 ms
Node API: Current       846.74 µs/iter   (776.48 µs … 1.11 ms) 866.45 µs 990.62 µs   1.02 ms

summary for movie.findMany({ where: { reviews: { author: { ... } }, take: 100 }) (to-many -> to-one)
  Web Assembly: Current
   1.09x slower than Node API: Current
   1.01x faster than Web Assembly: Baseline
   1.03x faster than Web Assembly: Latest

• movie.findMany({ where: { cast: { person: { ... } }, take: 100 }) (m2m -> to-one)
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline  909.97 µs/iter   (863.51 µs … 1.46 ms) 914.63 µs   1.25 ms   1.29 ms
Web Assembly: Latest    908.41 µs/iter    (859.84 µs … 1.7 ms) 912.14 µs   1.26 ms   1.44 ms
Web Assembly: Current   938.31 µs/iter    (879.2 µs … 1.59 ms) 929.32 µs   1.44 ms   1.56 ms
Node API: Current       830.81 µs/iter   (772.34 µs … 1.04 ms)  857.5 µs 948.31 µs 972.06 µs

summary for movie.findMany({ where: { cast: { person: { ... } }, take: 100 }) (m2m -> to-one)
  Web Assembly: Current
   1.13x slower than Node API: Current
   1.03x slower than Web Assembly: Latest
   1.03x slower than Web Assembly: Baseline

After changes in 34bfe42

@jkomyno jkomyno changed the base branch from main to fix/clippy January 2, 2024 13:17
@jkomyno jkomyno added this to the 5.8.0 milestone Jan 2, 2024
@jkomyno jkomyno changed the title feat(quert-engine-wasm): slimmer core on wasm32 target arch feat(query-engine-wasm): slimmer core on wasm32 target arch Jan 2, 2024
Base automatically changed from fix/clippy to main January 3, 2024 12:44
Copy link

codspeed-hq bot commented Jan 3, 2024

CodSpeed Performance Report

Merging #4624 will not alter performance

Comparing feat/slimmer-core-wasm (34bfe42) with main (0ac27a9)

Summary

✅ 11 untouched benchmarks

@jkomyno
Copy link
Contributor Author

jkomyno commented Jan 8, 2024

Deprecated by #4631.

@jkomyno jkomyno closed this Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant