mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-10 10:44:22 +01:00
global allocator should not be set for library, only for executables
This commit is contained in:
10
Cargo.lock
generated
10
Cargo.lock
generated
@@ -2080,9 +2080,9 @@ checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa"
|
||||
|
||||
[[package]]
|
||||
name = "libmimalloc-sys"
|
||||
version = "0.1.42"
|
||||
version = "0.1.43"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec9d6fac27761dabcd4ee73571cdb06b7022dc99089acbe5435691edffaac0f4"
|
||||
checksum = "bf88cd67e9de251c1781dbe2f641a1a3ad66eaae831b8a2c38fbdc5ddae16d4d"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"libc",
|
||||
@@ -2380,9 +2380,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "mimalloc"
|
||||
version = "0.1.46"
|
||||
version = "0.1.47"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "995942f432bbb4822a7e9c3faa87a695185b0d09273ba85f097b54f4e458f2af"
|
||||
checksum = "b1791cbe101e95af5764f06f20f6760521f7158f69dbf9d6baf941ee1bf6bc40"
|
||||
dependencies = [
|
||||
"libmimalloc-sys",
|
||||
]
|
||||
@@ -4192,6 +4192,7 @@ dependencies = [
|
||||
"libc",
|
||||
"limbo_completion",
|
||||
"miette",
|
||||
"mimalloc",
|
||||
"nu-ansi-term 0.50.1",
|
||||
"rustyline",
|
||||
"schemars",
|
||||
@@ -4232,7 +4233,6 @@ dependencies = [
|
||||
"lru",
|
||||
"memory-stats",
|
||||
"miette",
|
||||
"mimalloc",
|
||||
"pack1",
|
||||
"parking_lot",
|
||||
"paste",
|
||||
|
||||
@@ -57,6 +57,7 @@ strum_macros = "0.26"
|
||||
serde = "1.0"
|
||||
serde_json = "1.0"
|
||||
anyhow = "1.0.98"
|
||||
mimalloc = { version = "0.1.47", default-features = false }
|
||||
|
||||
[profile.release]
|
||||
debug = "line-tables-only"
|
||||
|
||||
@@ -46,6 +46,7 @@ serde = { workspace = true, features = ["derive"]}
|
||||
validator = {version = "0.20.0", features = ["derive"]}
|
||||
toml_edit = {version = "0.22.24", features = ["serde"]}
|
||||
serde_json = "1.0"
|
||||
mimalloc = { workspace = true }
|
||||
|
||||
[features]
|
||||
default = ["io_uring"]
|
||||
|
||||
@@ -15,6 +15,10 @@ use std::{
|
||||
sync::{atomic::Ordering, LazyLock},
|
||||
};
|
||||
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
#[global_allocator]
|
||||
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
|
||||
|
||||
fn rustyline_config() -> Config {
|
||||
Config::builder()
|
||||
.completion_type(rustyline::CompletionType::List)
|
||||
|
||||
@@ -38,7 +38,6 @@ rustix = { version = "1.0.5", features = ["fs"] }
|
||||
libc = { version = "0.2.172" }
|
||||
|
||||
[target.'cfg(not(target_family = "wasm"))'.dependencies]
|
||||
mimalloc = { version = "0.1.46", default-features = false }
|
||||
libloading = "0.8.6"
|
||||
|
||||
[dependencies]
|
||||
|
||||
@@ -38,10 +38,6 @@ pub mod numeric;
|
||||
#[cfg(not(feature = "fuzz"))]
|
||||
mod numeric;
|
||||
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
#[global_allocator]
|
||||
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
|
||||
|
||||
use crate::translate::optimizer::optimize_plan;
|
||||
use crate::translate::pragma::TURSO_CDC_DEFAULT_TABLE_NAME;
|
||||
#[cfg(all(feature = "fs", feature = "conn_raw_api"))]
|
||||
|
||||
@@ -2,6 +2,27 @@
|
||||
|
||||
The `turso_ext` crate simplifies the creation and registration of libraries meant to extend the functionality of `Turso`, that can be loaded
|
||||
like traditional `sqlite3` extensions, but are able to be written in much more ergonomic Rust.
|
||||
|
||||
**Attention**
|
||||
If you wish to dynamic linking, currently you need to set your global_allocator to `MiMalloc` for non-wasm targets. Or you can clone the repo and change `macros/src/ext/mod.rs` to use your custom allocator:
|
||||
|
||||
E.g
|
||||
```diff
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
#[cfg(not(feature = "static"))]
|
||||
#[global_allocator]
|
||||
- static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
|
||||
+ static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc
|
||||
```
|
||||
|
||||
Then add the allocator to the extension you want to use
|
||||
|
||||
```toml
|
||||
[target.'cfg(not(target_family = "wasm"))'.dependencies]
|
||||
tikv-jemallocator = "0.5"
|
||||
```
|
||||
|
||||
Then you just the compile the dynamic library and extract the necessary `.so/.dylib/.dll` files from `.target` folder.
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user