Skip to content

Commit 56bedd1

Browse files
committed
Pivot to specifying all of MALLOC_CONF in flag
Signed-off-by: Moritz Hoffmann <[email protected]>
1 parent c905d08 commit 56bedd1

File tree

7 files changed

+41
-40
lines changed

7 files changed

+41
-40
lines changed

misc/python/materialize/mzcompose/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ def get_minimal_system_parameters(
7777
# -----
7878
# Others (ordered by name)
7979
"allow_real_time_recency": "true",
80+
"clusterd_malloc_conf": "thp:always",
8081
"constraint_based_timestamp_selection": "verify",
8182
"enable_compute_peek_response_stash": "true",
8283
"enable_0dt_deployment": "true" if zero_downtime else "false",
@@ -113,7 +114,6 @@ def get_minimal_system_parameters(
113114
"enable_sql_server_source": "true",
114115
"enable_statement_lifecycle_logging": "true",
115116
"enable_compute_temporal_bucketing": "true",
116-
"enabel_transparent_hugepages": "true",
117117
"enable_variadic_left_join_lowering": "true",
118118
"enable_worker_core_affinity": "true",
119119
"grpc_client_http2_keep_alive_timeout": "5s",
@@ -565,7 +565,7 @@ def get_default_system_parameters(
565565
"enable_ctp_cluster_protocols",
566566
"enable_paused_cluster_readhold_downgrade",
567567
"force_swap_for_cc_sizes",
568-
"enable_transparent_hugepages",
568+
"clusterd_malloc_conf",
569569
]
570570

571571

misc/python/materialize/parallel_workload/action.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1322,7 +1322,7 @@ def __init__(
13221322
"enable_mz_join_core_v2",
13231323
"force_swap_for_cc_sizes",
13241324
"enable_with_ordinality_legacy_fallback",
1325-
"enable_transparent_hugepages",
1325+
"clusterd_malloc_conf",
13261326
]
13271327

13281328
def run(self, exe: Executor) -> bool:

src/controller-types/src/dyncfgs.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ pub const ENABLE_PAUSED_CLUSTER_READHOLD_DOWNGRADE: Config<bool> = Config::new(
8080
"Aggressively downgrade input read holds for indexes on zero-replica clusters.",
8181
);
8282

83-
pub const ENABLE_TRANSPARENT_HUGEPAGES: Config<bool> = Config::new(
84-
"enable_transparent_hugepages",
85-
false,
86-
"Enable transparent hugepages in clusterd with jemalloc.",
83+
pub const CLUSTERD_MALLOC_CONF: Config<&str> = Config::new(
84+
"clusterd_malloc_conf",
85+
"",
86+
"MALLOC_CONF to pass to clusterd. If empty, no MALLOC_CONF is set.",
8787
);
8888

8989
/// Adds the full set of all controller `Config`s.
@@ -96,7 +96,7 @@ pub fn all_dyncfgs(configs: ConfigSet) -> ConfigSet {
9696
.add(&WALLCLOCK_LAG_HISTOGRAM_PERIOD_INTERVAL)
9797
.add(&ENABLE_TIMELY_ZERO_COPY)
9898
.add(&ENABLE_TIMELY_ZERO_COPY_LGALLOC)
99-
.add(&ENABLE_TRANSPARENT_HUGEPAGES)
99+
.add(&CLUSTERD_MALLOC_CONF)
100100
.add(&TIMELY_ZERO_COPY_LIMIT)
101101
.add(&ARRANGEMENT_EXERT_PROPORTIONALITY)
102102
.add(&ENABLE_CTP_CLUSTER_PROTOCOLS)

src/controller/src/clusters.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ use mz_compute_client::logging::LogVariant;
2626
use mz_compute_client::service::{ComputeClient, ComputeGrpcClient};
2727
use mz_compute_types::config::{ComputeReplicaConfig, ComputeReplicaLogging};
2828
use mz_controller_types::dyncfgs::{
29-
ARRANGEMENT_EXERT_PROPORTIONALITY, CONTROLLER_PAST_GENERATION_REPLICA_CLEANUP_RETRY_INTERVAL,
30-
ENABLE_CTP_CLUSTER_PROTOCOLS, ENABLE_TIMELY_ZERO_COPY, ENABLE_TIMELY_ZERO_COPY_LGALLOC,
31-
ENABLE_TRANSPARENT_HUGEPAGES, TIMELY_ZERO_COPY_LIMIT,
29+
ARRANGEMENT_EXERT_PROPORTIONALITY, CLUSTERD_MALLOC_CONF,
30+
CONTROLLER_PAST_GENERATION_REPLICA_CLEANUP_RETRY_INTERVAL, ENABLE_CTP_CLUSTER_PROTOCOLS,
31+
ENABLE_TIMELY_ZERO_COPY, ENABLE_TIMELY_ZERO_COPY_LGALLOC, TIMELY_ZERO_COPY_LIMIT,
3232
};
3333
use mz_controller_types::{ClusterId, ReplicaId};
3434
use mz_orchestrator::NamespacedOrchestrator;
@@ -665,6 +665,10 @@ where
665665
});
666666
}
667667

668+
let clusterd_malloc_conf = CLUSTERD_MALLOC_CONF.get(&self.dyncfg);
669+
let clusterd_malloc_conf =
670+
(!clusterd_malloc_conf.is_empty()).then_some(clusterd_malloc_conf);
671+
668672
let service = self.orchestrator.ensure_service(
669673
&service_name,
670674
ServiceConfig {
@@ -819,7 +823,7 @@ where
819823
}],
820824
disk_limit,
821825
node_selector: location.allocation.selectors,
822-
enable_transparent_hugepages: ENABLE_TRANSPARENT_HUGEPAGES.get(&self.dyncfg),
826+
clusterd_malloc_conf,
823827
},
824828
)?;
825829

