diff --git a/src/runtime2/consensus.rs b/src/runtime2/consensus.rs index c3a2947ea86c1ed9c9e458826ca585c236ca9d1d..e30edb59f646a07f21511afe1de906d17b9358ee 100644 --- a/src/runtime2/consensus.rs +++ b/src/runtime2/consensus.rs @@ -458,8 +458,6 @@ impl Consensus { } fn send_or_store_local_solution(&mut self, solution: LocalSolution, ctx: &mut ComponentCtx) -> Option { - println!("DEBUG [....:.. conn:{:02}]: Storing local solution for component {}, branch {}", ctx.id.0, solution.component.0, solution.final_branch_id.index); - if self.highest_connector_id == ctx.id { // We are the leader if let Some(global_solution) = self.solution_combiner.add_solution_and_check_for_global_solution(solution) { diff --git a/src/runtime2/mod.rs b/src/runtime2/mod.rs index 407fda0c76334eef9db7b1877ea42873d4b00045..3cf1ba4de30ac97d92be9c0353934cb417c6972e 100644 --- a/src/runtime2/mod.rs +++ b/src/runtime2/mod.rs @@ -306,13 +306,11 @@ impl RuntimeInner { #[inline] pub(crate) fn increment_active_interfaces(&self) { let _old_num = self.active_interfaces.fetch_add(1, Ordering::SeqCst); - println!("DEBUG: Incremented active interfaces to {}", _old_num + 1); debug_assert_ne!(_old_num, 0); // once it hits 0, it stays zero } pub(crate) fn decrement_active_interfaces(&self) { let old_num = self.active_interfaces.fetch_sub(1, Ordering::SeqCst); - println!("DEBUG: Decremented active interfaces to {}", old_num - 1); debug_assert!(old_num > 0); if old_num == 1 { // such that active interfaces is now 0 let num_connectors = self.active_connectors.load(Ordering::Acquire); @@ -325,12 +323,10 @@ impl RuntimeInner { #[inline] fn increment_active_components(&self) { let _old_num = self.active_connectors.fetch_add(1, Ordering::SeqCst); - println!("DEBUG: Incremented components to {}", _old_num + 1); } fn decrement_active_components(&self) { let old_num = self.active_connectors.fetch_sub(1, Ordering::SeqCst); - println!("DEBUG: Decremented components to {}", old_num - 1); debug_assert!(old_num > 0); if old_num == 1 { // such that we have no more active connectors (for now!) let num_interfaces = self.active_interfaces.load(Ordering::Acquire); @@ -345,14 +341,12 @@ impl RuntimeInner { debug_assert_eq!(self.active_interfaces.load(Ordering::Acquire), 0); debug_assert_eq!(self.active_connectors.load(Ordering::Acquire), 0); - println!("DEBUG: Signaling for shutdown"); let _lock = self.connector_queue.lock().unwrap(); let should_signal = self.should_exit .compare_exchange(false, true, Ordering::SeqCst, Ordering::Acquire) .is_ok(); if should_signal { - println!("DEBUG: Notifying all waiting schedulers"); self.scheduler_notifier.notify_all(); } } diff --git a/src/runtime2/native.rs b/src/runtime2/native.rs index daeeff3c14f8cef0346939cb005260948010bd11..73ac568570c9bbfd328c4b774335232f1de83c09 100644 --- a/src/runtime2/native.rs +++ b/src/runtime2/native.rs @@ -69,12 +69,10 @@ impl Connector for ConnectorApplication { while let Some(job) = queue.pop_front() { match job { ApplicationJob::NewChannel((endpoint_a, endpoint_b)) => { - println!("DEBUG: API adopting ports"); comp_ctx.push_port(endpoint_a); comp_ctx.push_port(endpoint_b); } ApplicationJob::NewConnector(connector, initial_ports) => { - println!("DEBUG: API creating connector"); comp_ctx.push_component(connector, initial_ports); }, ApplicationJob::Shutdown => { @@ -196,11 +194,8 @@ impl ApplicationInterface { .is_ok(); if should_wake_up { - println!("DEBUG: Waking up connector"); let key = unsafe{ ConnectorKey::from_id(self.connector_id) }; self.runtime.push_work(key); - } else { - println!("DEBUG: NOT waking up connector"); } } } diff --git a/src/runtime2/port.rs b/src/runtime2/port.rs index 9e51424b942b6f488136f6151409a8c75cb426fb..428bc23ed5f86e69b08156121aa4b44a37f58c65 100644 --- a/src/runtime2/port.rs +++ b/src/runtime2/port.rs @@ -58,8 +58,6 @@ pub struct Port { pub peer_connector: ConnectorId, // might be temporarily inconsistent while peer port is sent around in non-sync phase } - - // TODO: Turn port ID into its own type pub struct Channel { pub putter_id: PortIdLocal, // can put on it, so from the connector's point of view, this is an output diff --git a/src/runtime2/scheduler.rs b/src/runtime2/scheduler.rs index 2a7873e8371a94bc7fc194b93f75d5cdeee02729..f54d36201d575e58d5f2d89c450ca272f575d4b7 100644 --- a/src/runtime2/scheduler.rs +++ b/src/runtime2/scheduler.rs @@ -347,11 +347,11 @@ impl Scheduler { // TODO: Remove, this is debugging stuff fn debug(&self, message: &str) { - println!("DEBUG [thrd:{:02} conn: ]: {}", self.scheduler_id, message); + // println!("DEBUG [thrd:{:02} conn: ]: {}", self.scheduler_id, message); } fn debug_conn(&self, conn: ConnectorId, message: &str) { - println!("DEBUG [thrd:{:02} conn:{:02}]: {}", self.scheduler_id, conn.0, message); + // println!("DEBUG [thrd:{:02} conn:{:02}]: {}", self.scheduler_id, conn.0, message); } } diff --git a/src/runtime2/tests/mod.rs b/src/runtime2/tests/mod.rs index eec0105e5de7429babadd59ae496d33561481aa1..e2b407475b6e1520689575c2bd93c2ef14b82b44 100644 --- a/src/runtime2/tests/mod.rs +++ b/src/runtime2/tests/mod.rs @@ -3,9 +3,9 @@ use crate::{PortId, ProtocolDescription}; use crate::common::Id; use crate::protocol::eval::*; -const NUM_THREADS: u32 = 10; // number of threads in runtime -const NUM_INSTANCES: u32 = 10; // number of test instances constructed -const NUM_LOOPS: u32 = 10; // number of loops within a single test (not used by all tests) +const NUM_THREADS: u32 = 1; // number of threads in runtime +const NUM_INSTANCES: u32 = 4; // number of test instances constructed +const NUM_LOOPS: u32 = 4; // number of loops within a single test (not used by all tests) fn create_runtime(pdl: &str) -> Runtime { let protocol = ProtocolDescription::parse(pdl.as_bytes()).expect("parse pdl"); @@ -27,6 +27,27 @@ fn run_test_in_runtime(pdl: &str, constructor: // Wait until done :) } +struct TestTimer { + name: &'static str, + started: std::time::Instant +} + +impl TestTimer { + fn new(name: &'static str) -> Self { + Self{ name, started: std::time::Instant::now() } + } +} + +impl Drop for TestTimer { + fn drop(&mut self) { + let delta = std::time::Instant::now() - self.started; + let nanos = (delta.as_secs_f64() * 1_000_000.0) as u64; + let millis = nanos / 1000; + let nanos = nanos % 1000; + println!("[{}] Took {:>4}.{:03} ms", self.name, millis, nanos); + } +} + #[test] fn test_put_and_get() { const CODE: &'static str = " @@ -34,7 +55,6 @@ fn test_put_and_get() { u32 index = 0; while (index < loops) { synchronous { - print(\"putting!\"); put(sender, true); } index += 1; @@ -45,7 +65,6 @@ fn test_put_and_get() { u32 index = 0; while (index < loops) { synchronous { - print(\"getting!\"); auto result = get(receiver); assert(result); } @@ -54,6 +73,7 @@ fn test_put_and_get() { } "; + let thing = TestTimer::new("hello"); run_test_in_runtime(CODE, |api| { let channel = api.create_channel();