Skip to content

Commit 5ea5db5

Browse files
frankmcsherryclaude
andcommitted
compute: make per-column compression flag replica-scoped
Addresses review feedback on MaterializeInc#37111: scope `enable_arrangement_column_compression_alpha` to the replica (`ParameterScope::Replica`) so it can carry per-replica / per-size-family overrides, like the other replica-local physical flags (lgalloc, persist pager, column-paged batcher). This also replaces the manual capture chain the flag previously borrowed from dictionary compression — InstanceConfig/ReplicaConfig fields, the controller's per-replica capture, and the `handle_create_instance` store — with the replica-scoped idiom: the per-replica-resolved value arrives in the replica's `worker_config`, and `apply_worker_config` mirrors it into the process-global `mz_row_spine::COLUMN_COMPRESSION` flag (next to the lgalloc-region store). The controller-level capture read only the environment value and would have missed per-replica overrides. Re-applying on each config tick is safe: every batch records its own codec, so a flip only affects batches sealed afterwards. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent d9f7564 commit 5ea5db5

6 files changed

Lines changed: 18 additions & 26 deletions

File tree

src/compute-client/src/controller.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ use mz_compute_types::ComputeInstanceId;
4444
use mz_compute_types::config::ComputeReplicaConfig;
4545
use mz_compute_types::dataflows::DataflowDescription;
4646
use mz_compute_types::dyncfgs::{
47-
COMPUTE_REPLICA_EXPIRATION_OFFSET, ENABLE_ARRANGEMENT_COLUMN_COMPRESSION_ALPHA,
48-
ENABLE_ARRANGEMENT_DICTIONARY_COMPRESSION_ALPHA,
47+
COMPUTE_REPLICA_EXPIRATION_OFFSET, ENABLE_ARRANGEMENT_DICTIONARY_COMPRESSION_ALPHA,
4948
};
5049
use mz_dyncfg::{ConfigSet, ConfigUpdates};
5150
use mz_expr::RowSetFinishing;
@@ -721,9 +720,6 @@ impl ComputeController {
721720
// why a later flip of the flag only affects replicas created afterwards.
722721
let arrangement_dictionary_compression =
723722
ENABLE_ARRANGEMENT_DICTIONARY_COMPRESSION_ALPHA.get(&self.dyncfg);
724-
// Likewise captured once at replica creation, independent of dictionary compression.
725-
let arrangement_column_compression =
726-
ENABLE_ARRANGEMENT_COLUMN_COMPRESSION_ALPHA.get(&self.dyncfg);
727723

728724
let replica_config = ReplicaConfig {
729725
location,
@@ -736,7 +732,6 @@ impl ComputeController {
736732
grpc_client: self.config.grpc_client.clone(),
737733
expiration_offset: (!expiration_offset.is_zero()).then_some(expiration_offset),
738734
arrangement_dictionary_compression,
739-
arrangement_column_compression,
740735
};
741736

742737
let instance = self.instance_mut(instance_id).expect("validated");

src/compute-client/src/controller/instance.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -993,7 +993,6 @@ impl Instance {
993993
logging: Default::default(),
994994
expiration_offset: Default::default(),
995995
arrangement_dictionary_compression: Default::default(),
996-
arrangement_column_compression: Default::default(),
997996
};
998997

999998
self.send(ComputeCommand::CreateInstance(Box::new(instance_config)));

src/compute-client/src/controller/replica.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ pub(super) struct ReplicaConfig {
5151
pub expiration_offset: Option<Duration>,
5252
/// Whether arrangements on this replica use dictionary compression, captured at creation.
5353
pub arrangement_dictionary_compression: bool,
54-
/// Whether arrangements on this replica use per-column compression, captured at creation.
55-
pub arrangement_column_compression: bool,
5654
}
5755

5856
/// A client for a replica task.
@@ -280,7 +278,6 @@ impl ReplicaTask {
280278
}
281279
config.arrangement_dictionary_compression =
282280
self.config.arrangement_dictionary_compression;
283-
config.arrangement_column_compression = self.config.arrangement_column_compression;
284281
}
285282
_ => {}
286283
}

