diff --git a/crates/buzz-db/src/batch.rs b/crates/buzz-db/src/batch.rs index c1cbdecd8..f6a180f2d 100644 --- a/crates/buzz-db/src/batch.rs +++ b/crates/buzz-db/src/batch.rs @@ -55,7 +55,9 @@ use crate::error::{DbError, Result}; use crate::event::ThreadMetadataParams; use crate::Db; -/// Default maximum events coalesced into one transaction. +/// Suggested maximum events coalesced into one transaction when batching is +/// enabled. Not the relay default — `BUZZ_WRITE_BATCH_MAX` defaults to `0` +/// (batching off); see `Config::from_env` in `buzz-relay`. pub const DEFAULT_MAX_BATCH: usize = 16; /// Queue depth for pending insert requests (matches the relay's default diff --git a/crates/buzz-relay/src/config.rs b/crates/buzz-relay/src/config.rs index abc756dcb..7c398deae 100644 --- a/crates/buzz-relay/src/config.rs +++ b/crates/buzz-relay/src/config.rs @@ -68,7 +68,10 @@ pub struct Config { pub max_concurrent_handlers: usize, /// Maximum plain event inserts coalesced into one group-commit /// transaction (`BUZZ_WRITE_BATCH_MAX`). `0` disables batching and every - /// insert commits individually (the pre-batching behavior). + /// insert commits individually (the pre-batching behavior). Defaults to + /// `0`: benchmarks on the repaired-T1a base showed the single batch lane + /// cuts DB commits/msg ~25% but regresses p50/p99 latency at 500-1000 QPS, + /// so batching is opt-in until that trade-off is resolved. pub write_batch_max: usize, /// Per-connection outbound message buffer size (number of messages). pub send_buffer_size: usize, @@ -433,10 +436,13 @@ impl Config { .and_then(|v| v.parse().ok()) .unwrap_or(1024); + // Default off (`0`): group-commit batching measurably regressed + // p50/p99 latency at 500-1000 QPS on the repaired-T1a base despite + // saving ~25% of DB commits. Opt in explicitly per deployment. let write_batch_max = std::env::var("BUZZ_WRITE_BATCH_MAX") .ok() .and_then(|v| v.parse().ok()) - .unwrap_or(buzz_db::batch::DEFAULT_MAX_BATCH); + .unwrap_or(0); let send_buffer_size = std::env::var("BUZZ_SEND_BUFFER") .ok()