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: complete format support #4818

Merged
merged 5 commits into from Apr 10, 2024
Merged

feat: complete format support #4818

merged 5 commits into from Apr 10, 2024

Conversation

jkomyno
Copy link
Contributor

@jkomyno jkomyno commented Apr 9, 2024

@jkomyno jkomyno self-assigned this Apr 9, 2024
Copy link
Contributor

github-actions bot commented Apr 9, 2024

WASM Query Engine file Size

Engine This PR Base branch Diff
Postgres 2.122MiB 2.124MiB -1.545KiB
Postgres (gzip) 835.308KiB 836.395KiB -1.087KiB
Mysql 2.092MiB 2.092MiB 46.000B
Mysql (gzip) 823.248KiB 823.309KiB -63.000B
Sqlite 1.987MiB 1.988MiB -383.000B
Sqlite (gzip) 783.859KiB 784.004KiB -149.000B

Copy link
Contributor

github-actions bot commented Apr 9, 2024

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

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     365 ms/iter       (362 ms … 370 ms)    369 ms    370 ms    370 ms
Web Assembly: Latest       451 ms/iter       (449 ms … 456 ms)    453 ms    456 ms    456 ms
Web Assembly: Current      446 ms/iter       (444 ms … 450 ms)    447 ms    450 ms    450 ms
Node API: Current          197 ms/iter       (195 ms … 201 ms)    199 ms    201 ms    201 ms

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

• movies.findMany({ take: 2000 })
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline  14'796 µs/iter (14'648 µs … 15'742 µs) 14'799 µs 15'742 µs 15'742 µs
Web Assembly: Latest    18'311 µs/iter (18'131 µs … 19'696 µs) 18'304 µs 19'696 µs 19'696 µs
Web Assembly: Current   18'477 µs/iter (17'962 µs … 22'657 µs) 18'249 µs 22'657 µs 22'657 µs
Node API: Current        8'041 µs/iter   (7'879 µs … 9'470 µs)  8'043 µs  9'470 µs  9'470 µs

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

• movies.findMany({ where: {...}, take: 2000 })
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline   2'322 µs/iter   (2'202 µs … 3'570 µs)  2'300 µs  3'323 µs  3'570 µs
Web Assembly: Latest     2'804 µs/iter   (2'737 µs … 3'364 µs)  2'823 µs  3'131 µs  3'364 µs
Web Assembly: Current    2'929 µs/iter   (2'721 µs … 6'269 µs)  2'811 µs  5'157 µs  6'269 µs
Node API: Current        1'429 µs/iter   (1'301 µs … 2'542 µs)  1'426 µs  2'125 µs  2'542 µs

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

• movies.findMany({ include: { cast: true } take: 2000 }) (m2m)
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline     567 ms/iter       (559 ms … 583 ms)    572 ms    583 ms    583 ms
Web Assembly: Latest       776 ms/iter       (769 ms … 793 ms)    781 ms    793 ms    793 ms
Web Assembly: Current      772 ms/iter       (764 ms … 792 ms)    778 ms    792 ms    792 ms
Node API: Current          479 ms/iter       (465 ms … 496 ms)    493 ms    496 ms    496 ms

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

• movies.findMany({ where: {...}, include: { cast: true } take: 2000 }) (m2m)
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline  78'060 µs/iter (77'693 µs … 79'036 µs) 78'269 µs 79'036 µs 79'036 µs
Web Assembly: Latest       109 ms/iter       (108 ms … 109 ms)    109 ms    109 ms    109 ms
Web Assembly: Current      108 ms/iter       (108 ms … 109 ms)    108 ms    109 ms    109 ms
Node API: Current       61'789 µs/iter (61'362 µs … 62'310 µs) 62'176 µs 62'310 µs 62'310 µs

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

• movies.findMany({ take: 2000, include: { cast: { include: { person: true } } } })
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline   1'013 ms/iter   (1'003 ms … 1'045 ms)  1'026 ms  1'045 ms  1'045 ms
Web Assembly: Latest     1'304 ms/iter   (1'291 ms … 1'321 ms)  1'317 ms  1'321 ms  1'321 ms
Web Assembly: Current    1'296 ms/iter   (1'285 ms … 1'313 ms)  1'305 ms  1'313 ms  1'313 ms
Node API: Current          896 ms/iter       (874 ms … 922 ms)    920 ms    922 ms    922 ms

