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(core): add fork of cuid with wasm32-unknown-unknown support #4231

Merged
merged 3 commits into from
Oct 30, 2023

Conversation

jkomyno
Copy link
Contributor

@jkomyno jkomyno commented Sep 13, 2023

This PR deprecates #4217.

Is uses a cuid fork that is compatible with wasm32-unknown-unknown targets (as long the js feature of the getrandom dependency is active). See diff.

It closes https://github.com/prisma/team-orm/issues/350. It closes https://github.com/prisma/team-orm/issues/282.

How to test

In the wasm32-support branch of the cuid-rust fork

  • Run cargo test -p cuid -- collisions::test --ignored --test-threads=1
  • Run cargo test -p cuid -- collisions::single_thread --ignored --test-threads=1
  • Run nice -n -20 cargo bench

In this PR

  • Running cargo tree -p prisma-schema-build --target wasm32-unknown-unknown | grep cuid should yield:

    ❯ cargo tree -p prisma-schema-build --target wasm32-unknown-unknown | grep cuid
    │   │   │   ├── cuid v1.3.2 (https://github.com/prisma/cuid-rust?branch=wasm32-support#81309f9a)
    │   │   │   │   ├── cuid-util v0.1.0 (https://github.com/prisma/cuid-rust?branch=wasm32-support#81309f9a)
    │   │   │   │   ├── cuid2 v0.1.2 (https://github.com/prisma/cuid-rust?branch=wasm32-support#81309f9a)
    │   │   │   │   │   ├── cuid-util v0.1.0 (https://github.com/prisma/cuid-rust?branch=wasm32-support#81309f9a)

    indicating that Prisma's cuid fork with wasm32 support is pulled in the Wasm binary for @prisma/prisma-schema-wasm.

  • Running cargo tree -p query-engine-node-api -e features | grep getrandom should yield:

    ❯ cargo tree -p query-engine-node-api -e features | grep getrandom
    │       │       │   ├── getrandom feature "default"
    │       │       │   │   └── getrandom v0.2.10
    │       │       │                       │   │   └── getrandom feature "default" (*)
    │       │   │   │   │   │   │   │   │           └── getrandom feature "default" (*)
    │       │   │   │   │   │   │   │   ├── rand feature "getrandom"
    │       │   │   │   │   │   │   │   │   └── rand_core feature "getrandom"
    │       │   │   │   │   │   │   │       ├── getrandom feature "std"
    │       │   │   │   │   │   │   │       │   └── getrandom v0.2.10 (*)
    │       │   │   │   │   │   │   │       └── rand_core feature "getrandom" (*)
    │       ├── getrandom feature "default" (*)
    │       │   │       └── uuid feature "getrandom"
    │   │   │           │   │           └── getrandom feature "default"
    │   │   │           │   │               └── getrandom v0.1.16
    │   │   │           │   ├── getrandom feature "default" (*)
    │   │   │               ├── rand feature "getrandom"
    │   │   │               │   ├── rand feature "getrandom_package"
    │   │   │               │   └── rand_core feature "getrandom"
    │   │   │                   ├── getrandom feature "std"
    │   │   │                   │   └── getrandom v0.1.16 (*)
    │   │   │                   └── rand_core feature "getrandom" (*)

    indicating that the napi.rs Query Engine uses the default features of getrandom, rather than "js".

  • Running cargo tree -p prisma-schema-build -e features --target wasm32-unknown-unknown | grep getrandom should yield:

    ❯ cargo tree -p prisma-schema-build -e features --target wasm32-unknown-unknown | grep getrandom
    │       │       │       │       │       │   │   │           └── getrandom feature "default"
    │       │       │       │       │       │   │   │               └── getrandom v0.2.10
    │       │       │       │       │       │   │   ├── rand feature "getrandom"
    │       │       │       │       │       │   │   │   └── rand_core feature "getrandom"
    │       │       │       │       │       │   │       ├── rand_core feature "getrandom" (*)
    │       │       │       │       │       │   │       └── getrandom feature "std"
    │       │       │       │       │       │   │           └── getrandom v0.2.10 (*)
    │       │       │       ├── getrandom feature "default" (*)
    │       │       │       ├── getrandom feature "js"
    │       │       │       │   ├── getrandom v0.2.10 (*)
    │       │       │       │   ├── getrandom feature "js-sys"
    │       │       │       │   │   └── getrandom v0.2.10 (*)
    │       │       │       │   └── getrandom feature "wasm-bindgen"
    │       │       │       │       └── getrandom v0.2.10 (*)
    │       │       │       │       │   │   └── getrandom feature "default" (*)
    │       │       │           └── uuid feature "getrandom"

    indicating that @prisma/prisma-schema-wasm would use the "js" feature of getrandom.

  • Running cargo build -p prisma-schema-build --target wasm32-unknown-unknown && echo $? should exit with 0.

TODO:

@jkomyno jkomyno changed the title feat(core): add fork of "cuid" with wasm32-unknown-unknown support feat(core): add fork of cuid with wasm32-unknown-unknown support Sep 13, 2023
@jkomyno jkomyno added this to the 5.4.0 milestone Sep 13, 2023
@jkomyno jkomyno marked this pull request as ready for review September 13, 2023 05:24
@jkomyno jkomyno requested a review from a team as a code owner September 13, 2023 05:24
@jkomyno jkomyno requested a review from miguelff September 13, 2023 05:24
@codspeed-hq
Copy link

codspeed-hq bot commented Sep 13, 2023

CodSpeed Performance Report

Merging #4231 will not alter performance

Comparing feat/cuid-support-on-wasm32 (791d525) with main (6dda9d7)

Summary

✅ 11 untouched benchmarks

Copy link
Contributor

@janpio janpio left a comment

Choose a reason for hiding this comment

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

@miguelff
Copy link
Contributor

Really clean! thank you! ❤️

@janpio janpio added topic: driver adapters formerly phase 1 topic: edge functions formerly phase 2 and removed topic: driver adapters formerly phase 1 labels Sep 19, 2023
@jkomyno jkomyno modified the milestones: 5.4.0, 5.6.0 Oct 26, 2023
@jkomyno
Copy link
Contributor Author

jkomyno commented Oct 27, 2023

Note: we can merge this once these PRs are merged as well.

@jkomyno jkomyno merged commit 582b416 into main Oct 30, 2023
48 of 55 checks passed
@jkomyno jkomyno deleted the feat/cuid-support-on-wasm32 branch October 30, 2023 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: edge functions formerly phase 2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants