Skip to content

Commit

Permalink
fix: in --trace mode, greatly increase message-buffer size.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Byron committed Oct 18, 2023
1 parent 16170d9 commit b230078
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
6 changes: 4 additions & 2 deletions src/plumbing/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pub mod async_util {

pub fn prepare(
verbose: bool,
trace: bool,
name: &str,
range: impl Into<Option<ProgressRange>>,
) -> (
Expand All @@ -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())
Expand Down Expand Up @@ -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),
);
Expand Down Expand Up @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions src/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ pub fn init_env_logger() {
}

#[cfg(feature = "prodash-render-line")]
pub fn progress_tree() -> std::sync::Arc<prodash::tree::Root> {
pub fn progress_tree(trace: bool) -> std::sync::Arc<prodash::tree::Root> {
prodash::tree::root::Options {
message_buffer_capacity: 200,
message_buffer_capacity: if trace { 10_000 } else { 200 },
..Default::default()
}
.into()
Expand Down Expand Up @@ -55,7 +55,7 @@ pub mod pretty {
#[cfg(feature = "small")]
pub fn prepare_and_run<T>(
name: &str,
_trace: bool,
trace: bool,
verbose: bool,
progress: bool,
#[cfg_attr(not(feature = "prodash-render-tui"), allow(unused_variables))] progress_keep_open: bool,
Expand All @@ -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};
Expand Down Expand Up @@ -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)?;

Expand Down

0 comments on commit b230078

Please sign in to comment.