Skip to content

threshold_total: treat a zero count as absent - #993

Open
bos wants to merge 1 commit into
TimelyDataflow:master-nextfrom
bos:fix-threshold-total-zero
Open

bos wants to merge 1 commit into
TimelyDataflow:master-nextfrom
bos:fix-threshold-total-zero

Conversation

@bos

@bos bos commented Oct 21, 2026

Copy link
Copy Markdown

Fixes #992.

threshold_total called thresh on the count before and after each update, also when that count was zero. distinct_total gives it |_,_| 1, so when a key's count returned to zero it emitted 1 - 1 = 0 instead of -1. Whether a zero count reached thresh at all depended on whether the trace had merged away the updates that cancelled.

threshold_total now gives zero for a zero count and does not call thresh on it. threshold documents the same behaviour, and distinct_total keeps its closure.

Test plan

  • New tests/threshold.rs: distinct_total and threshold_total (with a thresh that does not map zero to zero) on a key that leaves and returns, with all updates in one batch and with one batch for each time. Both tests fail before the change.
  • A randomized comparison against a reference: 5,000 inputs in each scheduling order, including the order from reduce panics with "upper straddles batch" when its input frontier is ahead of its trace #990 (the operator runs before the arrange that feeds it), with no failures. count_total passes the same check without changes.
  • cargo test --workspace.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant