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

experiment(psl/query-engine-wasm): create QE-specific ValidatedSchema, adopt binary (de)serialization for query-engine-wasm #4696

Closed
wants to merge 10 commits into from

Conversation

jkomyno
Copy link
Contributor

@jkomyno jkomyno commented Feb 5, 2024

This PR currently sits at 758 KB gzip'd.


DO NOT REVIEW YET (outdated description)

This is a preliminary PR that sets the ground for https://github.com/prisma/team-orm/issues/892.

This PR:

  • removes diagnostics from psl::ValidatedSchema
  • removes warnings from psl::Generator

The removed fields are still computed, but they are returned "besides" the struct, rather than "within" the struct".
No public API is affected: e.g., getConfig() in @prisma/prisma-schema-wasm still returns the warnings (if any).


Rationale: we want to experiment deserializing a ValidatedSchema directly. The fewer fields it contains, the better and easier it is to investigate https://github.com/prisma/team-orm/issues/892.

@jkomyno jkomyno self-assigned this Feb 5, 2024
Copy link
Contributor

github-actions bot commented Feb 5, 2024

WASM Size

Engine This PR Base branch Diff
WASM 2.162MiB 2.161MiB 673.000B
WASM (gzip) 836.294KiB 836.334KiB -41.000B

Copy link
Contributor

github-actions bot commented Feb 5, 2024

✅ WASM query-engine performance won't change substantially (1.004x)

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      p999
-------------------------------------------------------------- -----------------------------
• movies.findMany() (all - 25000)
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline  313.02 ms/iter (309.24 ms … 319.59 ms) 314.88 ms 319.59 ms 319.59 ms
Web Assembly: Latest    384.82 ms/iter (383.66 ms … 385.86 ms) 385.44 ms 385.86 ms 385.86 ms
Web Assembly: Current   390.66 ms/iter (388.24 ms … 394.75 ms) 392.33 ms 394.75 ms 394.75 ms
Node API: Current       235.72 ms/iter  (224.1 ms … 249.58 ms) 248.56 ms 249.58 ms 249.58 ms

summary for movies.findMany() (all - 25000)
  Web Assembly: Current
   1.66x slower than Node API: Current
   1.25x slower than Web Assembly: Baseline
   1.02x slower than Web Assembly: Latest

• movies.findMany({ take: 2000 })
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline   12.46 ms/iter   (12.16 ms … 13.63 ms)  12.48 ms  13.63 ms  13.63 ms
Web Assembly: Latest     16.39 ms/iter   (15.78 ms … 19.37 ms)  16.86 ms  19.37 ms  19.37 ms
Web Assembly: Current    16.23 ms/iter   (15.88 ms … 17.54 ms)  16.44 ms  17.54 ms  17.54 ms
Node API: Current        9,056 µs/iter   (8,640 µs … 11.35 ms)  9,132 µs  11.35 ms  11.35 ms

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

• movies.findMany({ where: {...}, take: 2000 })
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline   1,981 µs/iter   (1,827 µs … 3,131 µs)  1,952 µs  3,066 µs  3,131 µs
Web Assembly: Latest     2,492 µs/iter   (2,399 µs … 3,202 µs)  2,487 µs  3,081 µs  3,202 µs
Web Assembly: Current    2,496 µs/iter   (2,403 µs … 3,520 µs)  2,488 µs  3,099 µs  3,520 µs
Node API: Current        1,493 µs/iter   (1,384 µs … 1,945 µs)  1,507 µs  1,811 µs  1,945 µs

summary for movies.findMany({ where: {...}, take: 2000 })
  Web Assembly: Current
   1.67x slower than Node API: Current
   1.26x slower than Web Assembly: Baseline
   1x faster than Web Assembly: Latest

• movies.findMany({ include: { cast: true } take: 2000 }) (m2m)
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline   12.44 ms/iter   (12.15 ms … 13.91 ms)  12.49 ms  13.91 ms  13.91 ms
Web Assembly: Latest     16.05 ms/iter   (15.77 ms … 17.05 ms)  16.18 ms  17.05 ms  17.05 ms
Web Assembly: Current    16.16 ms/iter   (15.86 ms … 17.77 ms)   16.2 ms  17.77 ms  17.77 ms
Node API: Current        9,027 µs/iter   (8,635 µs … 10.94 ms)  9,079 µs  10.94 ms  10.94 ms

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

