diff --git a/src/batch/Cargo.toml b/src/batch/Cargo.toml index ca3202bfe29b9..a53866cfde301 100644 --- a/src/batch/Cargo.toml +++ b/src/batch/Cargo.toml @@ -62,7 +62,7 @@ criterion = { version = "0.4", features = ["async_tokio", "async"] } rand = "0.8" tempfile = "3" -[target.'cfg(target_os = "linux")'.dev-dependencies] +[target.'cfg(unix)'.dev-dependencies] tikv-jemallocator = "0.5" [[bench]] diff --git a/src/batch/benches/expand.rs b/src/batch/benches/expand.rs index 9096c86d9ab0e..7c94cd6e176df 100644 --- a/src/batch/benches/expand.rs +++ b/src/batch/benches/expand.rs @@ -15,12 +15,12 @@ pub mod utils; use criterion::{criterion_group, criterion_main, BatchSize, BenchmarkId, Criterion}; use risingwave_batch::executor::{BoxedExecutor, ExpandExecutor}; -use risingwave_common::enable_jemalloc_on_linux; +use risingwave_common::enable_jemalloc_on_unix; use risingwave_common::types::DataType; use tokio::runtime::Runtime; use utils::{create_input, execute_executor}; -enable_jemalloc_on_linux!(); +enable_jemalloc_on_unix!(); fn create_expand_executor( column_subsets: Vec>, diff --git a/src/batch/benches/filter.rs b/src/batch/benches/filter.rs index afe3e6a8ad5aa..f2ef54cfcb343 100644 --- a/src/batch/benches/filter.rs +++ b/src/batch/benches/filter.rs @@ -16,7 +16,7 @@ pub mod utils; use criterion::{criterion_group, criterion_main, BatchSize, BenchmarkId, Criterion}; use risingwave_batch::executor::{BoxedExecutor, FilterExecutor}; -use risingwave_common::enable_jemalloc_on_linux; +use risingwave_common::enable_jemalloc_on_unix; use risingwave_common::types::{DataType, ScalarImpl}; use risingwave_common::util::value_encoding::serialize_datum; use risingwave_expr::expr::build_from_prost; @@ -30,7 +30,7 @@ use risingwave_pb::expr::{ExprNode, FunctionCall}; use tokio::runtime::Runtime; use utils::{create_input, execute_executor}; -enable_jemalloc_on_linux!(); +enable_jemalloc_on_unix!(); fn create_filter_executor(chunk_size: usize, chunk_num: usize) -> BoxedExecutor { const CHUNK_SIZE: usize = 1024; diff --git a/src/batch/benches/hash_agg.rs b/src/batch/benches/hash_agg.rs index 0e5ec4dd175db..06200ef4700b2 100644 --- a/src/batch/benches/hash_agg.rs +++ b/src/batch/benches/hash_agg.rs @@ -18,14 +18,14 @@ use itertools::Itertools; use risingwave_batch::executor::{BoxedExecutor, HashAggExecutor}; use risingwave_common::catalog::{Field, Schema}; use risingwave_common::types::DataType; -use risingwave_common::{enable_jemalloc_on_linux, hash}; +use risingwave_common::{enable_jemalloc_on_unix, hash}; use risingwave_expr::expr::AggKind; use risingwave_expr::vector_op::agg::AggStateFactory; use risingwave_pb::expr::{AggCall, InputRef}; use tokio::runtime::Runtime; use utils::{create_input, execute_executor}; -enable_jemalloc_on_linux!(); +enable_jemalloc_on_unix!(); fn create_agg_call( input_schema: &Schema, diff --git a/src/batch/benches/hash_join.rs b/src/batch/benches/hash_join.rs index 77f92c23dc189..971fc75ebf09b 100644 --- a/src/batch/benches/hash_join.rs +++ b/src/batch/benches/hash_join.rs @@ -21,7 +21,7 @@ use risingwave_batch::executor::{BoxedExecutor, JoinType}; use risingwave_common::catalog::schema_test_utils::field_n; use risingwave_common::types::{DataType, ScalarImpl}; use risingwave_common::util::value_encoding::serialize_datum; -use risingwave_common::{enable_jemalloc_on_linux, hash}; +use risingwave_common::{enable_jemalloc_on_unix, hash}; use risingwave_expr::expr::build_from_prost; use risingwave_pb::data::data_type::TypeName; use risingwave_pb::data::PbDatum; @@ -32,7 +32,7 @@ use risingwave_pb::expr::expr_node::Type::{ use risingwave_pb::expr::{ExprNode, FunctionCall}; use utils::bench_join; -enable_jemalloc_on_linux!(); +enable_jemalloc_on_unix!(); fn create_hash_join_executor( join_type: JoinType, diff --git a/src/batch/benches/limit.rs b/src/batch/benches/limit.rs index 90136ce705dda..45d1fc3d17b35 100644 --- a/src/batch/benches/limit.rs +++ b/src/batch/benches/limit.rs @@ -16,12 +16,12 @@ pub mod utils; use criterion::{criterion_group, criterion_main, BatchSize, BenchmarkId, Criterion}; use risingwave_batch::executor::{BoxedExecutor, LimitExecutor}; -use risingwave_common::enable_jemalloc_on_linux; +use risingwave_common::enable_jemalloc_on_unix; use risingwave_common::types::DataType; use tokio::runtime::Runtime; use utils::{create_input, execute_executor}; -enable_jemalloc_on_linux!(); +enable_jemalloc_on_unix!(); fn create_limit_executor( chunk_size: usize, diff --git a/src/batch/benches/nested_loop_join.rs b/src/batch/benches/nested_loop_join.rs index 50486193c2f33..2c8b36cb6ff3e 100644 --- a/src/batch/benches/nested_loop_join.rs +++ b/src/batch/benches/nested_loop_join.rs @@ -15,7 +15,7 @@ pub mod utils; use criterion::{criterion_group, criterion_main, Criterion}; use risingwave_batch::executor::{BoxedExecutor, JoinType, NestedLoopJoinExecutor}; -use risingwave_common::enable_jemalloc_on_linux; +use risingwave_common::enable_jemalloc_on_unix; use risingwave_common::types::{DataType, ScalarImpl}; use risingwave_common::util::value_encoding::serialize_datum; use risingwave_expr::expr::build_from_prost; @@ -28,7 +28,7 @@ use risingwave_pb::expr::expr_node::Type::{ use risingwave_pb::expr::{ExprNode, FunctionCall}; use utils::{bench_join, create_input}; -enable_jemalloc_on_linux!(); +enable_jemalloc_on_unix!(); fn create_nested_loop_join_executor( join_type: JoinType, diff --git a/src/batch/benches/sort.rs b/src/batch/benches/sort.rs index f8de2fa730e9c..d99670f04ad44 100644 --- a/src/batch/benches/sort.rs +++ b/src/batch/benches/sort.rs @@ -16,13 +16,13 @@ pub mod utils; use criterion::{criterion_group, criterion_main, BatchSize, BenchmarkId, Criterion}; use risingwave_batch::executor::{BoxedExecutor, SortExecutor}; -use risingwave_common::enable_jemalloc_on_linux; +use risingwave_common::enable_jemalloc_on_unix; use risingwave_common::types::DataType; use risingwave_common::util::sort_util::{ColumnOrder, OrderType}; use tokio::runtime::Runtime; use utils::{create_input, execute_executor}; -enable_jemalloc_on_linux!(); +enable_jemalloc_on_unix!(); fn create_order_by_executor( chunk_size: usize, diff --git a/src/batch/benches/top_n.rs b/src/batch/benches/top_n.rs index 9d3a51a8a0320..717fcab2d497a 100644 --- a/src/batch/benches/top_n.rs +++ b/src/batch/benches/top_n.rs @@ -16,13 +16,13 @@ pub mod utils; use criterion::{criterion_group, criterion_main, BatchSize, BenchmarkId, Criterion}; use risingwave_batch::executor::{BoxedExecutor, TopNExecutor}; -use risingwave_common::enable_jemalloc_on_linux; +use risingwave_common::enable_jemalloc_on_unix; use risingwave_common::types::DataType; use risingwave_common::util::sort_util::{ColumnOrder, OrderType}; use tokio::runtime::Runtime; use utils::{create_input, execute_executor}; -enable_jemalloc_on_linux!(); +enable_jemalloc_on_unix!(); fn create_top_n_executor( chunk_size: usize, diff --git a/src/cmd/Cargo.toml b/src/cmd/Cargo.toml index 7a53b0400a5d0..115cb9d397d1e 100644 --- a/src/cmd/Cargo.toml +++ b/src/cmd/Cargo.toml @@ -42,7 +42,7 @@ tokio = { version = "0.2", package = "madsim-tokio", features = [ workspace-config = { path = "../utils/workspace-config", optional = true } workspace-hack = { path = "../workspace-hack" } -[target.'cfg(target_os = "linux")'.dependencies] +[target.'cfg(unix)'.dependencies] tikv-jemallocator = { version = "0.5", features = ["profiling", "stats"] } [[bin]] diff --git a/src/cmd/src/bin/compactor.rs b/src/cmd/src/bin/compactor.rs index 708e849a479c1..1588e7635bea8 100644 --- a/src/cmd/src/bin/compactor.rs +++ b/src/cmd/src/bin/compactor.rs @@ -14,9 +14,9 @@ #![cfg_attr(coverage, feature(no_coverage))] -use risingwave_common::enable_jemalloc_on_linux; +use risingwave_common::enable_jemalloc_on_unix; -enable_jemalloc_on_linux!(); +enable_jemalloc_on_unix!(); #[cfg_attr(coverage, no_coverage)] fn main() { diff --git a/src/cmd/src/bin/compute_node.rs b/src/cmd/src/bin/compute_node.rs index cfef0e095f9bc..a15d9b206ba8a 100644 --- a/src/cmd/src/bin/compute_node.rs +++ b/src/cmd/src/bin/compute_node.rs @@ -14,9 +14,9 @@ #![cfg_attr(coverage, feature(no_coverage))] -use risingwave_common::enable_task_local_jemalloc_on_linux; +use risingwave_common::enable_task_local_jemalloc_on_unix; -enable_task_local_jemalloc_on_linux!(); +enable_task_local_jemalloc_on_unix!(); #[cfg_attr(coverage, no_coverage)] fn main() { diff --git a/src/cmd/src/bin/ctl.rs b/src/cmd/src/bin/ctl.rs index af694b694bd29..ca529a919e734 100644 --- a/src/cmd/src/bin/ctl.rs +++ b/src/cmd/src/bin/ctl.rs @@ -15,9 +15,9 @@ #![cfg_attr(coverage, feature(no_coverage))] use anyhow::Result; -use risingwave_common::enable_jemalloc_on_linux; +use risingwave_common::enable_jemalloc_on_unix; -enable_jemalloc_on_linux!(); +enable_jemalloc_on_unix!(); #[cfg_attr(coverage, no_coverage)] fn main() -> Result<()> { diff --git a/src/cmd/src/bin/frontend_node.rs b/src/cmd/src/bin/frontend_node.rs index 1c212e83964b1..5c5c4f66c473d 100644 --- a/src/cmd/src/bin/frontend_node.rs +++ b/src/cmd/src/bin/frontend_node.rs @@ -14,9 +14,9 @@ #![cfg_attr(coverage, feature(no_coverage))] -use risingwave_common::enable_jemalloc_on_linux; +use risingwave_common::enable_jemalloc_on_unix; -enable_jemalloc_on_linux!(); +enable_jemalloc_on_unix!(); #[cfg_attr(coverage, no_coverage)] fn main() { diff --git a/src/cmd/src/bin/meta_node.rs b/src/cmd/src/bin/meta_node.rs index d8096a6ff9a4b..2b83291038532 100644 --- a/src/cmd/src/bin/meta_node.rs +++ b/src/cmd/src/bin/meta_node.rs @@ -14,9 +14,9 @@ #![cfg_attr(coverage, feature(no_coverage))] -use risingwave_common::enable_jemalloc_on_linux; +use risingwave_common::enable_jemalloc_on_unix; -enable_jemalloc_on_linux!(); +enable_jemalloc_on_unix!(); #[cfg_attr(coverage, no_coverage)] fn main() { diff --git a/src/cmd_all/Cargo.toml b/src/cmd_all/Cargo.toml index a8b02c9c99c70..8ad41939680c7 100644 --- a/src/cmd_all/Cargo.toml +++ b/src/cmd_all/Cargo.toml @@ -43,7 +43,7 @@ tracing = { version = "0.1" } workspace-config = { path = "../utils/workspace-config", optional = true } workspace-hack = { path = "../workspace-hack" } -[target.'cfg(target_os = "linux")'.dependencies] +[target.'cfg(unix)'.dependencies] tikv-jemallocator = { version = "0.5", features = ["profiling", "stats"] } [[bin]] diff --git a/src/cmd_all/src/bin/risingwave.rs b/src/cmd_all/src/bin/risingwave.rs index 5c014b9001194..1556682843267 100644 --- a/src/cmd_all/src/bin/risingwave.rs +++ b/src/cmd_all/src/bin/risingwave.rs @@ -21,10 +21,10 @@ use std::env; use anyhow::{bail, Result}; use clap::Parser; use risingwave_cmd_all::playground; -use risingwave_common::enable_task_local_jemalloc_on_linux; +use risingwave_common::enable_task_local_jemalloc_on_unix; use tracing::Level; -enable_task_local_jemalloc_on_linux!(); +enable_task_local_jemalloc_on_unix!(); type RwFns = HashMap<&'static str, Box) -> Result<()>>>; diff --git a/src/common/src/jemalloc.rs b/src/common/src/jemalloc.rs index 3c13db1866ca3..5b7e1e4a2baed 100644 --- a/src/common/src/jemalloc.rs +++ b/src/common/src/jemalloc.rs @@ -14,18 +14,18 @@ /// If is resolved, we may inline this #[macro_export] -macro_rules! enable_jemalloc_on_linux { +macro_rules! enable_jemalloc_on_unix { () => { - #[cfg(target_os = "linux")] + #[cfg(unix)] #[global_allocator] static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; }; } #[macro_export] -macro_rules! enable_task_local_jemalloc_on_linux { +macro_rules! enable_task_local_jemalloc_on_unix { () => { - #[cfg(target_os = "linux")] + #[cfg(unix)] #[global_allocator] static GLOBAL: task_stats_alloc::TaskLocalAlloc = task_stats_alloc::TaskLocalAlloc(tikv_jemallocator::Jemalloc); diff --git a/src/compute/src/memory_management/mod.rs b/src/compute/src/memory_management/mod.rs index 6e3c7526af8aa..89d6f8b1a63b2 100644 --- a/src/compute/src/memory_management/mod.rs +++ b/src/compute/src/memory_management/mod.rs @@ -13,6 +13,9 @@ // limitations under the License. pub mod memory_manager; + +// Only enable the non-trivial policies on Linux as it relies on statistics from `jemalloc-ctl` +// which might be inaccurate on other platforms. #[cfg(target_os = "linux")] pub mod policy;