Skip to content

Commit 3d4bca7

Browse files
authored
fix: also enable jemalloc on macOS (risingwavelabs#8665)
Signed-off-by: Bugen Zhao <[email protected]>
1 parent 3079441 commit 3d4bca7

File tree

19 files changed

+38
-35
lines changed

19 files changed

+38
-35
lines changed

src/batch/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ criterion = { version = "0.4", features = ["async_tokio", "async"] }
6262
rand = "0.8"
6363
tempfile = "3"
6464

65-
[target.'cfg(target_os = "linux")'.dev-dependencies]
65+
[target.'cfg(unix)'.dev-dependencies]
6666
tikv-jemallocator = "0.5"
6767

6868
[[bench]]

src/batch/benches/expand.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ pub mod utils;
1515

1616
use criterion::{criterion_group, criterion_main, BatchSize, BenchmarkId, Criterion};
1717
use risingwave_batch::executor::{BoxedExecutor, ExpandExecutor};
18-
use risingwave_common::enable_jemalloc_on_linux;
18+
use risingwave_common::enable_jemalloc_on_unix;
1919
use risingwave_common::types::DataType;
2020
use tokio::runtime::Runtime;
2121
use utils::{create_input, execute_executor};
2222

23-
enable_jemalloc_on_linux!();
23+
enable_jemalloc_on_unix!();
2424

2525
fn create_expand_executor(
2626
column_subsets: Vec<Vec<usize>>,

src/batch/benches/filter.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub mod utils;
1616

1717
use criterion::{criterion_group, criterion_main, BatchSize, BenchmarkId, Criterion};
1818
use risingwave_batch::executor::{BoxedExecutor, FilterExecutor};
19-
use risingwave_common::enable_jemalloc_on_linux;
19+
use risingwave_common::enable_jemalloc_on_unix;
2020
use risingwave_common::types::{DataType, ScalarImpl};
2121
use risingwave_common::util::value_encoding::serialize_datum;
2222
use risingwave_expr::expr::build_from_prost;
@@ -30,7 +30,7 @@ use risingwave_pb::expr::{ExprNode, FunctionCall};
3030
use tokio::runtime::Runtime;
3131
use utils::{create_input, execute_executor};
3232

33-
enable_jemalloc_on_linux!();
33+
enable_jemalloc_on_unix!();
3434

3535
fn create_filter_executor(chunk_size: usize, chunk_num: usize) -> BoxedExecutor {
3636
const CHUNK_SIZE: usize = 1024;

src/batch/benches/hash_agg.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ use itertools::Itertools;
1818
use risingwave_batch::executor::{BoxedExecutor, HashAggExecutor};
1919
use risingwave_common::catalog::{Field, Schema};
2020
use risingwave_common::types::DataType;
21-
use risingwave_common::{enable_jemalloc_on_linux, hash};
21+
use risingwave_common::{enable_jemalloc_on_unix, hash};
2222
use risingwave_expr::expr::AggKind;
2323
use risingwave_expr::vector_op::agg::AggStateFactory;
2424
use risingwave_pb::expr::{AggCall, InputRef};
2525
use tokio::runtime::Runtime;
2626
use utils::{create_input, execute_executor};
2727

28-
enable_jemalloc_on_linux!();
28+
enable_jemalloc_on_unix!();
2929

3030
fn create_agg_call(
3131
input_schema: &Schema,

src/batch/benches/hash_join.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use risingwave_batch::executor::{BoxedExecutor, JoinType};
2121
use risingwave_common::catalog::schema_test_utils::field_n;
2222
use risingwave_common::types::{DataType, ScalarImpl};
2323
use risingwave_common::util::value_encoding::serialize_datum;
24-
use risingwave_common::{enable_jemalloc_on_linux, hash};
24+
use risingwave_common::{enable_jemalloc_on_unix, hash};
2525
use risingwave_expr::expr::build_from_prost;
2626
use risingwave_pb::data::data_type::TypeName;
2727
use risingwave_pb::data::PbDatum;
@@ -32,7 +32,7 @@ use risingwave_pb::expr::expr_node::Type::{
3232
use risingwave_pb::expr::{ExprNode, FunctionCall};
3333
use utils::bench_join;
3434

35-
enable_jemalloc_on_linux!();
35+
enable_jemalloc_on_unix!();
3636

3737
fn create_hash_join_executor(
3838
join_type: JoinType,

src/batch/benches/limit.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ pub mod utils;
1616

1717
use criterion::{criterion_group, criterion_main, BatchSize, BenchmarkId, Criterion};
1818
use risingwave_batch::executor::{BoxedExecutor, LimitExecutor};
19-
use risingwave_common::enable_jemalloc_on_linux;
19+
use risingwave_common::enable_jemalloc_on_unix;
2020
use risingwave_common::types::DataType;
2121
use tokio::runtime::Runtime;
2222
use utils::{create_input, execute_executor};
2323

24-
enable_jemalloc_on_linux!();
24+
enable_jemalloc_on_unix!();
2525

2626
fn create_limit_executor(
2727
chunk_size: usize,

src/batch/benches/nested_loop_join.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub mod utils;
1515

1616
use criterion::{criterion_group, criterion_main, Criterion};
1717
use risingwave_batch::executor::{BoxedExecutor, JoinType, NestedLoopJoinExecutor};
18-
use risingwave_common::enable_jemalloc_on_linux;
18+
use risingwave_common::enable_jemalloc_on_unix;
1919
use risingwave_common::types::{DataType, ScalarImpl};
2020
use risingwave_common::util::value_encoding::serialize_datum;
2121
use risingwave_expr::expr::build_from_prost;
@@ -28,7 +28,7 @@ use risingwave_pb::expr::expr_node::Type::{
2828
use risingwave_pb::expr::{ExprNode, FunctionCall};
2929
use utils::{bench_join, create_input};
3030

31-
enable_jemalloc_on_linux!();
31+
enable_jemalloc_on_unix!();
3232

3333
fn create_nested_loop_join_executor(
3434
join_type: JoinType,

src/batch/benches/sort.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ pub mod utils;
1616

1717
use criterion::{criterion_group, criterion_main, BatchSize, BenchmarkId, Criterion};
1818
use risingwave_batch::executor::{BoxedExecutor, SortExecutor};
19-
use risingwave_common::enable_jemalloc_on_linux;
19+
use risingwave_common::enable_jemalloc_on_unix;
2020
use risingwave_common::types::DataType;
2121
use risingwave_common::util::sort_util::{ColumnOrder, OrderType};
2222
use tokio::runtime::Runtime;
2323
use utils::{create_input, execute_executor};
2424

25-
enable_jemalloc_on_linux!();
25+
enable_jemalloc_on_unix!();
2626

2727
fn create_order_by_executor(
2828
chunk_size: usize,

src/batch/benches/top_n.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ pub mod utils;
1616

1717
use criterion::{criterion_group, criterion_main, BatchSize, BenchmarkId, Criterion};
1818
use risingwave_batch::executor::{BoxedExecutor, TopNExecutor};
19-
use risingwave_common::enable_jemalloc_on_linux;
19+
use risingwave_common::enable_jemalloc_on_unix;
2020
use risingwave_common::types::DataType;
2121
use risingwave_common::util::sort_util::{ColumnOrder, OrderType};
2222
use tokio::runtime::Runtime;
2323
use utils::{create_input, execute_executor};
2424

25-
enable_jemalloc_on_linux!();
25+
enable_jemalloc_on_unix!();
2626

2727
fn create_top_n_executor(
2828
chunk_size: usize,

src/cmd/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ tokio = { version = "0.2", package = "madsim-tokio", features = [
4242
workspace-config = { path = "../utils/workspace-config", optional = true }
4343
workspace-hack = { path = "../workspace-hack" }
4444

45-
[target.'cfg(target_os = "linux")'.dependencies]
45+
[target.'cfg(unix)'.dependencies]
4646
tikv-jemallocator = { version = "0.5", features = ["profiling", "stats"] }
4747

4848
[[bin]]

src/cmd/src/bin/compactor.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414

1515
#![cfg_attr(coverage, feature(no_coverage))]
1616

17-
use risingwave_common::enable_jemalloc_on_linux;
17+
use risingwave_common::enable_jemalloc_on_unix;
1818

19-
enable_jemalloc_on_linux!();
19+
enable_jemalloc_on_unix!();
2020

2121
#[cfg_attr(coverage, no_coverage)]
2222
fn main() {

src/cmd/src/bin/compute_node.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414

1515
#![cfg_attr(coverage, feature(no_coverage))]
1616

17-
use risingwave_common::enable_task_local_jemalloc_on_linux;
17+
use risingwave_common::enable_task_local_jemalloc_on_unix;
1818

19-
enable_task_local_jemalloc_on_linux!();
19+
enable_task_local_jemalloc_on_unix!();
2020

2121
#[cfg_attr(coverage, no_coverage)]
2222
fn main() {

src/cmd/src/bin/ctl.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
#![cfg_attr(coverage, feature(no_coverage))]
1616

1717
use anyhow::Result;
18-
use risingwave_common::enable_jemalloc_on_linux;
18+
use risingwave_common::enable_jemalloc_on_unix;
1919

20-
enable_jemalloc_on_linux!();
20+
enable_jemalloc_on_unix!();
2121

2222
#[cfg_attr(coverage, no_coverage)]
2323
fn main() -> Result<()> {

src/cmd/src/bin/frontend_node.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414

1515
#![cfg_attr(coverage, feature(no_coverage))]
1616

17-
use risingwave_common::enable_jemalloc_on_linux;
17+
use risingwave_common::enable_jemalloc_on_unix;
1818

19-
enable_jemalloc_on_linux!();
19+
enable_jemalloc_on_unix!();
2020

2121
#[cfg_attr(coverage, no_coverage)]
2222
fn main() {

src/cmd/src/bin/meta_node.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414

1515
#![cfg_attr(coverage, feature(no_coverage))]
1616

17-
use risingwave_common::enable_jemalloc_on_linux;
17+
use risingwave_common::enable_jemalloc_on_unix;
1818

19-
enable_jemalloc_on_linux!();
19+
enable_jemalloc_on_unix!();
2020

2121
#[cfg_attr(coverage, no_coverage)]
2222
fn main() {

src/cmd_all/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ tracing = { version = "0.1" }
4343
workspace-config = { path = "../utils/workspace-config", optional = true }
4444
workspace-hack = { path = "../workspace-hack" }
4545

46-
[target.'cfg(target_os = "linux")'.dependencies]
46+
[target.'cfg(unix)'.dependencies]
4747
tikv-jemallocator = { version = "0.5", features = ["profiling", "stats"] }
4848

4949
[[bin]]

src/cmd_all/src/bin/risingwave.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ use std::env;
2121
use anyhow::{bail, Result};
2222
use clap::Parser;
2323
use risingwave_cmd_all::playground;
24-
use risingwave_common::enable_task_local_jemalloc_on_linux;
24+
use risingwave_common::enable_task_local_jemalloc_on_unix;
2525
use tracing::Level;
2626

27-
enable_task_local_jemalloc_on_linux!();
27+
enable_task_local_jemalloc_on_unix!();
2828

2929
type RwFns = HashMap<&'static str, Box<dyn Fn(Vec<String>) -> Result<()>>>;
3030

src/common/src/jemalloc.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@
1414

1515
/// If <https://github.com/tikv/jemallocator/issues/22> is resolved, we may inline this
1616
#[macro_export]
17-
macro_rules! enable_jemalloc_on_linux {
17+
macro_rules! enable_jemalloc_on_unix {
1818
() => {
19-
#[cfg(target_os = "linux")]
19+
#[cfg(unix)]
2020
#[global_allocator]
2121
static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
2222
};
2323
}
2424

2525
#[macro_export]
26-
macro_rules! enable_task_local_jemalloc_on_linux {
26+
macro_rules! enable_task_local_jemalloc_on_unix {
2727
() => {
28-
#[cfg(target_os = "linux")]
28+
#[cfg(unix)]
2929
#[global_allocator]
3030
static GLOBAL: task_stats_alloc::TaskLocalAlloc<tikv_jemallocator::Jemalloc> =
3131
task_stats_alloc::TaskLocalAlloc(tikv_jemallocator::Jemalloc);

src/compute/src/memory_management/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
// limitations under the License.
1414

1515
pub mod memory_manager;
16+
17+
// Only enable the non-trivial policies on Linux as it relies on statistics from `jemalloc-ctl`
18+
// which might be inaccurate on other platforms.
1619
#[cfg(target_os = "linux")]
1720
pub mod policy;
1821

0 commit comments

Comments
 (0)