Skip to content

Commit

Permalink
feat(qe): use mimalloc instead of the system allocator
Browse files Browse the repository at this point in the history
  • Loading branch information
aqrln committed Sep 26, 2024
1 parent b43a787 commit e348b85
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions query-engine/query-engine-node-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ tokio.workspace = true
futures = "0.3"
query-engine-metrics = { path = "../metrics" }

mimalloc = "0.1.43"

[build-dependencies]
napi-build = "1"
build-utils.path = "../../libs/build-utils"
5 changes: 5 additions & 0 deletions query-engine/query-engine-node-api/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use mimalloc::MiMalloc;

pub mod engine;
pub mod error;
pub mod functions;
Expand All @@ -6,3 +8,6 @@ pub mod logger;
mod tracer;

pub(crate) type Result<T> = std::result::Result<T, error::ApiError>;

#[global_allocator]
static GLOBAL: MiMalloc = MiMalloc;
1 change: 1 addition & 0 deletions query-engine/query-engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ connector = { path = "../connectors/query-connector", package = "query-connector
enumflags2.workspace = true
psl = { workspace = true, features = ["all"] }
graphql-parser = { git = "https://github.com/prisma/graphql-parser" }
mimalloc = "0.1.43"
mongodb-connector = { path = "../connectors/mongodb-query-connector", optional = true, package = "mongodb-query-connector" }
query-core = { path = "../core", features = ["metrics"] }
request-handlers = { path = "../request-handlers", features = ["all"] }
Expand Down
4 changes: 4 additions & 0 deletions query-engine/query-engine/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#[macro_use]
extern crate tracing;

use mimalloc::MiMalloc;
use query_engine::cli::CliCommand;
use query_engine::context;
use query_engine::error::PrismaError;
Expand All @@ -13,6 +14,9 @@ use std::{error::Error, process};
use structopt::StructOpt;
use tracing::Instrument;

#[global_allocator]
static GLOBAL: MiMalloc = MiMalloc;

type AnyError = Box<dyn Error + Send + Sync + 'static>;

#[tokio::main]
Expand Down

0 comments on commit e348b85

Please sign in to comment.