Skip to content

communication: treat channel bounds like frontiers #518

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
14 changes: 6 additions & 8 deletions communication/src/allocator/zero_copy/allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl<A: AllocateBuilder> TcpBuilder<A> {
index: self.index,
peers: self.peers,
canaries: Rc::new(RefCell::new(Vec::new())),
channel_id_bound: None,
channel_id_upper: 0,
staged: Vec::new(),
sends,
recvs,
Expand All @@ -125,7 +125,7 @@ pub struct TcpAllocator<A: Allocate> {
staged: Vec<Bytes>, // staging area for incoming Bytes
canaries: Rc<RefCell<Vec<usize>>>,

channel_id_bound: Option<usize>,
channel_id_upper: usize,

// sending, receiving, and responding to binary buffers.
sends: Vec<Rc<RefCell<SendEndpoint<MergeQueue>>>>, // sends[x] -> goes to process x.
Expand All @@ -139,10 +139,8 @@ impl<A: Allocate> Allocate for TcpAllocator<A> {
fn allocate<T: Data>(&mut self, identifier: usize) -> (Vec<Box<dyn Push<Message<T>>>>, Box<dyn Pull<Message<T>>>) {

// Assume and enforce in-order identifier allocation.
if let Some(bound) = self.channel_id_bound {
assert!(bound < identifier);
}
self.channel_id_bound = Some(identifier);
assert!(self.channel_id_upper <= identifier);
self.channel_id_upper = identifier + 1;

// Result list of boxed pushers.
let mut pushes = Vec::<Box<dyn Push<Message<T>>>>::new();
Expand Down Expand Up @@ -235,7 +233,7 @@ impl<A: Allocate> Allocate for TcpAllocator<A> {
match self.to_local.entry(header.channel) {
Entry::Vacant(entry) => {
// We may receive data before allocating, and shouldn't block.
if self.channel_id_bound.map(|b| b < header.channel).unwrap_or(true) {
if self.channel_id_upper <= header.channel {
entry.insert(Rc::new(RefCell::new(VecDeque::new())))
.borrow_mut()
.push_back(peel);
Expand Down Expand Up @@ -275,4 +273,4 @@ impl<A: Allocate> Allocate for TcpAllocator<A> {
fn await_events(&self, duration: Option<std::time::Duration>) {
self.inner.await_events(duration);
}
}
}
14 changes: 6 additions & 8 deletions communication/src/allocator/zero_copy/allocator_process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl ProcessBuilder {
peers: self.peers,
events: Rc::new(RefCell::new(VecDeque::new())),
canaries: Rc::new(RefCell::new(Vec::new())),
channel_id_bound: None,
channel_id_upper: 0,
staged: Vec::new(),
sends,
recvs,
Expand Down Expand Up @@ -107,7 +107,7 @@ pub struct ProcessAllocator {

canaries: Rc<RefCell<Vec<usize>>>,

channel_id_bound: Option<usize>,
channel_id_upper: usize,

// sending, receiving, and responding to binary buffers.
staged: Vec<Bytes>,
Expand All @@ -122,10 +122,8 @@ impl Allocate for ProcessAllocator {
fn allocate<T: Data>(&mut self, identifier: usize) -> (Vec<Box<dyn Push<Message<T>>>>, Box<dyn Pull<Message<T>>>) {

// Assume and enforce in-order identifier allocation.
if let Some(bound) = self.channel_id_bound {
assert!(bound < identifier);
}
self.channel_id_bound = Some(identifier);
assert!(self.channel_id_upper <= identifier);
self.channel_id_upper = identifier + 1;

let mut pushes = Vec::<Box<dyn Push<Message<T>>>>::with_capacity(self.peers());

Expand Down Expand Up @@ -202,7 +200,7 @@ impl Allocate for ProcessAllocator {
match self.to_local.entry(header.channel) {
Entry::Vacant(entry) => {
// We may receive data before allocating, and shouldn't block.
if self.channel_id_bound.map(|b| b < header.channel).unwrap_or(true) {
if self.channel_id_upper <= header.channel {
entry.insert(Rc::new(RefCell::new(VecDeque::new())))
.borrow_mut()
.push_back(peel);
Expand Down Expand Up @@ -250,4 +248,4 @@ impl Allocate for ProcessAllocator {
}
}
}
}
}