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

qe: Default make-qe task to JSON protocol and improve error message #4644

Merged
merged 3 commits into from
Jan 16, 2024

Conversation

SevInf
Copy link
Contributor

@SevInf SevInf commented Jan 12, 2024

I beleive prisma/team-orm#710 was caused by engine defaulting to GraphQL
via .envrc file. Error handling in BinaryEngine
being broken in this case (prisma/prisma#22636) made finding this out
really hard.
So, while main fix is done on the client side, I beleive we can adjust
few things on the engine side too:

  • make-qe task will now always use JSON protocol.
  • make-qe-graphql task added for cases where it is necessary. For
    example, using the playground.
  • Default PRISMA_ENGINE_PROTOCOL is removed from .envrc. If needed,
    it can be restored via .envrc.local.
  • Error message adjusted to mention incorrect protocol possiblity.

For reviewers: I would appreciate if you'd checked out the branch and tested
if instructions here work for you now.

Contributes to prisma/team-orm#710

I beleive prisma/team-orm#710 was caused by engine defaulting to GraphQL
via `.envrc` file. Error handling in BinaryEngine
being broken in this case (prisma/prisma#22636) made finding this out
really hard.
So, while main fix is done on the client side, I beleive we can adjust
few things on the engine side too:

- `make-qe` task will now always use JSON protocol.
- `make-qe-graphql` task added for cases where it is necessary. For
  example, using the playground.
- Default `PRISMA_ENGINE_PROTOCOL` is removed from `.envrc`. If needed,
  it can be restored via `.envrc.local`.
- Error message adjusted to mention incorrect protocol possiblity.

Contributes to prisma/team-orm#710
@SevInf SevInf requested a review from a team as a code owner January 12, 2024 11:23
@SevInf SevInf requested review from laplab and jkomyno and removed request for a team January 12, 2024 11:23
@SevInf SevInf added this to the 5.9.0 milestone Jan 12, 2024
Copy link
Contributor

github-actions bot commented Jan 12, 2024

WASM Size

Engine This PR Base branch Diff
WASM 2.745MiB 2.745MiB -90.000B
WASM (gzip) 1.010MiB 1.010MiB 85.000B

Copy link

codspeed-hq bot commented Jan 12, 2024

CodSpeed Performance Report

Merging #4644 will not alter performance

Comparing qe/connect-to-engine-json (b15ddb1) with main (85c1f86)

Summary

✅ 11 untouched benchmarks

Copy link
Contributor

github-actions bot commented Jan 12, 2024

🚨 WASM query-engine: 1 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  306.79 ms/iter  (304.42 ms … 312.5 ms) 306.54 ms  312.5 ms  312.5 ms
Web Assembly: Latest    312.97 ms/iter (307.19 ms … 320.94 ms) 313.69 ms 320.94 ms 320.94 ms
Web Assembly: Current   312.35 ms/iter (307.54 ms … 326.21 ms) 312.37 ms 326.21 ms 326.21 ms
Node API: Current       237.36 ms/iter (229.02 ms … 261.96 ms) 239.29 ms 261.96 ms 261.96 ms

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

• movies.findMany({ take: 2000 })
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline   12.65 ms/iter   (11.86 ms … 18.57 ms)  12.51 ms  18.57 ms  18.57 ms
Web Assembly: Latest     12.28 ms/iter   (11.91 ms … 14.89 ms)   12.3 ms  14.89 ms  14.89 ms
Web Assembly: Current    12.64 ms/iter    (12.2 ms … 16.67 ms)  12.36 ms  16.67 ms  16.67 ms
Node API: Current         9.39 ms/iter    (8.88 ms … 10.14 ms)   9.46 ms  10.14 ms  10.14 ms

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

• movies.findMany({ where: {...}, take: 2000 })
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline    2.11 ms/iter     (1.86 ms … 3.79 ms)   2.03 ms   3.64 ms   3.65 ms
Web Assembly: Latest      2.03 ms/iter     (1.84 ms … 4.59 ms)   1.99 ms   3.38 ms   3.52 ms
Web Assembly: Current     1.96 ms/iter     (1.84 ms … 3.32 ms)   1.93 ms    3.3 ms   3.32 ms
Node API: Current         1.57 ms/iter      (1.49 ms … 2.2 ms)   1.58 ms   1.79 ms   2.11 ms

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

• movies.findMany({ include: { cast: true } take: 2000 }) (m2m)
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline   12.19 ms/iter   (11.92 ms … 12.78 ms)  12.28 ms  12.78 ms  12.78 ms
Web Assembly: Latest     12.26 ms/iter   (11.99 ms … 12.81 ms)  12.34 ms  12.81 ms  12.81 ms
Web Assembly: Current    12.45 ms/iter   (12.15 ms … 18.09 ms)  12.37 ms  18.09 ms  18.09 ms
Node API: Current         9.83 ms/iter    (9.05 ms … 15.58 ms)   9.83 ms  15.58 ms  15.58 ms

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

• movies.findMany({ where: {...}, include: { cast: true } take: 2000 }) (m2m)
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline    1.93 ms/iter     (1.84 ms … 3.24 ms)   1.93 ms   2.85 ms   3.18 ms
Web Assembly: Latest      1.93 ms/iter     (1.83 ms … 2.87 ms)   1.92 ms   2.68 ms   2.76 ms
Web Assembly: Current     1.93 ms/iter     (1.85 ms … 3.16 ms)   1.92 ms   2.35 ms    2.4 ms
Node API: Current         1.56 ms/iter     (1.45 ms … 1.87 ms)   1.59 ms   1.81 ms   1.81 ms

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

• movies.findMany({ take: 2000, include: { cast: { include: { person: true } } } })
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline    12.3 ms/iter   (11.91 ms … 13.85 ms)  12.35 ms  13.85 ms  13.85 ms
Web Assembly: Latest     12.33 ms/iter   (12.17 ms … 13.94 ms)   12.3 ms  13.94 ms  13.94 ms
Web Assembly: Current    12.46 ms/iter   (12.06 ms … 13.13 ms)   12.6 ms  13.13 ms  13.13 ms
Node API: Current         9.72 ms/iter     (9.28 ms … 12.3 ms)   9.73 ms   12.3 ms   12.3 ms

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

• movie.findMany({ where: { ... }, take: 2000, include: { cast: { include: { person: true } } } })
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline    1.92 ms/iter     (1.81 ms … 2.88 ms)    1.9 ms   2.84 ms   2.88 ms
Web Assembly: Latest       1.9 ms/iter     (1.82 ms … 2.82 ms)   1.89 ms   2.36 ms   2.79 ms
Web Assembly: Current     1.92 ms/iter     (1.83 ms … 5.51 ms)    1.9 ms   2.87 ms   2.92 ms
Node API: Current         1.58 ms/iter      (1.5 ms … 1.85 ms)   1.59 ms   1.78 ms   1.81 ms

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

• movie.findMany({ where: { reviews: { author: { ... } }, take: 100 }) (to-many -> to-one)
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline  939.51 µs/iter     (857.8 µs … 3.1 ms) 924.79 µs   1.49 ms   1.56 ms
Web Assembly: Latest     926.8 µs/iter   (860.76 µs … 1.53 ms) 916.97 µs   1.51 ms   1.53 ms
Web Assembly: Current    912.4 µs/iter    (869.28 µs … 1.4 ms) 915.64 µs    1.2 ms   1.29 ms
Node API: Current       857.89 µs/iter   (782.48 µs … 1.22 ms)  865.6 µs   1.05 ms    1.1 ms

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

• movie.findMany({ where: { cast: { person: { ... } }, take: 100 }) (m2m -> to-one)
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline  923.81 µs/iter    (857.83 µs … 1.6 ms)  917.6 µs   1.52 ms   1.57 ms
Web Assembly: Latest    897.68 µs/iter   (859.19 µs … 2.28 ms) 901.67 µs    1.2 ms   1.24 ms
Web Assembly: Current   902.47 µs/iter   (867.28 µs … 1.45 ms) 901.76 µs   1.33 ms   1.41 ms
Node API: Current       817.07 µs/iter   (765.27 µs … 1.05 ms) 845.93 µs 929.55 µs 968.76 µs

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

After changes in b15ddb1

Copy link
Contributor

@miguelff miguelff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got an expected reproduction, the error message is:

prisma:error Error parsing Graphql query. data did not match any variant of untagged enum GraphqlBody
PrismaClientKnownRequestError: Error parsing Graphql query. data did not match any variant of untagged enum GraphqlBody
    at Uo.httpErrorHandler (/Users/miguel/GitHub/prisma/prisma-engines/repro/node_modules/@prisma/client/runtime/binary.js:176:5223)
    at /Users/miguel/GitHub/prisma/prisma-engines/repro/node_modules/@prisma/client/runtime/binary.js:176:2481
    at Function.onHttpError (/Users/miguel/GitHub/prisma/prisma-engines/repro/node_modules/@prisma/client/runtime/binary.js:165:207)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Uo.request (/Users/miguel/GitHub/prisma/prisma-engines/repro/node_modules/@prisma/client/runtime/binary.js:176:2545)
    at async Object.singleLoader (/Users/miguel/GitHub/prisma/prisma-engines/repro/node_modules/@prisma/client/runtime/binary.js:187:5214)
    at async wl.request (/Users/miguel/GitHub/prisma/prisma-engines/repro/node_modules/@prisma/client/runtime/binary.js:187:5706)
    at async a (/Users/miguel/GitHub/prisma/prisma-engines/repro/node_modules/@prisma/client/runtime/binary.js:192:9691) {
  code: undefined,
  clientVersion: '5.9.0-dev.10',
  meta: undefined
}

@SevInf SevInf merged commit b35b06e into main Jan 16, 2024
137 of 138 checks passed
@SevInf SevInf deleted the qe/connect-to-engine-json branch January 16, 2024 15:21
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.

3 participants