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

Make std::time::Instant optional #577

Open
wants to merge 3 commits 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
8 changes: 0 additions & 8 deletions communication/src/allocator/generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,6 @@ impl Allocate for Generic {
fn receive(&mut self) { self.receive(); }
fn release(&mut self) { self.release(); }
fn events(&self) -> &Rc<RefCell<Vec<usize>>> { self.events() }
fn await_events(&self, _duration: Option<std::time::Duration>) {
match self {
Generic::Thread(t) => t.await_events(_duration),
Generic::Process(p) => p.await_events(_duration),
Generic::ProcessBinary(pb) => pb.await_events(_duration),
Generic::ZeroCopy(z) => z.await_events(_duration),
}
}
}


Expand Down
9 changes: 0 additions & 9 deletions communication/src/allocator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

use std::rc::Rc;
use std::cell::RefCell;
use std::time::Duration;

pub use self::thread::Thread;
pub use self::process::Process;
Expand Down Expand Up @@ -57,14 +56,6 @@ pub trait Allocate {
/// into a performance problem.
fn events(&self) -> &Rc<RefCell<Vec<usize>>>;

/// Awaits communication events.
///
/// This method may park the current thread, for at most `duration`,
/// until new events arrive.
/// The method is not guaranteed to wait for any amount of time, but
/// good implementations should use this as a hint to park the thread.
fn await_events(&self, _duration: Option<Duration>) { }

/// Ensure that received messages are surfaced in each channel.
///
/// This method should be called to ensure that received messages are
Expand Down
5 changes: 0 additions & 5 deletions communication/src/allocator/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use std::rc::Rc;
use std::cell::RefCell;
use std::sync::{Arc, Mutex};
use std::any::Any;
use std::time::Duration;
use std::collections::{HashMap};
use crossbeam_channel::{Sender, Receiver};

Expand Down Expand Up @@ -178,10 +177,6 @@ impl Allocate for Process {
self.inner.events()
}

fn await_events(&self, duration: Option<Duration>) {
self.inner.await_events(duration);
}

fn receive(&mut self) {
let mut events = self.inner.events().borrow_mut();
while let Ok(index) = self.counters_recv.try_recv() {
Expand Down
11 changes: 0 additions & 11 deletions communication/src/allocator/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

use std::rc::Rc;
use std::cell::RefCell;
use std::time::Duration;
use std::collections::VecDeque;

use crate::allocator::{Allocate, AllocateBuilder};
Expand Down Expand Up @@ -36,16 +35,6 @@ impl Allocate for Thread {
fn events(&self) -> &Rc<RefCell<Vec<usize>>> {
&self.events
}
fn await_events(&self, duration: Option<Duration>) {
if self.events.borrow().is_empty() {
if let Some(duration) = duration {
std::thread::park_timeout(duration);
}
else {
std::thread::park();
}
}
}
}

/// Thread-local counting channel push endpoint.
Expand Down
3 changes: 0 additions & 3 deletions communication/src/allocator/zero_copy/allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,4 @@ impl<A: Allocate> Allocate for TcpAllocator<A> {
fn events(&self) -> &Rc<RefCell<Vec<usize>>> {
self.inner.events()
}
fn await_events(&self, duration: Option<std::time::Duration>) {
self.inner.await_events(duration);
}
}
10 changes: 0 additions & 10 deletions communication/src/allocator/zero_copy/allocator_process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,14 +240,4 @@ impl Allocate for ProcessAllocator {
fn events(&self) -> &Rc<RefCell<Vec<usize>>> {
&self.events
}
fn await_events(&self, duration: Option<std::time::Duration>) {
if self.events.borrow().is_empty() {
if let Some(duration) = duration {
std::thread::park_timeout(duration);
}
else {
std::thread::park();
}
}
}
}
10 changes: 5 additions & 5 deletions timely/examples/logging-send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ fn main() {
let mut probe = ProbeHandle::new();

// Register timely worker logging.
worker.log_register().insert::<TimelyEvent,_>("timely", |_time, data|
worker.log_register().unwrap().insert::<TimelyEvent,_>("timely", |_time, data|
data.iter().for_each(|x| println!("LOG1: {:?}", x))
);

// Register timely progress logging.
// Less generally useful: intended for debugging advanced custom operators or timely
// internals.
worker.log_register().insert::<TimelyProgressEvent,_>("timely/progress", |_time, data|
worker.log_register().unwrap().insert::<TimelyProgressEvent,_>("timely/progress", |_time, data|
data.iter().for_each(|x| {
println!("PROGRESS: {:?}", x);
let (_, _, ev) = x;
Expand All @@ -48,7 +48,7 @@ fn main() {
});

// Register timely worker logging.
worker.log_register().insert::<TimelyEvent,_>("timely", |_time, data|
worker.log_register().unwrap().insert::<TimelyEvent,_>("timely", |_time, data|
data.iter().for_each(|x| println!("LOG2: {:?}", x))
);

Expand All @@ -61,13 +61,13 @@ fn main() {
});

// Register user-level logging.
worker.log_register().insert::<(),_>("input", |_time, data|
worker.log_register().unwrap().insert::<(),_>("input", |_time, data|
for element in data.iter() {
println!("Round tick at: {:?}", element.0);
}
);

let input_logger = worker.log_register().get::<()>("input").expect("Input logger absent");
let input_logger = worker.log_register().unwrap().get::<()>("input").expect("Input logger absent");

let timer = std::time::Instant::now();

Expand Down
2 changes: 1 addition & 1 deletion timely/examples/threadless.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ fn main() {

// create a naked single-threaded worker.
let allocator = timely::communication::allocator::Thread::default();
let mut worker = timely::worker::Worker::new(WorkerConfig::default(), allocator);
let mut worker = timely::worker::Worker::new(WorkerConfig::default(), allocator, None);

// create input and probe handles.
let mut input = InputHandle::new();
Expand Down
2 changes: 1 addition & 1 deletion timely/src/dataflow/scopes/child.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ where
fn peek_identifier(&self) -> usize {
self.parent.peek_identifier()
}
fn log_register(&self) -> ::std::cell::RefMut<crate::logging_core::Registry<crate::logging::WorkerIdentifier>> {
fn log_register(&self) -> Option<::std::cell::RefMut<crate::logging_core::Registry<crate::logging::WorkerIdentifier>>> {
self.parent.log_register()
}
}
Expand Down
4 changes: 2 additions & 2 deletions timely/src/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ where
F: FnOnce(&mut Worker<crate::communication::allocator::thread::Thread>)->T+Send+Sync+'static
{
let alloc = crate::communication::allocator::thread::Thread::default();
let mut worker = crate::worker::Worker::new(WorkerConfig::default(), alloc);
let mut worker = crate::worker::Worker::new(WorkerConfig::default(), alloc, Some(std::time::Instant::now()));
let result = func(&mut worker);
while worker.has_dataflows() {
worker.step_or_park(None);
Expand Down Expand Up @@ -320,7 +320,7 @@ where
T: Send+'static,
F: Fn(&mut Worker<<A as AllocateBuilder>::Allocator>)->T+Send+Sync+'static {
initialize_from(builders, others, move |allocator| {
let mut worker = Worker::new(worker_config.clone(), allocator);
let mut worker = Worker::new(worker_config.clone(), allocator, Some(std::time::Instant::now()));
let result = func(&mut worker);
while worker.has_dataflows() {
worker.step_or_park(None);
Expand Down
10 changes: 7 additions & 3 deletions timely/src/progress/subgraph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,11 @@ where
let path = self.path.clone();
let reachability_logging =
worker.log_register()
.get::<reachability::logging::TrackerEvent>("timely/reachability")
.map(|logger| reachability::logging::TrackerLogger::new(path, logger));
.as_ref()
.and_then(|l|
l.get::<reachability::logging::TrackerEvent>("timely/reachability")
.map(|logger| reachability::logging::TrackerLogger::new(path, logger))
);
let (tracker, scope_summary) = builder.build(reachability_logging);

let progcaster = Progcaster::new(worker, self.path.clone(), self.logging.clone(), self.progress_logging.clone());
Expand Down Expand Up @@ -296,10 +299,11 @@ where
self.propagate_pointstamps();

{ // Enqueue active children; scoped to let borrow drop.
use crate::scheduling::activate::Scheduler;
let temp_active = &mut self.temp_active;
self.activations
.borrow_mut()
.for_extensions(&self.path[..], |index| temp_active.push(Reverse(index)));
.extensions(&self.path[..], temp_active);
}

// Schedule child operators.
Expand Down
Loading