Skip to content

Commit 05e6762

Browse files
committed
feat(hydro_lang): use mimalloc when compiling for an external host
1 parent 79e12dc commit 05e6762

5 files changed

Lines changed: 35 additions & 2 deletions

File tree

Cargo.lock

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

hydro_lang/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ build = ["dep:dfir_lang", "dep:backtrace", "dep:ctor"]
4848
trybuild = ["build", "dep:toml", "dep:prettyplease", "dep:stageleft_tool", "dep:trybuild-internals-api", "dep:sha2"]
4949
runtime_measure = ["dep:chrono", "dep:procfs"]
5050
runtime_support = ["dep:dfir_rs", "dfir_rs/deploy_integration"]
51+
runtime_mimalloc = ["dep:mimalloc"]
5152
dfir_context = ["dep:dfir_rs"]
5253

5354
[package.metadata.docs.rs]
@@ -65,6 +66,7 @@ dfir_rs = { path = "../dfir_rs", version = "^0.14.0", default-features = false,
6566
dfir_lang = { path = "../dfir_lang", version = "^0.14.0", optional = true }
6667
futures = "0.3.0"
6768
match_box = "0.0.2"
69+
mimalloc = { version = "0.1", optional = true }
6870
nameof = { version = "1.0.0", optional = true }
6971
prettyplease = { version = "0.2.0", features = ["verbatim"], optional = true }
7072
proc-macro-crate = "3.3"

hydro_lang/src/compile/trybuild/generate.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use trybuild_internals_api::{Runner, dependencies, features, path};
1818
#[cfg(feature = "deploy")]
1919
use super::rewriters::UseTestModeStaged;
2020

21-
pub const HYDRO_RUNTIME_FEATURES: &[&str] = &["deploy_integration", "runtime_measure"];
21+
pub const HYDRO_RUNTIME_FEATURES: &[&str] = &["deploy_integration", "runtime_measure", "runtime_mimalloc"];
2222

2323
pub(crate) static IS_TEST: std::sync::atomic::AtomicBool =
2424
std::sync::atomic::AtomicBool::new(false);
@@ -181,6 +181,9 @@ pub fn compile_graph_trybuild(
181181
use hydro_lang::runtime_support::dfir_rs as __root_dfir_rs;
182182
pub use #trybuild_crate_name_ident::__staged;
183183

184+
#[global_allocator]
185+
static GLOBAL: hydro_lang::runtime_support::mimalloc::MiMalloc = hydro_lang::runtime_support::mimalloc::MiMalloc;
186+
184187
#[allow(unused)]
185188
fn __hydro_runtime<'a>(__hydro_lang_trybuild_cli: &'a hydro_lang::runtime_support::dfir_rs::util::deploy::DeployPorts<hydro_lang::__staged::deploy::deploy_runtime::HydroMeta>) -> hydro_lang::runtime_support::dfir_rs::scheduled::graph::Dfir<'a> {
186189
#(#extra_stmts)*

hydro_lang/src/deploy/deploy_graph.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use hydro_deploy::custom_service::CustomClientPort;
1515
use hydro_deploy::rust_crate::RustCrateService;
1616
use hydro_deploy::rust_crate::ports::{DemuxSink, RustCrateSink, RustCrateSource, TaggedSource};
1717
use hydro_deploy::rust_crate::tracing_options::TracingOptions;
18-
use hydro_deploy::{CustomService, Deployment, Host, RustCrate, TracingResults};
18+
use hydro_deploy::{CustomService, Deployment, Host, HostTargetType, RustCrate, TracingResults};
1919
use hydro_deploy_integration::{ConnectedSink, ConnectedSource};
2020
use nameof::name_of;
2121
use proc_macro2::Span;
@@ -1043,6 +1043,7 @@ fn create_trybuild_service(
10431043
features: &Option<Vec<String>>,
10441044
bin_name: &str,
10451045
) -> RustCrate {
1046+
let target_type = trybuild.host.target_type();
10461047
let mut ret = RustCrate::new(dir, trybuild.host)
10471048
.target_dir(target_dir)
10481049
.example(bin_name)
@@ -1084,6 +1085,10 @@ fn create_trybuild_service(
10841085
.chain(trybuild.features),
10851086
);
10861087

1088+
if target_type != HostTargetType::Local {
1089+
ret = ret.features(["hydro___feature_runtime_mimalloc".to_string()]);
1090+
}
1091+
10871092
for (key, value) in trybuild.build_envs {
10881093
ret = ret.build_env(key, value);
10891094
}

hydro_lang/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ pub mod runtime_support {
2222
pub use colored;
2323
pub use {bincode, dfir_rs, stageleft, tokio};
2424
pub mod resource_measurement;
25+
26+
#[cfg(feature = "runtime_mimalloc")]
27+
pub use mimalloc;
2528
}
2629

2730
#[doc(hidden)]

0 commit comments

Comments
 (0)