@@ -8,16 +8,15 @@ use crate::logging::TimelyLogger as Logger;
88use crate :: logging:: TimelyProgressLogger as ProgressLogger ;
99use crate :: Bincode ;
1010
11- /// A list of progress updates corresponding to `((child_scope, [in/out]_port, timestamp), delta)`
12- pub type ProgressVec < T > = Vec < ( ( Location , T ) , i64 ) > ;
1311/// A progress update message consisting of source worker id, sequence number and lists of
1412/// message and internal updates
15- pub type ProgressMsg < T > = Bincode < ( usize , usize , ProgressVec < T > ) > ;
13+ pub type ProgressMsg < T > = Bincode < ( usize , usize , ChangeBatch < ( Location , T ) > ) > ;
1614
1715/// Manages broadcasting of progress updates to and receiving updates from workers.
1816pub struct Progcaster < T : Timestamp > {
19- to_push : Option < ProgressMsg < T > > ,
20- pushers : Vec < Box < dyn Push < ProgressMsg < T > > > > ,
17+ /// Pusher into which we send progress updates.
18+ pusher : Box < dyn Push < ProgressMsg < T > > > ,
19+ /// Puller from which we recv progress updates.
2120 puller : Box < dyn Pull < ProgressMsg < T > > > ,
2221 /// Source worker index
2322 source : usize ,
@@ -27,7 +26,7 @@ pub struct Progcaster<T:Timestamp> {
2726 identifier : usize ,
2827 /// Communication channel identifier
2928 channel_identifier : usize ,
30-
29+ /// An optional logger to record progress messages.
3130 progress_logging : Option < ProgressLogger < T > > ,
3231}
3332
@@ -36,15 +35,14 @@ impl<T:Timestamp+Send> Progcaster<T> {
3635 pub fn new < A : crate :: worker:: AsWorker > ( worker : & mut A , addr : Rc < [ usize ] > , identifier : usize , mut logging : Option < Logger > , progress_logging : Option < ProgressLogger < T > > ) -> Progcaster < T > {
3736
3837 let channel_identifier = worker. new_identifier ( ) ;
39- let ( pushers , puller) = worker. allocate ( channel_identifier, addr) ;
38+ let ( pusher , puller) = worker. broadcast ( channel_identifier, addr) ;
4039 logging. as_mut ( ) . map ( |l| l. log ( crate :: logging:: CommChannelsEvent {
4140 identifier : channel_identifier,
4241 kind : crate :: logging:: CommChannelKind :: Progress ,
4342 } ) ) ;
4443 let worker_index = worker. index ( ) ;
4544 Progcaster {
46- to_push : None ,
47- pushers,
45+ pusher,
4846 puller,
4947 source : worker_index,
5048 counter : 0 ,
@@ -90,31 +88,17 @@ impl<T:Timestamp+Send> Progcaster<T> {
9088 } ) ;
9189 } ) ;
9290
93- for pusher in self . pushers . iter_mut ( ) {
94-
95- // Attempt to reuse allocations, if possible.
96- if let Some ( tuple) = & mut self . to_push {
97- tuple. payload . 0 = self . source ;
98- tuple. payload . 1 = self . counter ;
99- tuple. payload . 2 . clear ( ) ;
100- tuple. payload . 2 . extend ( changes. iter ( ) . cloned ( ) ) ;
101- }
102- // If we don't have an allocation ...
103- if self . to_push . is_none ( ) {
104- self . to_push = Some ( Bincode :: from ( (
105- self . source ,
106- self . counter ,
107- changes. clone ( ) . into_inner ( ) . into_vec ( ) ,
108- ) ) ) ;
109- }
91+ let payload = ( self . source , self . counter , std:: mem:: take ( changes) ) ;
92+ let mut to_push = Some ( Bincode { payload } ) ;
93+ self . pusher . push ( & mut to_push) ;
94+ self . pusher . done ( ) ;
11095
111- // TODO: This should probably use a broadcast channel.
112- pusher . push ( & mut self . to_push ) ;
113- pusher . done ( ) ;
96+ if let Some ( pushed ) = to_push {
97+ * changes = pushed . payload . 2 ;
98+ changes . clear ( ) ;
11499 }
115100
116101 self . counter += 1 ;
117- changes. clear ( ) ;
118102 }
119103 }
120104
@@ -125,7 +109,7 @@ impl<T:Timestamp+Send> Progcaster<T> {
125109
126110 let source = message. 0 ;
127111 let counter = message. 1 ;
128- let recv_changes = & message. 2 ;
112+ let recv_changes = & mut message. 2 ;
129113
130114 let channel = self . channel_identifier ;
131115
0 commit comments