@@ -267,7 +267,12 @@ impl<'gctx> Timings<'gctx> {
267267 }
268268
269269 /// Mark that the `.rmeta` file as generated.
270- pub fn unit_rmeta_finished ( & mut self , id : JobId , unblocked : Vec < & Unit > ) {
270+ pub fn unit_rmeta_finished (
271+ & mut self ,
272+ build_runner : & BuildRunner < ' _ , ' _ > ,
273+ id : JobId ,
274+ unblocked : Vec < & Unit > ,
275+ ) {
271276 if !self . enabled {
272277 return ;
273278 }
@@ -277,12 +282,21 @@ impl<'gctx> Timings<'gctx> {
277282 let Some ( unit_time) = self . active . get_mut ( & id) else {
278283 return ;
279284 } ;
280- let t = self . start . elapsed ( ) . as_secs_f64 ( ) ;
281- unit_time. rmeta_time = Some ( t - unit_time. start ) ;
285+ let elapsed = self . start . elapsed ( ) . as_secs_f64 ( ) ;
286+ unit_time. rmeta_time = Some ( elapsed - unit_time. start ) ;
282287 assert ! ( unit_time. unblocked_rmeta_units. is_empty( ) ) ;
283288 unit_time
284289 . unblocked_rmeta_units
285290 . extend ( unblocked. iter ( ) . cloned ( ) . cloned ( ) ) ;
291+
292+ if let Some ( logger) = build_runner. bcx . logger {
293+ let unblocked = unblocked. iter ( ) . map ( |u| self . unit_to_index [ u] ) . collect ( ) ;
294+ logger. log ( LogMessage :: UnitRmetaFinished {
295+ index : self . unit_to_index [ & unit_time. unit ] ,
296+ elapsed,
297+ unblocked,
298+ } ) ;
299+ }
286300 }
287301
288302 /// Mark that a unit has finished running.
@@ -299,8 +313,8 @@ impl<'gctx> Timings<'gctx> {
299313 let Some ( mut unit_time) = self . active . remove ( & id) else {
300314 return ;
301315 } ;
302- let t = self . start . elapsed ( ) . as_secs_f64 ( ) ;
303- unit_time. duration = t - unit_time. start ;
316+ let elapsed = self . start . elapsed ( ) . as_secs_f64 ( ) ;
317+ unit_time. duration = elapsed - unit_time. start ;
304318 assert ! ( unit_time. unblocked_units. is_empty( ) ) ;
305319 unit_time
306320 . unblocked_units
@@ -321,33 +335,53 @@ impl<'gctx> Timings<'gctx> {
321335 let unblocked = unblocked. iter ( ) . map ( |u| self . unit_to_index [ u] ) . collect ( ) ;
322336 logger. log ( LogMessage :: UnitFinished {
323337 index : self . unit_to_index [ & unit_time. unit ] ,
324- duration : unit_time. duration ,
325- rmeta_time : unit_time. rmeta_time ,
326- sections : unit_time. sections . clone ( ) . into_iter ( ) . collect ( ) ,
338+ elapsed,
327339 unblocked,
328340 } ) ;
329341 }
330342 self . unit_times . push ( unit_time) ;
331343 }
332344
333345 /// Handle the start/end of a compilation section.
334- pub fn unit_section_timing ( & mut self , id : JobId , section_timing : & SectionTiming ) {
346+ pub fn unit_section_timing (
347+ & mut self ,
348+ build_runner : & BuildRunner < ' _ , ' _ > ,
349+ id : JobId ,
350+ section_timing : & SectionTiming ,
351+ ) {
335352 if !self . enabled {
336353 return ;
337354 }
338355 let Some ( unit_time) = self . active . get_mut ( & id) else {
339356 return ;
340357 } ;
341- let now = self . start . elapsed ( ) . as_secs_f64 ( ) ;
358+ let elapsed = self . start . elapsed ( ) . as_secs_f64 ( ) ;
342359
343360 match section_timing. event {
344361 SectionTimingEvent :: Start => {
345- unit_time. start_section ( & section_timing. name , now ) ;
362+ unit_time. start_section ( & section_timing. name , elapsed ) ;
346363 }
347364 SectionTimingEvent :: End => {
348- unit_time. end_section ( & section_timing. name , now ) ;
365+ unit_time. end_section ( & section_timing. name , elapsed ) ;
349366 }
350367 }
368+
369+ if let Some ( logger) = build_runner. bcx . logger {
370+ let index = self . unit_to_index [ & unit_time. unit ] ;
371+ let section = section_timing. name . clone ( ) ;
372+ logger. log ( match section_timing. event {
373+ SectionTimingEvent :: Start => LogMessage :: UnitSectionStarted {
374+ index,
375+ elapsed,
376+ section,
377+ } ,
378+ SectionTimingEvent :: End => LogMessage :: UnitSectionFinished {
379+ index,
380+ elapsed,
381+ section,
382+ } ,
383+ } )
384+ }
351385 }
352386
353387 /// This is called periodically to mark the concurrency of internal structures.
0 commit comments