Changeset - 43f31542f6db
[Not reviewed]
0 3 0
Christopher Esterhuyse - 5 years ago 2020-02-04 16:08:29
christopheresterhuyse@gmail.com
more debug prints on branch predicates
3 files changed with 32 insertions and 34 deletions:
0 comments (0 inline, 0 general)
src/runtime/actors.rs
Show inline comments
 
@@ -31,6 +31,7 @@ pub(crate) struct PolyP {
 
}
 
#[derive(Debug, Clone)]
 
pub(crate) struct BranchP {
 
    pub outbox: HashMap<Key, Payload>,
 
    pub inbox: HashMap<Key, Payload>,
 
    pub state: ProtocolS,
 
}
 
@@ -114,7 +115,18 @@ impl PolyP {
 
                    );
 

	
 
                    // OK now check we really received all the messages we expected to
 
                    if predicate.iter_true().count() == branch.inbox.keys().map(lookup).count() {
 
                    let num_fired = predicate.iter_matching(true).count();
 
                    let num_msgs =
 
                        branch.inbox.keys().chain(branch.outbox.keys()).map(lookup).count();
 
                    match num_fired.cmp(&num_msgs) {
 
                        Ordering::Less => unreachable!(),
 
                        Ordering::Greater => lockprintln!(
 
                            "{:?}: {:?} with pred {:?} finished but |inbox|+|outbox| < .",
 
                            cid,
 
                            m_ctx.my_subtree_id,
 
                            &predicate,
 
                        ),
 
                        Ordering::Equal => {
 
                            lockprintln!(
 
                                "{:?}: {:?} with pred {:?} finished! Storing this solution locally.",
 
                                cid,
 
@@ -127,13 +139,7 @@ impl PolyP {
 
                            );
 
                            // store the solution for recovering later
 
                            self.complete.insert(predicate, branch);
 
                    } else {
 
                        lockprintln!(
 
                            "{:?}: {:?} with pred {:?} finished but was missing a GET. Pruning.",
 
                            cid,
 
                            m_ctx.my_subtree_id,
 
                            &predicate,
 
                        );
 
                        }
 
                    }
 
                }
 
                Sb::PutMsg(ekey, payload) => {
 
@@ -141,6 +147,7 @@ impl PolyP {
 
                    let EndpointExt { info, endpoint } =
 
                        m_ctx.inner.endpoint_exts.get_mut(ekey).unwrap();
 
                    if predicate.replace_assignment(info.channel_id, true) != Some(false) {
 
                        branch.outbox.insert(ekey, payload.clone());
 
                        let msg = CommMsgContents::SendPayload {
 
                            payload_predicate: predicate.clone(),
 
                            payload,
 
@@ -276,12 +283,12 @@ impl PolyP {
 
    pub(crate) fn become_mono(
 
        mut self,
 
        decision: &Predicate,
 
        all_inboxes: &mut HashMap<Key, Payload>,
 
        table_row: &mut HashMap<Key, Payload>,
 
    ) -> MonoP {
 
        if let Some((_, branch)) = self.complete.drain().find(|(p, _)| decision.satisfies(p)) {
 
            let BranchP { inbox, state } = branch;
 
            for (key, payload) in inbox {
 
                assert!(all_inboxes.insert(key, payload).is_none());
 
            let BranchP { inbox, state, outbox } = branch;
 
            for (key, payload) in inbox.into_iter().chain(outbox.into_iter()) {
 
                table_row.insert(key, payload);
 
            }
 
            self.incomplete.clear();
 
            MonoP { state, ekeys: self.ekeys }
 
@@ -312,12 +319,12 @@ impl PolyN {
 
    pub fn become_mono(
 
        mut self,
 
        decision: &Predicate,
 
        all_inboxes: &mut HashMap<Key, Payload>,
 
        table_row: &mut HashMap<Key, Payload>,
 
    ) -> MonoN {
 
        if let Some((_, branch)) = self.branches.drain().find(|(p, _)| decision.satisfies(p)) {
 
            let BranchN { gotten, sync_batch_index, .. } = branch;
 
            for (&key, payload) in gotten.iter() {
 
                assert!(all_inboxes.insert(key, payload.clone()).is_none());
 
                assert!(table_row.insert(key, payload.clone()).is_none());
 
            }
 
            MonoN { ekeys: self.ekeys, result: Some((sync_batch_index, gotten)) }
 
        } else {
src/runtime/communication.rs
Show inline comments
 
@@ -6,30 +6,21 @@ impl Controller {
 
        let cid = self.inner.channel_id_stream.controller_id;
 
        lockprintln!("{:?}: ENDING ROUND WITH DECISION! {:?}", cid, &decision);
 

	
 
        let mut all_inboxes = HashMap::default();
 
        let mut table_row = HashMap::default();
 
        self.inner.mono_n = self
 
            .ephemeral
 
            .poly_n
 
            .take()
 
            .map(|poly_n| poly_n.become_mono(&decision, &mut all_inboxes));
 
            .map(|poly_n| poly_n.become_mono(&decision, &mut table_row));
 
        self.inner.mono_ps.extend(
 
            self.ephemeral.poly_ps.drain(..).map(|m| m.become_mono(&decision, &mut all_inboxes)),
 
            self.ephemeral.poly_ps.drain(..).map(|m| m.become_mono(&decision, &mut table_row)),
 
        );
 
        let valuations: HashMap<_, _> = all_inboxes
 
            .drain()
 
            .map(|(ekey, payload)| {
 
        for (ekey, payload) in table_row {
 
            let channel_id = self.inner.endpoint_exts.get(ekey).unwrap().info.channel_id;
 
                (channel_id, Some(payload))
 
            })
 
            .collect();
 
        for (channel_id, value) in decision.assigned.iter() {
 
            if !value {
 
                lockprintln!("{:?}: VALUE {:?} => *", cid, channel_id);
 
            } else if let Some(payload) = valuations.get(channel_id) {
 
            lockprintln!("{:?}: VALUE {:?} => Message({:?})", cid, channel_id, payload);
 
            } else {
 
                lockprintln!("{:?}: VALUE {:?} => Message(?)", cid, channel_id);
 
        }
 
        for channel_id in decision.iter_matching(false) {
 
            lockprintln!("{:?}: VALUE {:?} => *", cid, channel_id);
 
        }
 
        let announcement =
 
            CommMsgContents::Announce { oracle: decision }.into_msg(self.inner.round_index);
 
@@ -446,6 +437,7 @@ impl Into<PolyP> for MonoP {
 
                BranchP {
 
                    state: self.state,
 
                    inbox: Default::default(),
 
                    outbox: Default::default(),
 
                }
 
            },
 
            ekeys: self.ekeys,
src/runtime/mod.rs
Show inline comments
 
@@ -406,11 +406,10 @@ impl Predicate {
 
        }
 
    }
 

	
 
    pub fn iter_true(&self) -> impl Iterator<Item = ChannelId> + '_ {
 
        self.assigned.iter().filter_map(|(&channel_id, b)| match b {
 
            true => Some(channel_id),
 
            false => None,
 
        })
 
    pub fn iter_matching(&self, value: bool) -> impl Iterator<Item = ChannelId> + '_ {
 
        self.assigned
 
            .iter()
 
            .filter_map(move |(&channel_id, &b)| if b == value { Some(channel_id) } else { None })
 
    }
 

	
 
    pub fn batch_assign_nones(
0 comments (0 inline, 0 general)