From b2300782ad09f17730fe2a5ba4938517d4e7ec16 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Wed, 18 Oct 2023 13:30:41 +0200 Subject: [PATCH] fix: in `--trace` mode, greatly increase message-buffer size. That way, it's much less likely that messages will get lost due to being overwritten before they can be displayed every 100ms or so. --- src/plumbing/main.rs | 6 ++++-- src/shared.rs | 10 +++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/plumbing/main.rs b/src/plumbing/main.rs index 677ec60fe0c..d651e3d1cac 100644 --- a/src/plumbing/main.rs +++ b/src/plumbing/main.rs @@ -31,6 +31,7 @@ pub mod async_util { pub fn prepare( verbose: bool, + trace: bool, name: &str, range: impl Into>, ) -> ( @@ -41,7 +42,7 @@ pub mod async_util { shared::init_env_logger(); if verbose { - let progress = shared::progress_tree(); + let progress = shared::progress_tree(trace); let sub_progress = progress.add_child(name); let ui_handle = shared::setup_line_renderer_range(&progress, range.into().unwrap_or(STANDARD_RANGE)); (Some(ui_handle), Some(sub_progress).into()) @@ -416,6 +417,7 @@ pub fn main() -> Result<()> { { let (_handle, progress) = async_util::prepare( auto_verbose, + trace, "remote-refs", Some(core::repository::remote::refs::PROGRESS_RANGE), ); @@ -626,7 +628,7 @@ pub fn main() -> Result<()> { refs_directory, } => { let (_handle, progress) = - async_util::prepare(verbose, "pack-receive", core::pack::receive::PROGRESS_RANGE); + async_util::prepare(verbose, trace, "pack-receive", core::pack::receive::PROGRESS_RANGE); let fut = core::pack::receive( protocol, &url, diff --git a/src/shared.rs b/src/shared.rs index d0e9b362c02..ef0068ab4e5 100644 --- a/src/shared.rs +++ b/src/shared.rs @@ -20,9 +20,9 @@ pub fn init_env_logger() { } #[cfg(feature = "prodash-render-line")] -pub fn progress_tree() -> std::sync::Arc { +pub fn progress_tree(trace: bool) -> std::sync::Arc { prodash::tree::root::Options { - message_buffer_capacity: 200, + message_buffer_capacity: if trace { 10_000 } else { 200 }, ..Default::default() } .into() @@ -55,7 +55,7 @@ pub mod pretty { #[cfg(feature = "small")] pub fn prepare_and_run( name: &str, - _trace: bool, + trace: bool, verbose: bool, progress: bool, #[cfg_attr(not(feature = "prodash-render-tui"), allow(unused_variables))] progress_keep_open: bool, @@ -77,7 +77,7 @@ pub mod pretty { run(progress::DoOrDiscard::from(None), &mut stdout_lock, &mut stderr_lock) } (true, false) => { - let progress = crate::shared::progress_tree(); + let progress = crate::shared::progress_tree(trace); let sub_progress = progress.add_child(name); use crate::shared::{self, STANDARD_RANGE}; @@ -157,7 +157,7 @@ pub mod pretty { } (true, false) => { use crate::shared::{self, STANDARD_RANGE}; - let progress = shared::progress_tree(); + let progress = shared::progress_tree(trace); let sub_progress = progress.add_child(name); init_tracing(trace, false, &progress)?;