Skip to content

fix(mongo): default int native type should be long#4888

Merged
Weakky merged 1 commit intomainfrom
fix/mongodb-int-regression
Jun 3, 2024
Merged

fix(mongo): default int native type should be long#4888
Weakky merged 1 commit intomainfrom
fix/mongodb-int-regression

Conversation

@Weakky
Copy link
Copy Markdown
Contributor

@Weakky Weakky commented May 27, 2024

Overview

fixes prisma/prisma#24262

Encode Int fields as Int64 by default.

This fixes a regression introduced in #4639 where ScalarField::native_type() always returns a native type now, even when it's not explicitly specified in the Prisma Schema. This caused the MongoDB connector to use a different code path to encode input values which encoded default Int fields as Int32 although they were previously encoded as Int64s.

@github-actions
Copy link
Copy Markdown
Contributor

WASM Query Engine file Size

Engine This PR Base branch Diff
Postgres 2.153MiB 2.153MiB 0.000B
Postgres (gzip) 846.060KiB 846.060KiB 0.000B
Mysql 2.119MiB 2.119MiB 0.000B
Mysql (gzip) 831.748KiB 831.748KiB 0.000B
Sqlite 2.015MiB 2.015MiB 0.000B
Sqlite (gzip) 793.079KiB 793.079KiB 0.000B

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented May 27, 2024

CodSpeed Performance Report

Merging #4888 will not alter performance

Comparing fix/mongodb-int-regression (d6c930c) with main (793f7fb)

Summary

✅ 11 untouched benchmarks

@github-actions
Copy link
Copy Markdown
Contributor

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

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

benchmark                   time (avg)             (min … max)       p75       p99      p999
-------------------------------------------------------------- -----------------------------
• movies.findMany() (all - ~50K)
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline     360 ms/iter       (357 ms … 367 ms)    363 ms    367 ms    367 ms
Web Assembly: Latest       452 ms/iter       (449 ms … 465 ms)    453 ms    465 ms    465 ms
Web Assembly: Current      462 ms/iter       (458 ms … 467 ms)    466 ms    467 ms    467 ms
Node API: Current          201 ms/iter       (196 ms … 209 ms)    202 ms    209 ms    209 ms

summary for movies.findMany() (all - ~50K)
  Web Assembly: Current
   2.3x slower than Node API: Current
   1.28x slower than Web Assembly: Baseline
   1.02x slower than Web Assembly: Latest

• movies.findMany({ take: 2000 })
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline  14'719 µs/iter (14'266 µs … 18'779 µs) 14'416 µs 18'779 µs 18'779 µs
Web Assembly: Latest    18'363 µs/iter (17'920 µs … 19'104 µs) 18'355 µs 19'104 µs 19'104 µs
Web Assembly: Current   18'604 µs/iter (18'360 µs … 19'527 µs) 18'753 µs 19'527 µs 19'527 µs
Node API: Current        7'987 µs/iter   (7'830 µs … 8'317 µs)  8'044 µs  8'317 µs  8'317 µs

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

• movies.findMany({ where: {...}, take: 2000 })
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline   2'289 µs/iter   (2'190 µs … 3'394 µs)  2'272 µs  3'314 µs  3'394 µs
Web Assembly: Latest     2'872 µs/iter   (2'772 µs … 3'659 µs)  2'867 µs  3'470 µs  3'659 µs
Web Assembly: Current    2'959 µs/iter   (2'807 µs … 4'880 µs)  2'918 µs  4'154 µs  4'880 µs
Node API: Current        1'411 µs/iter   (1'327 µs … 1'774 µs)  1'416 µs  1'688 µs  1'774 µs

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

• movies.findMany({ include: { cast: true } take: 2000 }) (m2m)
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline     565 ms/iter       (559 ms … 582 ms)    570 ms    582 ms    582 ms
Web Assembly: Latest       781 ms/iter       (774 ms … 798 ms)    782 ms    798 ms    798 ms
Web Assembly: Current      798 ms/iter       (775 ms … 891 ms)    802 ms    891 ms    891 ms
Node API: Current          472 ms/iter       (463 ms … 498 ms)    475 ms    498 ms    498 ms

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

