mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-11-29 14:25:45 +03:00
somewhat fix the ODB performance bottleneck with better caching.
This commit is contained in:
parent
a2382bde74
commit
66c747e611
@ -5,7 +5,7 @@ use core::fmt;
|
|||||||
use gitbutler_branch::{
|
use gitbutler_branch::{
|
||||||
Branch as GitButlerBranch, BranchId, BranchIdentity, ReferenceExtGix, Target,
|
Branch as GitButlerBranch, BranchId, BranchIdentity, ReferenceExtGix, Target,
|
||||||
};
|
};
|
||||||
use gitbutler_command_context::CommandContext;
|
use gitbutler_command_context::{CommandContext, GixRepositoryExt};
|
||||||
use gitbutler_reference::normalize_branch_name;
|
use gitbutler_reference::normalize_branch_name;
|
||||||
use gitbutler_serde::BStringForFrontend;
|
use gitbutler_serde::BStringForFrontend;
|
||||||
use gix::object::tree::diff::Action;
|
use gix::object::tree::diff::Action;
|
||||||
@ -427,8 +427,7 @@ pub fn get_branch_listing_details(
|
|||||||
.filter_map(Result::ok)
|
.filter_map(Result::ok)
|
||||||
.collect();
|
.collect();
|
||||||
let git2_repo = ctx.repository();
|
let git2_repo = ctx.repository();
|
||||||
let mut repo = ctx.gix_repository_minimal()?;
|
let repo = ctx.gix_repository_minimal()?.for_tree_diffing()?;
|
||||||
repo.object_cache_size_if_unset(4 * 1024);
|
|
||||||
let branches = list_branches(ctx, None, Some(branch_names))?;
|
let branches = list_branches(ctx, None, Some(branch_names))?;
|
||||||
|
|
||||||
let (default_target_current_upstream_commit_id, default_target_seen_at_last_update) = {
|
let (default_target_current_upstream_commit_id, default_target_seen_at_last_update) = {
|
||||||
|
@ -27,6 +27,6 @@ pub mod snapshot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn debug_print(this: impl std::fmt::Debug) -> anyhow::Result<()> {
|
fn debug_print(this: impl std::fmt::Debug) -> anyhow::Result<()> {
|
||||||
eprintln!("{:#?}", this);
|
println!("{:#?}", this);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -98,3 +98,19 @@ impl CommandContext {
|
|||||||
)?)
|
)?)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub trait GixRepositoryExt: Sized {
|
||||||
|
/// Configure the repository for diff operations between trees.
|
||||||
|
/// This means it needs an object cache relative to the amount of files in the repository.
|
||||||
|
fn for_tree_diffing(self) -> Result<Self>;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl GixRepositoryExt for gix::Repository {
|
||||||
|
fn for_tree_diffing(mut self) -> anyhow::Result<Self> {
|
||||||
|
let num_tracked = self.index_or_empty()?.entries().len();
|
||||||
|
let ten_mb_for_every_10k_files =
|
||||||
|
(num_tracked as f32 / 10_000.0) * (10 * 1024 * 1024) as f32;
|
||||||
|
self.object_cache_size_if_unset((ten_mb_for_every_10k_files as usize).max(4 * 1024));
|
||||||
|
Ok(self)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user