fix batch: make sure high_watermark>=batch, also put a max on batch size

This commit is contained in:
Simon Cruanes 2025-12-09 21:23:59 -05:00
parent 6c832df3a6
commit 2d8939ab0a
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4

View file

@ -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