summary for movies.findMany({ take: 2000, include: { cast: { include: { person: true } } } })
  Web Assembly: Current
   1.45x 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     142 ms/iter       (141 ms … 143 ms)    143 ms    143 ms    143 ms
Web Assembly: Latest       182 ms/iter       (181 ms … 184 ms)    183 ms    184 ms    184 ms
Web Assembly: Current      185 ms/iter       (184 ms … 185 ms)    185 ms    185 ms    185 ms
Node API: Current          109 ms/iter       (106 ms … 112 ms)    110 ms    112 ms    112 ms

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

• movie.findMany({ where: { reviews: { author: { ... } }, take: 100 }) (to-many -> to-one)
-------------------------------------------------------------- -----------------------------
Web Assembly: Baseline   1'054 µs/iter     (975 µs … 1'841 µs)  1'040 µs  1'748 µs  1'841 µs
Web Assembly: Latest     1'358 µs/iter   (1'291 µs … 1'980 µs)  1'364 µs  1'784 µs  1'980 µs
Web Assembly: Current    1'367 µs/iter   (1'295 µs … 2'197 µs)  1'366 µs  1'854 µs  2'197 µs
Node API: Current          788 µs/iter     (751 µs … 1'173 µs)    800 µs    912 µs  1'173 µs

summary for movie.findMany({ where: { reviews: { author: { ... } }, take: 100 }) (to-many -> to-one)
  Web Assembly: Current
   1.73x slower than Node API: Current
   1.3x 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'031 µs/iter     (979 µs … 1'710 µs)  1'030 µs  1'440 µs  1'710 µs
Web Assembly: Latest     1'347 µs/iter   (1'293 µs … 1'988 µs)  1'354 µs  1'759 µs  1'988 µs
Web Assembly: Current    1'350 µs/iter   (1'295 µs … 1'911 µs)  1'357 µs  1'683 µs  1'911 µs
Node API: Current          815 µs/iter     (716 µs … 1'361 µs)    813 µs  1'200 µs  1'361 µs

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

After changes in be1faff

@@ -1,6 +1,6 @@
mod actions;
mod format;
mod lint;
// mod lint;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changes to main.rs are necessary to let prisma-fmt compile.
I commented out the prisma-fmt lint command keeping in mind that, with https://github.com/prisma/team-orm/issues/1100, we will soon get rid of prisma-fmt's binary anyway

Comment on lines +11 to +19
impl<'de> Deserialize<'de> for SourceFile {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
let s: String = serde::de::Deserialize::deserialize(deserializer)?;
Ok(s.into())
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This allows deriving Multiple(Vec<(String, SourceFile)>) from Vec<(String, String)> within the following:

#[derive(Deserialize, Debug)]
#[serde(untagged)]
pub(crate) enum SchemaFileInput {
    Single(String),
    Multiple(Vec<(String, SourceFile)>),
}

It also highlights that SourceFile is created from a String.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!
Wouldn't putting #[serde(transparent)] over SourceFile do the same?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Afaik it wouldn't be the same, as SourceFile is essentially a newtype over a Contents field, not a String field

@jkomyno jkomyno marked this pull request as ready for review April 10, 2024 08:07
@jkomyno jkomyno requested a review from a team as a code owner April 10, 2024 08:07
@jkomyno jkomyno requested review from laplab and SevInf and removed request for a team and laplab April 10, 2024 08:07
Copy link

codspeed-hq bot commented Apr 10, 2024

CodSpeed Performance Report

Merging #4818 will not alter performance

Comparing integration/multi-prisma-fmt (be1faff) with main (f45ef6a)

Summary

✅ 11 untouched benchmarks

Copy link
Member

@Weakky Weakky left a comment

Choose a reason for hiding this comment

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

Looks good to me! (after CI goes green)

@jkomyno jkomyno merged commit dc758d7 into main Apr 10, 2024
208 of 209 checks passed
@jkomyno jkomyno deleted the integration/multi-prisma-fmt branch April 10, 2024 10:11
key-moon added a commit to key-moon/prisma-engines that referenced this pull request Apr 10, 2024
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.

None yet

3 participants