src/orchestrator-kubernetes/src/lib.rs

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ impl NamespacedOrchestrator for NamespacedKubernetesOrchestrator {
568568
replicas_selector,
569569
disk_limit,
570570
node_selector,
571-
enable_transparent_hugepages,
571+
clusterd_malloc_conf,
572572
}: ServiceConfig,
573573
) -> Result<Box<dyn Service>, anyhow::Error> {
574574
// This is extremely cheap to clone, so just look into the lock once.
@@ -972,30 +972,27 @@ impl NamespacedOrchestrator for NamespacedKubernetesOrchestrator {
972972
}]
973973
});
974974

975-
let mut env = if self.config.coverage {
976-
Some(vec![EnvVar {
975+
let mut env = Vec::new();
976+
977+
if self.config.coverage {
978+
env.push(EnvVar {
977979
name: "LLVM_PROFILE_FILE".to_string(),
978980
value: Some(format!("/coverage/{}-%p-%9m%c.profraw", self.namespace)),
979981
..Default::default()
980-
}])
981-
} else {
982-
None
983-
};
982+
});
983+
}
984984

985-
// Configure jemalloc to use transparent hugepages.
986-
if enable_transparent_hugepages {
987-
let var = EnvVar {
985+
// Configure jemalloc's MALLOC_CONF environment symbol.
986+
if let Some(malloc_conf) = clusterd_malloc_conf {
987+
env.push(EnvVar {
988988
name: "MALLOC_CONF".to_string(),
989-
value: Some("thp:always".to_string()),
989+
value: Some(malloc_conf),
990990
..Default::default()
991-
};
992-
if let Some(env) = &mut env {
993-
env.push(var);
994-
} else {
995-
env = Some(vec![var]);
996-
}
991+
});
997992
}
998993

994+
let env = (!env.is_empty()).then_some(env);
995+
999996
let mut volume_mounts = vec![];
1000997

1001998
if self.config.coverage {

src/orchestrator-process/src/lib.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ impl NamespacedOrchestrator for NamespacedProcessOrchestrator {
345345
cpu_limit: config.cpu_limit,
346346
scale: config.scale,
347347
labels: config.labels,
348-
enable_transparent_hugepages: config.enable_transparent_hugepages,
348+
clusterd_malloc_conf: config.clusterd_malloc_conf,
349349
disk,
350350
};
351351

@@ -462,8 +462,8 @@ struct EnsureServiceConfig {
462462
pub labels: BTreeMap<String, String>,
463463
/// Whether scratch disk space should be allocated for the service.
464464
pub disk: bool,
465-
/// Whether to enable transparent hugepages.
466-
pub enable_transparent_hugepages: bool,
465+
/// Optional jemalloc configuration.
466+
pub clusterd_malloc_conf: Option<String>,
467467
}
468468

469469
/// A task executing blocking work for a [`NamespacedProcessOrchestrator`] in the background.
@@ -575,7 +575,7 @@ impl OrchestratorWorker {
575575
scale,
576576
labels,
577577
disk,
578-
enable_transparent_hugepages,
578+
clusterd_malloc_conf,
579579
}: EnsureServiceConfig,
580580
) -> Result<(), anyhow::Error> {
581581
let full_id = self.config.full_id(&id);
@@ -690,7 +690,7 @@ impl OrchestratorWorker {
690690
memory_limit,
691691
cpu_limit,
692692
launch_spec: self.config.launch_spec,
693-
enable_transparent_hugepages,
693+
clusterd_malloc_conf: clusterd_malloc_conf.clone(),
694694
}),
695695
);
696696

@@ -796,7 +796,7 @@ impl OrchestratorWorker {
796796
memory_limit,
797797
cpu_limit,
798798
launch_spec,
799-
enable_transparent_hugepages,
799+
clusterd_malloc_conf,
800800
}: ServiceProcessConfig,
801801
) -> impl Future<Output = ()> + use<> {
802802
let suppress_output = self.config.suppress_output;
@@ -844,8 +844,8 @@ impl OrchestratorWorker {
844844
memory_limit.as_ref(),
845845
cpu_limit.as_ref(),
846846
);
847-
if enable_transparent_hugepages {
848-
cmd.env("MALLOC_CONF", "thp:always");
847+
if let Some(malloc_conf) = &clusterd_malloc_conf {
848+
cmd.env("MALLOC_CONF", malloc_conf);
849849
}
850850
info!(
851851
"launching {full_id}-{i} via {} {}...",
@@ -942,7 +942,7 @@ struct ServiceProcessConfig {
942942
memory_limit: Option<MemoryLimit>,
943943
cpu_limit: Option<CpuLimit>,
944944
launch_spec: LaunchSpec,
945-
enable_transparent_hugepages: bool,
945+
clusterd_malloc_conf: Option<String>,
946946
}
947947

948948
struct ServiceProcessPort {

src/orchestrator/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,8 @@ pub struct ServiceConfig {
243243
pub disk_limit: Option<DiskLimit>,
244244
/// Node selector for this service.
245245
pub node_selector: BTreeMap<String, String>,
246-
/// Whether to enable transparent hugepages.
247-
pub enable_transparent_hugepages: bool,
246+
/// Optional jemalloc configuration.
247+
pub clusterd_malloc_conf: Option<String>,
248248
}
249249

250250
/// A named port associated with a service.

0 commit comments

Comments
 (0)