Fix slowness in big repo revlog tab (#1849)

This commit is contained in:
extrawurst 2023-08-28 12:35:01 +02:00 committed by GitHub
parent 8c177151d1
commit 0376ed3a26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 6 additions and 239 deletions

190
Cargo.lock generated
View File

@ -17,18 +17,6 @@ version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
[[package]]
name = "ahash"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f"
dependencies = [
"cfg-if",
"getrandom",
"once_cell",
"version_check",
]
[[package]]
name = "aho-corasick"
version = "1.0.2"
@ -59,12 +47,6 @@ version = "1.0.75"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6"
[[package]]
name = "arrayvec"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711"
[[package]]
name = "asyncgit"
version = "0.24.0"
@ -173,12 +155,6 @@ dependencies = [
"unicode-width",
]
[[package]]
name = "bytemuck"
version = "1.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c041d3eab048880cb0b86b256447da3f18859a163c3b8d8893f4e6368abe6393"
[[package]]
name = "bytesize"
version = "1.3.0"
@ -263,15 +239,6 @@ version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc"
[[package]]
name = "cpp_demangle"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee34052ee3d93d6d8f3e6f81d85c47921f6653a19a7b70e939e3e602d893a674"
dependencies = [
"cfg-if",
]
[[package]]
name = "crc32fast"
version = "1.3.2"
@ -407,15 +374,6 @@ dependencies = [
"parking_lot_core",
]
[[package]]
name = "debugid"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef552e6f588e446098f6ba40d89ac146c8c7b64aade83c051ee00bb5d2bc18d"
dependencies = [
"uuid",
]
[[package]]
name = "diff"
version = "0.1.13"
@ -528,18 +486,6 @@ dependencies = [
"thiserror",
]
[[package]]
name = "findshlibs"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "40b9e59cd0f7e0806cca4be089683ecb6434e602038df21fe6bf6711b2f07f64"
dependencies = [
"cc",
"lazy_static",
"libc",
"winapi",
]
[[package]]
name = "flate2"
version = "1.0.25"
@ -750,7 +696,6 @@ dependencies = [
"notify",
"notify-debouncer-mini",
"once_cell",
"pprof",
"pretty_assertions",
"ratatui",
"rayon-core",
@ -831,24 +776,6 @@ dependencies = [
"hashbrown",
]
[[package]]
name = "inferno"
version = "0.11.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2fb7c1b80a1dfa604bb4a649a5c5aeef3d913f7c520cb42b40e534e8a61bcdfc"
dependencies = [
"ahash",
"indexmap",
"is-terminal",
"itoa",
"log",
"num-format",
"once_cell",
"quick-xml",
"rgb",
"str_stack",
]
[[package]]
name = "inotify"
version = "0.9.6"
@ -1046,15 +973,6 @@ version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
[[package]]
name = "memmap2"
version = "0.5.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "83faa42c0a078c393f6b29d5db232d8be22776a891f8f56e5284faee4a20b327"
dependencies = [
"libc",
]
[[package]]
name = "memoffset"
version = "0.7.1"
@ -1085,18 +1003,6 @@ dependencies = [
"windows-sys 0.42.0",
]
[[package]]
name = "nix"
version = "0.26.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bfdda3d196821d6af13126e40375cdf7da646a96114af134d5f417a9a1dc8e1a"
dependencies = [
"bitflags",
"cfg-if",
"libc",
"static_assertions",
]
[[package]]
name = "notify"
version = "5.2.0"
@ -1125,16 +1031,6 @@ dependencies = [
"notify",
]
[[package]]
name = "num-format"
version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a652d9771a63711fd3c3deb670acfbe5c30a4072e664d7a3bf5a9e1056ac72c3"
dependencies = [
"arrayvec",
"itoa",
]
[[package]]
name = "num-traits"
version = "0.2.15"
@ -1290,27 +1186,6 @@ version = "0.3.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160"
[[package]]
name = "pprof"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "978385d59daf9269189d052ca8a84c1acfd0715c0599a5d5188d4acc078ca46a"
dependencies = [
"backtrace",
"cfg-if",
"findshlibs",
"inferno",
"libc",
"log",
"nix",
"once_cell",
"parking_lot",
"smallvec",
"symbolic-demangle",
"tempfile",
"thiserror",
]
[[package]]
name = "pretty_assertions"
version = "1.4.0"
@ -1360,15 +1235,6 @@ dependencies = [
"unicode-ident",
]
[[package]]
name = "quick-xml"
version = "0.26.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f50b1c63b38611e7d4d7f68b82d3ad0cc71a2ad2e7f61fc10f1328d917c93cd"
dependencies = [
"memchr",
]
[[package]]
name = "quote"
version = "1.0.29"
@ -1453,15 +1319,6 @@ version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e5ea92a5b6195c6ef2a0295ea818b312502c6fc94dde986c5553242e18fd4ce2"
[[package]]
name = "rgb"
version = "0.8.36"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "20ec2d3e3fc7a92ced357df9cebd5a10b6fb2aa1ee797bf7e9ce2f17dffc8f59"
dependencies = [
"bytemuck",
]
[[package]]
name = "ron"
version = "0.8.0"
@ -1659,24 +1516,6 @@ version = "1.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9"
[[package]]
name = "stable_deref_trait"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
[[package]]
name = "static_assertions"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]]
name = "str_stack"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9091b6114800a5f2141aee1d1b9d6ca3592ac062dc5decb3764ec5895a47b4eb"
[[package]]
name = "strsim"
version = "0.10.0"
@ -1704,29 +1543,6 @@ dependencies = [
"syn",
]
[[package]]
name = "symbolic-common"
version = "12.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38f7afd8bcd36190409e6b71d89928f7f09d918a7aa3460d847bc49a538d672e"
dependencies = [
"debugid",
"memmap2",
"stable_deref_trait",
"uuid",
]
[[package]]
name = "symbolic-demangle"
version = "12.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec64922563a36e3fe686b6d99f06f25dacad2a202ac7502ed642930a188fb20a"
dependencies = [
"cpp_demangle",
"rustc-demangle",
"symbolic-common",
]
[[package]]
name = "syn"
version = "1.0.107"
@ -1915,12 +1731,6 @@ dependencies = [
"percent-encoding",
]
[[package]]
name = "uuid"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d023da39d1fde5a8a3fe1f3e01ca9632ada0a63e9797de55a879d6e2236277be"
[[package]]
name = "vcpkg"
version = "0.2.15"

