aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2021-05-17 13:29:58 +0000
committerFuwn <[email protected]>2021-05-17 13:29:58 +0000
commit94ee182f62d6cc351a8079b7fe54ef37b6336824 (patch)
tree062dad2421bccab834a700e97906eb62fa79202b
parentperf(global): perform link time optimization across all crates in release mode (diff)
downloadwhirl-94ee182f62d6cc351a8079b7fe54ef37b6336824.tar.xz
whirl-94ee182f62d6cc351a8079b7fe54ef37b6336824.zip
perf(global): custom allocator and adjust codegen-units
-rw-r--r--.cargo/config.toml2
-rw-r--r--Cargo.toml1
-rw-r--r--whirl/Cargo.toml7
-rw-r--r--whirl/src/lib.rs7
4 files changed, 17 insertions, 0 deletions
diff --git a/.cargo/config.toml b/.cargo/config.toml
new file mode 100644
index 0000000..03f4879
--- /dev/null
+++ b/.cargo/config.toml
@@ -0,0 +1,2 @@
+[build]
+rustflags = ["-Ctarget-cpu=native"]
diff --git a/Cargo.toml b/Cargo.toml
index b9ecf5a..b77f983 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -3,3 +3,4 @@ members = ["whirl_config", "whirl", "whirl_prompt", "whirl_server"]
[profile.release]
lto = "fat"
+codegen-units = 1
diff --git a/whirl/Cargo.toml b/whirl/Cargo.toml
index 7a84724..7277407 100644
--- a/whirl/Cargo.toml
+++ b/whirl/Cargo.toml
@@ -63,3 +63,10 @@ whirl_prompt = { path = "../whirl_prompt" }
# Server
whirl_server = { path = "../whirl_server" }
+# Allocator
+[target.'cfg(target_family = "windows")'.dependencies]
+mimalloc = { version = "0.1.25", default-features = false }
+
+[target.'cfg(target_family = "unix")'.dependencies]
+jemallocator = "0.3.2"
+
diff --git a/whirl/src/lib.rs b/whirl/src/lib.rs
index 7b45e18..e287d0e 100644
--- a/whirl/src/lib.rs
+++ b/whirl/src/lib.rs
@@ -20,6 +20,13 @@ extern crate serde_derive;
// #[macro_use]
// extern crate simple_error;
+#[cfg(target_family = "windows")]
+#[global_allocator]
+static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
+
+#[cfg(target_family = "unix")]
+static GLOBAL: jemallocator::Jemalloc = jemallocator::Jemalloc;
+
pub mod cli;
pub mod subs;