Repository navigation
reduce: stop keeping visited synthetic times as witnesses - #1113
Draft
frankmcsherry wants to merge 1 commit into
Draft
frankmcsherry wants to merge 1 commit into
frankmcsherry wants to merge 1 commit into
Conversation
The cursor reduce kept every synthetic time it visited in `times_current`, as a bare time. A bare time never cancels, so it stayed after the updates that produced it cancelled, and kept making later times interesting. With many input times retired in one round, this can cost about n²/2 evaluations where single steps cost about 3n. A visited synthetic time is no longer kept. What made it interesting stays in the batch buffer, and what it emits goes to `output_produced`. `output_produced` now also marks later times interesting and joins with uninteresting times, as `times_current` did. Both are advanced by the meet and consolidated, so they vanish once they cancel. `reduce_scaling_cancelled_history` runs such a round with n = 100,000. It takes about 2 s in debug with this change; on master-next the same workload takes 46 s at n = 1,000 and 361 s at n = 2,000. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The cursor reduce keeps every synthetic time it visits in
times_currentfor the rest of the round, and those times never cancel.When many input times are retired in one round, that can cost about n²/2 evaluations where one round per step costs about 3n.
This PR stops keeping them, and relies on the batch buffer and
output_produced, which do cancel.It is a draft for discussion; open questions are at the end.
The problem
At step
iof the test workload, a record is inserted at(i, n+1-i)and retracted at(i+1, n+1-i), and another record lives at(i, 0)for one step.The sweep finds the retraction time as the join of the seed
(i+1, 0)with the still-live insert, visits it, and pushes it intotimes_current.The insert and retraction then cancel in the batch buffer, but the bare time in
times_currentstays.Advanced by the meet it becomes
(s, n+1-i), which never merges with the others, and every later seed(s, 0)joins it into a fresh synthetic time that changes nothing.This is the case the TODO at the push described: "If we knew that the time derived from a canceled batch update, we could remove the time."
The change
times_current.output_produced, as it does withtimes_current. Interesting times already did.times_currentnow holds only the due pending times.Measurements
Logic calls and wall time on the test workload, one key, release, on an M4 Mac mini:
On master-next the counts are exactly (n+1)(n+4)/2; with this PR they are 3n+2, the same as one round per step.
The new test
reduce_scaling_cancelled_historyruns n = 100,000 in one round, in about 2 s in debug.On master-next the same test takes 46 s at n = 1,000 and 361 s at n = 2,000, in debug.
As with
reduce_scalingandjoin_scale_*, a regression shows up as a test that does not finish.Correctness checks, none committed:
examples/dynamic.rs(BFS) at four sizes up to 100,000 nodes: identical output, same time.cargo test -p differential-dataflow -p differential-dogs3 --all-targets: 114 passed, 3 ignored. Doc tests: 54 passed.How it lines up with
formal/No change to the model is needed.
In
Model.leanthe enumeration joins seeds with base times, and the base is the support of the stored input and output plus the seeds (viewBase).A time reached inside the interval is a seed joined with base times one at a time (
reached_of_mem_cl), so joins between two reached times add nothing there.A visited synthetic time that emitted nothing is in no support, so when a round is read as a sequence of finer rounds (#1110), later pieces never join with it.
The new interesting test is the README's "debt is created only above the seeds", read through the meet-advanced buffers: a time with no surviving batch entry, correction, or due pending time below it owes only what it owed before the round, and that sits above a pending time.
What is not proved is the step from the sweep to the model, the same informal step as before (#1110's "Not covered").
This change leans on it more: a visited time is now remembered only through buffers that cancel, where before the bare time stayed.
Questions
output_producedis advanced by the meet and consolidated only when a correction is added (the existing NOTE). It now does witness duty, so stale entries mean extra evaluations, never wrong output. Should it be compacted every step, astimes_currentis?reached, by design, and the same change there leaves the count unchanged (502,504 at n = 1,000 either way). Fixing it would mean letting seed evidence cancel. Separate PR, or not at all?next_timeto avoid putting it in totimes_current." and the TODO quoted above.Written by Claude Code (Claude Opus 5.5) from a design discussion; measured on an M4 Mac mini.
🤖 Generated with Claude Code