diff --git a/src/runtime/communication.rs b/src/runtime/communication.rs index 921d409c7b68d2e5b83d5bae2c3a4b2675a06a45..8c71e3c3b8e83d32f2d7fc35058766d520740164 100644 --- a/src/runtime/communication.rs +++ b/src/runtime/communication.rs @@ -231,8 +231,7 @@ impl Connector { .proto_components .keys() .map(|&id| Route::LocalComponent(LocalComponentId::Proto(id))); - let e = (0..endpoint_manager.endpoint_exts.len()) - .map(|index| Route::Endpoint { index }); + let e = neighborhood.children.iter().map(|&index| Route::Endpoint { index }); SolutionStorage::new(n.chain(c).chain(e)) }; log!(logger, "Solution storage initialized"); @@ -271,11 +270,16 @@ impl Connector { payloads_to_get.push((getter, msg)); } if to_get.is_empty() { - log!(logger, "Native submitting trivial solution for index {}", index); + log!( + logger, + "Native submitting solution for batch {} with {:?}", + index, + &predicate + ); solution_storage.submit_and_digest_subtree_solution( logger, Route::LocalComponent(LocalComponentId::Native), - Predicate::default(), + predicate.clone(), ); } let branch = NativeBranch { index, gotten: Default::default(), to_get }; @@ -614,8 +618,8 @@ impl BranchingNative { getter: PortId, send_payload_msg: SendPayloadMsg, ) { + log!(logger, "feeding native getter {:?} {:?}", getter, &send_payload_msg); assert!(port_info.polarities.get(&getter).copied() == Some(Getter)); - println!("BEFORE {:#?}", &self.branches); let mut draining = HashMap::default(); let finished = &mut self.branches; std::mem::swap(&mut draining, finished); @@ -637,40 +641,59 @@ impl BranchingNative { }; if predicate.query(var) != Some(true) { // optimization. Don't bother trying this branch + log!( + logger, + "skipping branch with {:?} that doesn't want the message (fastpath)", + &predicate + ); finished.insert(predicate, branch); continue; } use CommonSatResult as Csr; match predicate.common_satisfier(&send_payload_msg.predicate) { + Csr::Nonexistant => { + // this branch does not receive the message + log!( + logger, + "skipping branch with {:?} that doesn't want the message (slowpath)", + &predicate + ); + finished.insert(predicate, branch); + } Csr::Equivalent | Csr::FormerNotLatter => { // retain the existing predicate, but add this payload feed_branch(&mut branch, &predicate); - finished.insert(predicate, branch); - } - Csr::Nonexistant => { - // this branch does not receive the message + log!(logger, "branch pred covers it! Accept the msg"); finished.insert(predicate, branch); } Csr::LatterNotFormer => { - // fork branch, give fork the message and payload predicate + // fork branch, give fork the message and payload predicate. original branch untouched let mut branch2 = branch.clone(); - // original branch untouched - finished.insert(predicate, branch); let predicate2 = send_payload_msg.predicate.clone(); feed_branch(&mut branch2, &predicate2); + log!( + logger, + "payload pred {:?} covers branch pred {:?}", + &predicate2, + &predicate + ); + finished.insert(predicate, branch); finished.insert(predicate2, branch2); } - Csr::New(new_predicate) => { - // fork branch, give fork the message and the new predicate + Csr::New(predicate2) => { + // fork branch, give fork the message and the new predicate. original branch untouched let mut branch2 = branch.clone(); - // original branch untouched + feed_branch(&mut branch2, &predicate2); + log!( + logger, + "new subsuming pred created {:?}. forking and feeding", + &predicate2 + ); finished.insert(predicate, branch); - feed_branch(&mut branch2, &new_predicate); - finished.insert(new_predicate, branch2); + finished.insert(predicate2, branch2); } } } - println!("AFTER {:#?}", &self.branches); } fn collapse_with(self, solution_predicate: &Predicate) -> (usize, HashMap) { for (branch_predicate, branch) in self.branches { diff --git a/src/runtime/mod.rs b/src/runtime/mod.rs index 8dc24e0df55132b0837ee6875636092ed507b449..5c605e16603e8a90263735197d5beb1a6263d255 100644 --- a/src/runtime/mod.rs +++ b/src/runtime/mod.rs @@ -3,7 +3,7 @@ pub mod error; mod setup2; #[cfg(test)] -mod my_tests; +mod tests; use crate::common::*; use error::*; @@ -352,6 +352,14 @@ impl StringLogger { Self(controller_id, String::default()) } } +impl Drop for StringLogger { + fn drop(&mut self) { + let stdout = std::io::stdout(); + let mut lock = stdout.lock(); + writeln!(lock, "--- DROP LOG DUMP ---").unwrap(); + self.dump_log(&mut lock); + } +} impl Logger for StringLogger { fn line_writer(&mut self) -> &mut dyn std::fmt::Write { use std::fmt::Write; diff --git a/src/runtime/setup2.rs b/src/runtime/setup2.rs index ffd21c018fa730bc7d9d1c5c2657baa7aaf14d6c..3721383b660b9ca11709b752e6f57a2ac8f86f41 100644 --- a/src/runtime/setup2.rs +++ b/src/runtime/setup2.rs @@ -45,7 +45,13 @@ impl Connector { // {polarity, route} known. {peer} unknown. self.port_info.polarities.insert(p, polarity); self.port_info.routes.insert(p, Route::LocalComponent(LocalComponentId::Native)); - log!(self.logger, "Added net port {:?} with info {:?} ", p, &endpoint_setup); + log!( + self.logger, + "Added net port {:?} with polarity {:?} and endpoint setup {:?} ", + p, + polarity, + &endpoint_setup + ); endpoint_setups.push((p, endpoint_setup)); Ok(p) } diff --git a/src/runtime/my_tests.rs b/src/runtime/tests.rs similarity index 99% rename from src/runtime/my_tests.rs rename to src/runtime/tests.rs index a92311027a731553ac2862b56360e52c47cb2c9d..1caa7f2477df097bd555ac26c988250c29c98d8b 100644 --- a/src/runtime/my_tests.rs +++ b/src/runtime/tests.rs @@ -198,6 +198,7 @@ fn native_message_pass() { c.connect(Duration::from_secs(1)).unwrap(); c.get(g).unwrap(); c.sync(Duration::from_secs(1)).unwrap(); + c.gotten(g).unwrap(); }); s.spawn(|_| { let mut c = Connector::new_simple(MINIMAL_PROTO.clone(), 1);