View File

@ -51,10 +51,6 @@ unicode-truncate = "0.2"
unicode-width = "0.1"
which = "4.4"
# pprof is not available on windows
[target.'cfg(not(windows))'.dependencies]
pprof = { version = "0.12", features = ["flamegraph"], optional = true }
[dev-dependencies]
pretty_assertions = "1.4"
tempfile = "3.4"

View File

@ -6,7 +6,7 @@ ARGS=-l
# ARGS=-l -d ~/code/git-bare-test.git -w ~/code/git-bare-test
profile:
cargo run --features=timing,pprof -- ${ARGS}
sudo CARGO_PROFILE_RELEASE_DEBUG=true cargo flamegraph --features timing -- ${ARGS}
run-timing:
cargo run --features=timing --release -- ${ARGS}
@ -29,7 +29,7 @@ release-win: build-release
tar -C ./target/release/ -czvf ./release/gitui-win.tar.gz ./gitui.exe
cargo install cargo-wix --version 0.3.3
cargo wix -p gitui --no-build --nocapture --output ./release/gitui.msi
ls -l ./release/gitui.msi
ls -l ./release/gitui.msi
release-linux-musl: build-linux-musl-release
strip target/x86_64-unknown-linux-musl/release/gitui

View File

@ -38,7 +38,6 @@ mod keys;
mod notify_mutex;
mod options;
mod popup_stack;
mod profiler;
mod queue;
mod spinner;
mod string_utils;
@ -66,7 +65,6 @@ use crossterm::{
};
use input::{Input, InputEvent, InputState};
use keys::KeyConfig;
use profiler::Profiler;
use ratatui::{
backend::{Backend, CrosstermBackend},
Terminal,
@ -127,8 +125,6 @@ fn main() -> Result<()> {
let cliargs = process_cmdline()?;
let _profiler = Profiler::new();
asyncgit::register_tracing_logging();
if !valid_path(&cliargs.repo_path) {

View File

@ -1,39 +0,0 @@
/// helper struct to not pollute main with feature flags shenanigans for the profiler
/// also we make sure to generate a flamegraph on program exit
pub struct Profiler {
#[cfg(feature = "pprof")]
#[cfg(not(windows))]
guard: pprof::ProfilerGuard<'static>,
}
impl Profiler {
#[allow(clippy::missing_const_for_fn)]
pub fn new() -> Self {
Self {
#[cfg(feature = "pprof")]
#[cfg(not(windows))]
guard: pprof::ProfilerGuard::new(100)
.expect("profiler launch error"),
}
}
#[allow(clippy::unused_self)]
fn report(&mut self) {
#[cfg(feature = "pprof")]
#[cfg(not(windows))]
if let Ok(report) = self.guard.report().build() {
let file = std::fs::File::create("flamegraph.svg")
.expect("flamegraph file err");
report.flamegraph(&file).expect("flamegraph write err");
log::info!("profiler reported");
}
}
}
impl Drop for Profiler {
fn drop(&mut self) {
self.report();
}
}

View File

@ -448,6 +448,10 @@ impl Status {
&mut self,
ev: AsyncGitNotification,
) -> Result<()> {
if !self.is_visible() {
return Ok(());
}
match ev {
AsyncGitNotification::Diff => self.update_diff()?,
AsyncGitNotification::Status => self.update_status()?,