[taskbar] leave progress bar displayed at the end of the analysis

Summary:
The code was already trying to do that but failing. Now it works.

This revealed a slight bug where the progress bar would always stop at
N-1/N 99% jobs. Fixed by moving the progress bar updates *after* the
operation that might decrease the number of jobs left.

Reviewed By: mityal

Differential Revision: D17423978

fbshipit-source-id: fc32db5f3
master
Jules Villard 5 years ago committed by Facebook Github Bot
parent 85977bf327
commit a01639e098

@ -189,7 +189,7 @@ let main ~changed_files =
(* empty all caches to minimize the process heap to have less work to do when forking *)
clear_caches () ;
let stats = analyze source_files in
L.progress "@\nAnalysis phase finished in %a@." Mtime.Span.pp (Mtime_clock.count time0) ;
L.debug Analysis Quiet "collected stats:@\n%a@." BackendStats.pp stats ;
L.debug Analysis Quiet "Analysis phase finished in %a@\n" Mtime.Span.pp (Mtime_clock.count time0) ;
L.debug Analysis Quiet "Collected stats:@\n%a@." BackendStats.pp stats ;
BackendStats.log_to_scuba stats ;
output_json_makefile_stats source_files

@ -42,8 +42,8 @@ type ('work, 'final) t =
(** {2 Constants} *)
(** refresh rate of the task bar (worst case: it also refreshes on children updates)
this is now mandatory to allow checking for new work packets, when none were
(** refresh rate of the task bar (worst case: it also refreshes on children updates)
this is now mandatory to allow checking for new work packets, when none were
previously available *)
let refresh_timeout =
let frames_per_second = 12 in
@ -67,7 +67,7 @@ type worker_message =
(** [(i, t, status)]: starting a task from slot [i], at start time [t], with description
[status]. Watch out that [status] must not be too close in length to [buffer_size]. *)
| Ready of int
(** Sent after finishing initializing or after finishing a given task.
(** Sent after finishing initializing or after finishing a given task.
When received by master, this moves the worker state from [Initializing] or [Processing _] to [Idle]. *)
| Crash of int (** there was an error and the child is no longer receiving messages *)
@ -95,8 +95,8 @@ let rec really_read ?(pos = 0) ~len fd ~buf =
really_read ~pos:(pos + read) ~len:(len - read) fd ~buf
(** return a list of all updates coming from workers. The first update is expected for up to the
timeout [refresh_timeout]. After that, all already received updates are consumed but with zero timeout.
(** return a list of all updates coming from workers. The first update is expected for up to the
timeout [refresh_timeout]. After that, all already received updates are consumed but with zero timeout.
If there is none left, return the list. *)
let wait_for_updates pool buffer =
let rec aux acc ~timeout =
@ -221,8 +221,6 @@ let process_updates pool buffer =
Unix.wait (`Pid pid) |> ignore ;
killall pool ~slot "see backtrace above"
| Ready slot ->
TaskBar.set_remaining_tasks pool.task_bar (pool.tasks.remaining_tasks ()) ;
TaskBar.update_status pool.task_bar ~slot (Mtime_clock.now ()) "idle" ;
( match pool.children_states.(slot) with
| Processing work ->
pool.tasks.finished work
@ -230,6 +228,8 @@ let process_updates pool buffer =
()
| Idle ->
L.die InternalError "Received a Ready message from an idle worker@." ) ;
TaskBar.set_remaining_tasks pool.task_bar (pool.tasks.remaining_tasks ()) ;
TaskBar.update_status pool.task_bar ~slot (Mtime_clock.now ()) "idle" ;
pool.children_states.(slot) <- Idle ) ;
(* try to schedule more work if there are idle workers *)
if not (pool.tasks.is_empty ()) then

@ -45,6 +45,8 @@ let rec pp_n c fmt n =
let move_bol = "\r"
let move_cursor_down n = Printf.sprintf "\027[%iB" n
let move_cursor_up n = Printf.sprintf "\027[%iA" n
let erase_eol = "\027[0K"
@ -185,9 +187,10 @@ let tasks_done_reset task_bar =
let finish = function
| MultiLine _ ->
| MultiLine _ as task_bar ->
refresh task_bar ;
(* leave the progress bar displayed *)
Out_channel.output_string stderr "\n" ;
F.eprintf "%s%!" (move_cursor_down 1) ;
ANSITerminal.erase Below ;
Out_channel.flush stderr
| NonInteractive | Quiet ->

Loading…
Cancel
Save