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: Query Engine Wasm #4121

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 71 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 5 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,7 @@ napi-derive = "2.12.4"

[workspace.dependencies.quaint]
path = "quaint"
features = [
"bigdecimal",
"chrono",
"expose-drivers",
"fmt-sql",
"json",
"mssql",
"mysql",
"postgresql",
"sqlite",
"uuid",
]
features = ["workspace-default"]

[profile.dev.package.backtrace]
opt-level = 3
Expand All @@ -78,6 +67,10 @@ strip = "symbols"
[profile.release.package.query-engine]
strip = "symbols"

[profile.release.package.query-engine-wasm-api]
opt-level = 's'
debug = false

[profile.release]
lto = "fat"
codegen-units = 1
Expand Down
2 changes: 1 addition & 1 deletion libs/user-facing-errors/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ backtrace = "0.3.40"
tracing = "0.1"
indoc.workspace = true
itertools = "0.10"
quaint = { workspace = true, optional = true }
quaint = { path = "../../quaint", optional = true, features = ["slim"] }

[features]
default = []
Expand Down
12 changes: 9 additions & 3 deletions quaint/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ docs = []
# way to access database-specific methods when you need extra control.
expose-drivers = []

all = ["slim", "connectors", "pooled"]
all = ["slim", "connectors", "pooled", "serde-support"]

workspace-default = [
"slim",
"expose-drivers",
"fmt-sql",
]

