prisma-engines icon indicating copy to clipboard operation
prisma-engines copied to clipboard

chore: refactor query parser

Open Weakky opened this issue 1 year ago • 3 comments

Overview

Refactor the QueryParser to use a context.

Weakky avatar Apr 10 '24 17:04 Weakky

WASM Query Engine file Size

Engine This PR Base branch Diff
Postgres 2.125MiB 2.125MiB -39.000B
Postgres (gzip) 836.735KiB 837.104KiB -378.000B
Mysql 2.094MiB 2.094MiB -39.000B
Mysql (gzip) 824.141KiB 824.149KiB -8.000B
Sqlite 1.989MiB 1.989MiB -39.000B
Sqlite (gzip) 784.834KiB 784.986KiB -156.000B

github-actions[bot] avatar Apr 10 '24 17:04 github-actions[bot]

CodSpeed Performance Report

Merging #4822 will not alter performance

Comparing chore/refactor-parser (f6f4b04) with feat/exclude-selection (2f76318)

Summary

✅ 11 untouched benchmarks

codspeed-hq[bot] avatar Apr 10 '24 17:04 codspeed-hq[bot]

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

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.20.1 (x64-linux)

benchmark                   time (avg)             (min … max)       p75       p99      p999
-------------------------------------------------------------- -----------------------------
• movies.findMany() (all - ~50K)
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline     368 ms/iter       (366 ms … 372 ms)    368 ms    372 ms    372 ms
Web Assembly: Latest       454 ms/iter       (451 ms … 463 ms)    457 ms    463 ms    463 ms
Web Assembly: Current      458 ms/iter       (455 ms … 474 ms)    458 ms    474 ms    474 ms
Node API: Current          202 ms/iter       (201 ms … 203 ms)    203 ms    203 ms    203 ms

summary for movies.findMany() (all - ~50K)
  Web Assembly: Current
   2.27x slower than Node API: Current
   1.25x slower than Web Assembly: Baseline
   1.01x slower than Web Assembly: Latest

• movies.findMany({ take: 2000 })
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline  15'034 µs/iter (14'739 µs … 17'006 µs) 15'018 µs 17'006 µs 17'006 µs
Web Assembly: Latest    18'245 µs/iter (18'064 µs … 18'771 µs) 18'296 µs 18'771 µs 18'771 µs
Web Assembly: Current   18'366 µs/iter (18'167 µs … 19'280 µs) 18'390 µs 19'280 µs 19'280 µs
Node API: Current        8'091 µs/iter   (7'940 µs … 8'522 µs)  8'122 µs  8'522 µs  8'522 µs

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

• movies.findMany({ where: {...}, take: 2000 })
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline   2'353 µs/iter   (2'193 µs … 4'059 µs)  2'288 µs  3'892 µs  4'059 µs
Web Assembly: Latest     2'909 µs/iter   (2'768 µs … 4'885 µs)  2'866 µs  4'773 µs  4'885 µs
Web Assembly: Current    2'884 µs/iter   (2'773 µs … 3'763 µs)  2'876 µs  3'466 µs  3'763 µs
Node API: Current        1'398 µs/iter   (1'318 µs … 1'698 µs)  1'409 µs  1'658 µs  1'698 µs

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

• movies.findMany({ include: { cast: true } take: 2000 }) (m2m)
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline     585 ms/iter       (575 ms … 603 ms)    599 ms    603 ms    603 ms
Web Assembly: Latest       795 ms/iter       (789 ms … 810 ms)    803 ms    810 ms    810 ms
Web Assembly: Current      792 ms/iter       (788 ms … 797 ms)    797 ms    797 ms    797 ms
Node API: Current          485 ms/iter       (475 ms … 498 ms)    498 ms    498 ms    498 ms

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

• movies.findMany({ where: {...}, include: { cast: true } take: 2000 }) (m2m)
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline  79'766 µs/iter (79'584 µs … 80'098 µs) 80'008 µs 80'098 µs 80'098 µs
Web Assembly: Latest       111 ms/iter       (110 ms … 112 ms)    112 ms    112 ms    112 ms
Web Assembly: Current      112 ms/iter       (111 ms … 117 ms)    112 ms    117 ms    117 ms
Node API: Current       62'253 µs/iter (61'596 µs … 62'897 µs) 62'699 µs 62'897 µs 62'897 µs

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

• movies.findMany({ take: 2000, include: { cast: { include: { person: true } } } })
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline   1'023 ms/iter   (1'012 ms … 1'041 ms)  1'037 ms  1'041 ms  1'041 ms
Web Assembly: Latest     1'323 ms/iter   (1'317 ms … 1'336 ms)  1'335 ms  1'336 ms  1'336 ms
Web Assembly: Current    1'307 ms/iter   (1'301 ms … 1'323 ms)  1'312 ms  1'323 ms  1'323 ms
Node API: Current          883 ms/iter       (860 ms … 926 ms)    893 ms    926 ms    926 ms

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

• movie.findMany({ where: { ... }, take: 2000, include: { cast: { include: { person: true } } } })
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline     145 ms/iter       (143 ms … 149 ms)    146 ms    149 ms    149 ms
Web Assembly: Latest       188 ms/iter       (186 ms … 190 ms)    189 ms    190 ms    190 ms
Web Assembly: Current      184 ms/iter       (182 ms … 187 ms)    186 ms    187 ms    187 ms
Node API: Current          110 ms/iter       (108 ms … 113 ms)    112 ms    113 ms    113 ms

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

• movie.findMany({ where: { reviews: { author: { ... } }, take: 100 }) (to-many -> to-one)
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline   1'035 µs/iter     (979 µs … 1'782 µs)  1'035 µs  1'616 µs  1'782 µs
Web Assembly: Latest     1'390 µs/iter   (1'310 µs … 2'284 µs)  1'368 µs  2'161 µs  2'284 µs
Web Assembly: Current    1'406 µs/iter   (1'332 µs … 2'142 µs)  1'396 µs  1'879 µs  2'142 µs
Node API: Current          781 µs/iter     (714 µs … 1'123 µs)    803 µs    839 µs  1'123 µs

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

• movie.findMany({ where: { cast: { person: { ... } }, take: 100 }) (m2m -> to-one)
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline   1'076 µs/iter     (982 µs … 1'971 µs)  1'036 µs  1'952 µs  1'971 µs
Web Assembly: Latest     1'353 µs/iter   (1'295 µs … 2'203 µs)  1'352 µs  1'837 µs  2'203 µs
Web Assembly: Current    1'394 µs/iter   (1'332 µs … 1'947 µs)  1'393 µs  1'774 µs  1'947 µs
Node API: Current          775 µs/iter     (722 µs … 1'074 µs)    804 µs    848 µs  1'074 µs

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

After changes in f6f4b045116e4d3adb5447ba96c20533e7892a91

github-actions[bot] avatar Apr 10 '24 17:04 github-actions[bot]