src/compute-client/src/protocol/command.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -281,13 +281,6 @@ pub struct InstanceConfig {
281281
/// held fixed for the replica's lifetime, so flipping the flag only affects replicas created
282282
/// afterwards rather than retroactively changing arrangements across the environment.
283283
pub arrangement_dictionary_compression: bool,
284-
/// Whether arrangements created by this replica use per-column compression.
285-
///
286-
/// Captured from `enable_arrangement_column_compression_alpha` when the replica is created and
287-
/// held fixed for the replica's lifetime, exactly like `arrangement_dictionary_compression`.
288-
/// The two are independent; per-column compression layers over raw row bytes, not over
289-
/// dictionary-compressed bytes.
290-
pub arrangement_column_compression: bool,
291284
}
292285

293286
impl InstanceConfig {
@@ -310,14 +303,12 @@ impl InstanceConfig {
310303
peek_stash_persist_location: self_peek_stash_persist_location,
311304
// Captured at replica creation; intentionally not part of compatibility (see above).
312305
arrangement_dictionary_compression: _,
313-
arrangement_column_compression: _,
314306
} = self;
315307
let InstanceConfig {
316308
logging: other_logging,
317309
expiration_offset: other_offset,
318310
peek_stash_persist_location: other_peek_stash_persist_location,
319311
arrangement_dictionary_compression: _,
320-
arrangement_column_compression: _,
321312
} = other;
322313

323314
// Logging is compatible if exactly the same.

src/compute-types/src/dyncfgs.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,12 +401,15 @@ pub const ENABLE_ARRANGEMENT_DICTIONARY_COMPRESSION_ALPHA: Config<bool> = Config
401401

402402
/// Whether to enable per-column arrangement compression (the `RowCodec`
403403
/// framework). Independent of, and not combined with, dictionary compression.
404-
/// Like dictionary compression, captured at replica creation and held fixed.
404+
///
405+
/// Replica-scoped: the per-replica-resolved value is applied to the process-global
406+
/// `mz_row_spine::COLUMN_COMPRESSION` flag in the compute replica's `apply_worker_config`.
405407
pub const ENABLE_ARRANGEMENT_COLUMN_COMPRESSION_ALPHA: Config<bool> = Config::new(
406408
"enable_arrangement_column_compression_alpha",
407409
false,
408410
"Enable per-column arrangement compression (alpha; not yet production-ready).",
409-
);
411+
)
412+
.scoped(ParameterScope::Replica);
410413

411414
/// Whether to enable the peek response stash, for sending back large peek
412415
/// responses. The response stash will only be used for results that exceed

src/compute/src/compute_state.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,16 @@ impl ComputeState {
308308
std::sync::atomic::Ordering::Relaxed,
309309
);
310310

311+
// Per-column arrangement compression is replica-scoped (see
312+
// `ENABLE_ARRANGEMENT_COLUMN_COMPRESSION_ALPHA`), so its per-replica-resolved value
313+
// arrives in `worker_config`; mirror it into the process-global flag row-spine reads at
314+
// seal time. Safe to re-apply on every tick: each batch records its own codec, so a flip
315+
// only affects batches sealed afterwards.
316+
mz_row_spine::COLUMN_COMPRESSION.store(
317+
ENABLE_ARRANGEMENT_COLUMN_COMPRESSION_ALPHA.get(config),
318+
std::sync::atomic::Ordering::Relaxed,
319+
);
320+
311321
// NB: arrangement dictionary compression is deliberately NOT applied here. Unlike the
312322
// settings above, it is captured once at replica creation (see `handle_create_instance`
313323
// and `InstanceConfig::arrangement_dictionary_compression`) and held fixed, so that
@@ -489,11 +499,8 @@ impl<'a> ActiveComputeState<'a> {
489499
config.arrangement_dictionary_compression,
490500
std::sync::atomic::Ordering::Relaxed,
491501
);
492-
// Same one-shot treatment for per-column compression; see the note above.
493-
mz_row_spine::COLUMN_COMPRESSION.store(
494-
config.arrangement_column_compression,
495-
std::sync::atomic::Ordering::Relaxed,
496-
);
502+
// NB: per-column compression is replica-scoped and applied in `apply_worker_config`
503+
// (called just above), not captured on `InstanceConfig`.
497504

498505
if let Some(offset) = config.expiration_offset {
499506
self.compute_state.apply_expiration_offset(offset);

0 commit comments

Comments
 (0)