• movies.findMany({ where: {...}, include: { cast: true } take: 2000 }) (m2m)
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline   1,910 µs/iter   (1,823 µs … 2,480 µs)  1,910 µs  2,351 µs  2,480 µs
Web Assembly: Latest     2,528 µs/iter   (2,400 µs … 3,438 µs)  2,534 µs  3,159 µs  3,438 µs
Web Assembly: Current    2,541 µs/iter   (2,401 µs … 3,962 µs)  2,512 µs  3,570 µs  3,962 µs
Node API: Current        1,502 µs/iter   (1,394 µs … 2,003 µs)  1,516 µs  1,889 µs  2,003 µs

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

• movies.findMany({ take: 2000, include: { cast: { include: { person: true } } } })
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline   12.39 ms/iter    (12.2 ms … 13.37 ms)  12.48 ms  13.37 ms  13.37 ms
Web Assembly: Latest     16.28 ms/iter   (15.77 ms … 20.56 ms)   16.3 ms  20.56 ms  20.56 ms
Web Assembly: Current    15.94 ms/iter    (15.77 ms … 16.2 ms)  16.08 ms   16.2 ms   16.2 ms
Node API: Current        8,992 µs/iter   (8,679 µs … 9,933 µs)  9,004 µs  9,933 µs  9,933 µs

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

• movie.findMany({ where: { ... }, take: 2000, include: { cast: { include: { person: true } } } })
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline   1,901 µs/iter   (1,828 µs … 2,267 µs)  1,908 µs  2,192 µs  2,267 µs
Web Assembly: Latest     2,469 µs/iter   (2,374 µs … 3,082 µs)  2,463 µs  2,942 µs  3,082 µs
Web Assembly: Current    2,452 µs/iter   (2,379 µs … 2,924 µs)  2,452 µs  2,851 µs  2,924 µs
Node API: Current        1,465 µs/iter   (1,384 µs … 1,773 µs)  1,487 µs  1,682 µs  1,773 µs

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

• movie.findMany({ where: { reviews: { author: { ... } }, take: 100 }) (to-many -> to-one)
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline  905.42 µs/iter  (855.85 µs … 1,498 µs) 907.88 µs  1,247 µs  1,498 µs
Web Assembly: Latest     1,190 µs/iter   (1,138 µs … 1,542 µs)  1,196 µs  1,436 µs  1,542 µs
Web Assembly: Current    1,235 µs/iter   (1,166 µs … 1,908 µs)  1,229 µs  1,799 µs  1,908 µs
Node API: Current       816.77 µs/iter  (739.48 µs … 1,063 µs) 838.53 µs 926.33 µs  1,063 µs

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

• movie.findMany({ where: { cast: { person: { ... } }, take: 100 }) (m2m -> to-one)
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline  928.02 µs/iter  (888.47 µs … 1,341 µs)  932.1 µs  1,199 µs  1,341 µs
Web Assembly: Latest     1,240 µs/iter   (1,148 µs … 2,098 µs)  1,215 µs  2,060 µs  2,098 µs
Web Assembly: Current    1,235 µs/iter   (1,168 µs … 2,072 µs)  1,234 µs  2,056 µs  2,072 µs
Node API: Current       825.08 µs/iter  (746.92 µs … 1,147 µs) 847.24 µs  1,037 µs  1,147 µs

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

After changes in e9f38c3

Copy link

codspeed-hq bot commented Feb 5, 2024

CodSpeed Performance Report

Merging #4696 will not alter performance

Comparing chore/restructure-validatedschema (e9f38c3) with main (16a6fe5)

Summary

✅ 11 untouched benchmarks

@jkomyno jkomyno changed the title chore(psl): refactor ValidatedSchema and Generator experiment(psl/query-engine-wasm): create QE-specific ValidatedSchema, adopt binary (de)serialization for query-engine-wasm Feb 7, 2024
@jkomyno jkomyno closed this Feb 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.

None yet

1 participant