connectors = [
"postgresql-connector",
Expand Down Expand Up @@ -122,7 +128,7 @@ serde = { version = "1.0", features = ["derive"] }
test-macros = { path = "test-macros" }
test-setup = { path = "test-setup" }
uuid = { version = "1", features = ["v4"] }
tokio = { version = "1.0", features = ["rt-multi-thread", "macros", "time"] }
tokio = { version = "1.25", features = ["macros", "time"] }

[target.'cfg(target_arch = "wasm32")'.dependencies.getrandom]
version = "0.2"
Expand Down Expand Up @@ -188,4 +194,4 @@ optional = true
[dependencies.tokio-util]
version = "0.6"
features = ["compat"]
optional = true
optional = true
6 changes: 3 additions & 3 deletions query-engine/connectors/mongodb-query-connector/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ rand = "0.7"
regex = "1"
serde_json = { version = "1.0", features = ["float_roundtrip"] }
thiserror = "1.0"
tokio.workspace = true
tokio = { version = "1.25", features = ["macros", "sync", "io-util", "time"] }
tracing = "0.1"
tracing-futures = "0.2"
uuid.workspace = true
Expand Down Expand Up @@ -46,8 +46,8 @@ workspace = true
[dependencies.serde]
workspace = true

[dependencies.cuid2]
version = "0.1.1"
[dependencies.cuid]
version = "1.2"

[dependencies.user-facing-errors]
features = ["sql"]
Expand Down
9 changes: 8 additions & 1 deletion query-engine/connectors/query-connector/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,24 @@ edition = "2021"
name = "query-connector"
version = "0.1.0"

[features]
default = ["native"]
native = ["prisma-models/default_generators"]

[dependencies]
anyhow = "1.0"
async-trait = "0.1.31"
chrono = {version = "0.4", features = ["serde"]}
futures = "0.3"
itertools = "0.10"
prisma-models = {path = "../../prisma-models"}
prisma-models = {path = "../../prisma-models", features = ["wasm_generators"] }
prisma-value = {path = "../../../libs/prisma-value"}
serde.workspace = true
serde_json.workspace = true
thiserror = "1.0"
user-facing-errors = { path = "../../../libs/user-facing-errors", features = ["sql"] }
uuid = "1"
indexmap = "1.7"

[target.'cfg(target_arch = "wasm32")'.dependencies]
getrandom = { version = "0.2", features = ["js"] }
15 changes: 9 additions & 6 deletions query-engine/connectors/sql-query-connector/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ version = "0.1.0"

[features]
vendored-openssl = ["quaint/vendored-openssl"]
js-connectors = []
native-connectors = ["quaint/pooled", "quaint/connectors"]
js-connectors = ["prisma-models/wasm_generators"]
native-connectors = ["cuid", "connector-interface/native", "quaint/pooled", "quaint/connectors"]
default = ["native-connectors"]

[dependencies]
Expand All @@ -20,20 +20,22 @@ once_cell = "1.3"
rand = "0.7"
serde_json = {version = "1.0", features = ["float_roundtrip"]}
thiserror = "1.0"
tokio.workspace = true
tokio = { version = "1.25", features = ["rt", "macros", "sync", "io-util", "time"] }
tracing = "0.1"
tracing-futures = "0.2"
uuid.workspace = true
opentelemetry = { version = "0.17", features = ["tokio"] }
tracing-opentelemetry = "0.17.3"
quaint.workspace = true
quaint = { path = "../../../quaint", features = ["slim"] }

[dependencies.connector-interface]
package = "query-connector"
path = "../query-connector"
default-features = false

[dependencies.prisma-models]
path = "../../prisma-models"
default-features = false

[dependencies.prisma-value]
path = "../../../libs/prisma-value"
Expand All @@ -46,8 +48,9 @@ version = "0.4"
features = ["derive"]
version = "1.0"

[dependencies.cuid2]
version = "0.1.1"
[dependencies.cuid]
version = "1.2"
optional = true

[dependencies.user-facing-errors]
features = ["sql"]
Expand Down
15 changes: 9 additions & 6 deletions query-engine/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,41 @@ name = "query-core"
version = "0.1.0"

[features]
default = ["metrics"]
default = ["native"]
native = ["metrics", "prisma-models/default_generators", "cuid", "connector/native"]
metrics = ["query-engine-metrics"]

[dependencies]
async-trait = "0.1"
bigdecimal = "0.3"
chrono = "0.4"
connection-string.workspace = true
connector = { path = "../connectors/query-connector", package = "query-connector" }
connector = { path = "../connectors/query-connector", package = "query-connector", default-features = false }
crossbeam-channel = "0.5.6"
psl.workspace = true
futures = "0.3"
indexmap = { version = "1.7", features = ["serde-1"] }
itertools = "0.10"
once_cell = "1"
petgraph = "0.4"
prisma-models = { path = "../prisma-models", features = ["default_generators"] }
prisma-models = { path = "../prisma-models", features = ["wasm_generators"] }
opentelemetry = { version = "0.17.0", features = ["rt-tokio", "serialize"] }
query-engine-metrics = { path = "../metrics", optional = true }
serde.workspace = true
serde_json.workspace = true
thiserror = "1.0"
tokio.workspace = true
tokio = { version = "1.25", features = ["macros", "sync", "io-util", "time"] }
tracing = { version = "0.1", features = ["attributes"] }
tracing-futures = "0.2"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
tracing-opentelemetry = "0.17.4"
user-facing-errors = { path = "../../libs/user-facing-errors" }
uuid = "1"
cuid2 = "0.1.1"
cuid = { version = "1.2", optional = true }
schema = { path = "../schema" }
lru = "0.7.7"
enumflags2 = "0.7"
getrandom = { version = "0.2", features = ["js"] }
instant = { version = "0.1", features = ["stdweb", "wasm-bindgen", "inaccurate"] } # Vercel Edge Function does not have performance API

[target.'cfg(target_arch = "wasm32")'.dependencies]
getrandom = { version = "0.2", features = ["js"] }
5 changes: 5 additions & 0 deletions query-engine/core/src/executor/execute_operation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub async fn execute_single_operation(
operation: &Operation,
trace_id: Option<String>,
) -> crate::Result<ResponseData> {
#[cfg(feature = "metrics")]
let operation_timer = Instant::now();

let (graph, serializer) = build_graph(&query_schema, operation.clone())?;
Expand All @@ -48,7 +49,9 @@ pub async fn execute_many_operations(
let mut results = Vec::with_capacity(queries.len());

for (i, (graph, serializer)) in queries.into_iter().enumerate() {
#[cfg(feature = "metrics")]
let operation_timer = Instant::now();

let result = execute_on(conn, graph, serializer, query_schema.as_ref(), trace_id.clone()).await;

#[cfg(feature = "metrics")]
Expand Down Expand Up @@ -149,7 +152,9 @@ async fn execute_self_contained(
retry_on_transient_error: bool,
trace_id: Option<String>,
) -> crate::Result<ResponseData> {
#[cfg(feature = "metrics")]
let operation_timer = Instant::now();

let result = if retry_on_transient_error {
execute_self_contained_with_retry(
&mut conn,
Expand Down
Loading
Loading