• movies.findMany({ where: {...}, include: { cast: true } take: 2000 }) (m2m)
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline  78'236 µs/iter (77'407 µs … 80'424 µs) 78'601 µs 80'424 µs 80'424 µs
Web Assembly: Latest       110 ms/iter       (109 ms … 115 ms)    110 ms    115 ms    115 ms
Web Assembly: Current      109 ms/iter       (108 ms … 112 ms)    109 ms    112 ms    112 ms
Node API: Current       62'562 µs/iter (60'756 µs … 64'491 µs) 63'412 µs 64'491 µs 64'491 µs

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

• movies.findMany({ take: 2000, include: { cast: { include: { person: true } } } })
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline   1'011 ms/iter   (1'004 ms … 1'031 ms)  1'014 ms  1'031 ms  1'031 ms
Web Assembly: Latest     1'301 ms/iter   (1'297 ms … 1'319 ms)  1'301 ms  1'319 ms  1'319 ms
Web Assembly: Current    1'302 ms/iter   (1'289 ms … 1'321 ms)  1'318 ms  1'321 ms  1'321 ms
Node API: Current          884 ms/iter       (872 ms … 914 ms)    904 ms    914 ms    914 ms

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

• movie.findMany({ where: { ... }, take: 2000, include: { cast: { include: { person: true } } } })
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline     142 ms/iter       (141 ms … 146 ms)    144 ms    146 ms    146 ms
Web Assembly: Latest       182 ms/iter       (181 ms … 185 ms)    183 ms    185 ms    185 ms
Web Assembly: Current      187 ms/iter       (184 ms … 192 ms)    187 ms    192 ms    192 ms
Node API: Current          113 ms/iter       (112 ms … 115 ms)    114 ms    115 ms    115 ms

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

• movie.findMany({ where: { reviews: { author: { ... } }, take: 100 }) (to-many -> to-one)
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline   1'042 µs/iter     (973 µs … 1'786 µs)  1'037 µs  1'570 µs  1'786 µs
Web Assembly: Latest     1'388 µs/iter   (1'306 µs … 2'022 µs)  1'385 µs  1'849 µs  2'022 µs
Web Assembly: Current    1'393 µs/iter   (1'332 µs … 1'986 µs)  1'394 µs  1'826 µs  1'986 µs
Node API: Current          779 µs/iter     (708 µs … 1'340 µs)    797 µs  1'136 µs  1'340 µs

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

• movie.findMany({ where: { cast: { person: { ... } }, take: 100 }) (m2m -> to-one)
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline   1'043 µs/iter     (980 µs … 1'711 µs)  1'036 µs  1'633 µs  1'711 µs
Web Assembly: Latest     1'373 µs/iter   (1'305 µs … 2'043 µs)  1'374 µs  1'946 µs  2'043 µs
Web Assembly: Current    1'386 µs/iter   (1'332 µs … 1'819 µs)  1'396 µs  1'677 µs  1'819 µs
Node API: Current          787 µs/iter     (720 µs … 1'254 µs)    806 µs    864 µs  1'254 µs

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

After changes in d6c930c

@Weakky Weakky added this to the 5.15.0 milestone May 27, 2024
@Weakky Weakky marked this pull request as ready for review May 27, 2024 15:10
@Weakky Weakky requested a review from a team as a code owner May 27, 2024 15:10
@Weakky Weakky requested review from jkomyno and removed request for a team May 27, 2024 15:10
@Weakky Weakky merged commit 4f418dd into main Jun 3, 2024
@Weakky Weakky deleted the fix/mongodb-int-regression branch June 3, 2024 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Breaking change? Int switched to being Int32 for MongoDB

3 participants