Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protect upsert workers from input overload #301

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/operators/arrange/upsert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,16 +193,23 @@ where
let mut priority_queue = BinaryHeap::<std::cmp::Reverse<(G::Timestamp, Tr::Key, Option<Tr::Val>)>>::new();
let mut updates = Vec::new();

let mut buffers = Vec::new();

move |input, output| {

// Stash capabilities and associated data (ordered by time).
// Read input out without doing work, to avoid trapping overloaded workers.
input.for_each(|cap, data| {
capabilities.insert(cap.retain());
data.swap(&mut buffer);
for (key, val, time) in buffer.drain(..) {
buffers.push(std::mem::take(&mut buffer));
});

// Stash capabilities and associated data (ordered by time).
for buffer in buffers.drain(..) {
for (key, val, time) in buffer {
priority_queue.push(std::cmp::Reverse((time, key, val)))
}
});
}

// Test to see if strict progress has occurred, which happens whenever any element of
// the old frontier is not greater or equal to the new frontier. It is only in this
Expand Down