From 2d8939ab0aa39d59c9736dbeaf8d630eb24b8c30 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Tue, 9 Dec 2025 21:23:59 -0500 Subject: [PATCH] fix batch: make sure high_watermark>=batch, also put a max on batch size --- src/client/batch.ml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/client/batch.ml b/src/client/batch.ml index 110d9514..57e7eb4f 100644 --- a/src/client/batch.ml +++ b/src/client/batch.ml @@ -13,18 +13,24 @@ type 'a t = { timeout: Mtime.span option; } -let default_high_watermark batch_size = max 10 (min (batch_size * 10) 1_000_000) +let max_batch_size = 100_000 + +let default_high_watermark batch_size = + max 10 (min (batch_size * 10) max_batch_size) let _dummy_start = Mtime.min_stamp let _empty_state : _ state = { q = []; size = 0; start = _dummy_start } let make ?(batch = 100) ?high_watermark ?now ?timeout () : _ t = + let batch = min batch max_batch_size in let high_watermark = match high_watermark with - | Some x -> x + | Some x -> max x batch (* high watermark must be >= batch *) | None -> default_high_watermark batch in + assert (high_watermark >= batch); + let start = match now with | Some x -> x