gitbutlerapp / gitbutler

The GitButler version control client, backed by Git, powered by Tauri/Rust/Svelte
https://gitbutler.com
Other
13.41k stars 530 forks source link

High CPU usage and slow UI response time when creating/deleting branches #2776

Closed dobcey closed 2 months ago

dobcey commented 9 months ago

Problem

When creating or deleting a branch the CPU usage goes to 100% and it takes 10 seconds for the operation to succeed (at least visually).

It only seems to affect the branch lane. When creating, the new lane doesn't appear until after 10 seconds, but everything else seems to be working. I can view file diffs in the mean time for example. When deleting, the success message appears after ~ 3 seconds, but the confirmation modal (which can be dismissed) is present until till 10 seconds has passed, and then the deleted lane disappears.

How to reproduce

Create or delete a branch.

System Info

Log output

Create branch - 10s

2024-02-17T09:55:04.883539Z  INFO create_virtual_branch: gitbutler-app/src/virtual_branches/commands.rs:94: new project_id="16a46fcf-f25a-4da1-a036-56b459b88073" branch=BranchCreateRequest { name: None, ownership: None, order: None, selected_for_changes: None }
2024-02-17T09:55:04.911618Z  INFO create_virtual_branch: gitbutler-app/src/virtual_branches/commands.rs:94: close time.busy=28.0ms time.idle=68.5µs project_id="16a46fcf-f25a-4da1-a036-56b459b88073" branch=BranchCreateRequest { name: None, ownership: None, order: None, selected_for_changes: None }
2024-02-17T09:55:14.290854Z  INFO gitbutler-app/src/watcher/dispatchers/file_change.rs:103: git file change project_id=16a46fcf-f25a-4da1-a036-56b459b88073 file_path=.git/logs/HEAD
2024-02-17T09:55:14.352553Z  INFO gitbutler-app/src/watcher/dispatchers/file_change.rs:103: git file change project_id=16a46fcf-f25a-4da1-a036-56b459b88073 file_path=.git/logs/HEAD
2024-02-17T09:55:14.358839Z  INFO gitbutler-app/src/watcher/dispatchers/file_change.rs:103: git file change project_id=16a46fcf-f25a-4da1-a036-56b459b88073 file_path=.git/index
2024-02-17T09:55:14.570149Z  INFO can_apply_virtual_branch: gitbutler-app/src/virtual_branches/commands.rs:354: new project_id="16a46fcf-f25a-4da1-a036-56b459b88073" branch_id="9cd1a6f1-e843-4922-aedc-66fc9a7c5ffb"
2024-02-17T09:55:14.570209Z  INFO can_apply_virtual_branch: gitbutler-app/src/virtual_branches/commands.rs:354: new project_id="16a46fcf-f25a-4da1-a036-56b459b88073" branch_id="00766fe1-3d81-4a19-9ca6-b55210862d6b"
2024-02-17T09:55:14.570317Z  INFO can_apply_virtual_branch: gitbutler-app/src/virtual_branches/commands.rs:354: new project_id="16a46fcf-f25a-4da1-a036-56b459b88073" branch_id="22c24c6d-a5cd-4860-be22-2adc952e8a78"
2024-02-17T09:55:14.570344Z  INFO can_apply_virtual_branch: gitbutler-app/src/virtual_branches/commands.rs:354: new project_id="16a46fcf-f25a-4da1-a036-56b459b88073" branch_id="b3f40b24-df6b-4908-b6fb-c948c70056c5"
2024-02-17T09:55:14.571984Z  INFO can_apply_virtual_branch: gitbutler-app/src/virtual_branches/commands.rs:354: close time.busy=1.65ms time.idle=22.5µs project_id="16a46fcf-f25a-4da1-a036-56b459b88073" branch_id="22c24c6d-a5cd-4860-be22-2adc952e8a78"
2024-02-17T09:55:14.572138Z  INFO can_apply_virtual_branch: gitbutler-app/src/virtual_branches/commands.rs:354: close time.busy=1.78ms time.idle=13.7µs project_id="16a46fcf-f25a-4da1-a036-56b459b88073" branch_id="b3f40b24-df6b-4908-b6fb-c948c70056c5"
2024-02-17T09:55:14.573044Z  INFO can_apply_virtual_branch: gitbutler-app/src/virtual_branches/commands.rs:354: close time.busy=2.83ms time.idle=13.0µs project_id="16a46fcf-f25a-4da1-a036-56b459b88073" branch_id="00766fe1-3d81-4a19-9ca6-b55210862d6b"
2024-02-17T09:55:14.705911Z  INFO can_apply_virtual_branch: gitbutler-app/src/virtual_branches/commands.rs:354: close time.busy=136ms time.idle=37.2µs project_id="16a46fcf-f25a-4da1-a036-56b459b88073" branch_id="9cd1a6f1-e843-4922-aedc-66fc9a7c5ffb"

Delete branch - 10s

2024-02-17T10:05:08.811555Z  INFO delete_virtual_branch: gitbutler-app/src/virtual_branches/commands.rs:242: close time.busy=4.71s time.idle=41.1µs project_id="16a46fcf-f25a-4da1-a036-56b459b88073" branch_id="22c24c6d-a5cd-4860-be22-2adc952e8a78"
2024-02-17T10:05:08.812440Z  INFO list_remote_branches: gitbutler-app/src/virtual_branches/commands.rs:504: new project_id="16a46fcf-f25a-4da1-a036-56b459b88073"
2024-02-17T10:05:08.815380Z  INFO list_remote_branches: gitbutler-app/src/virtual_branches/commands.rs:504: close time.busy=2.92ms time.idle=24.0µs project_id="16a46fcf-f25a-4da1-a036-56b459b88073"
2024-02-17T10:05:18.160110Z  INFO gitbutler-app/src/watcher/dispatchers/file_change.rs:103: git file change project_id=16a46fcf-f25a-4da1-a036-56b459b88073 file_path=.git/logs/HEAD
2024-02-17T10:05:18.205678Z  INFO gitbutler-app/src/watcher/dispatchers/file_change.rs:103: git file change project_id=16a46fcf-f25a-4da1-a036-56b459b88073 file_path=.git/logs/HEAD
2024-02-17T10:05:18.211950Z  INFO gitbutler-app/src/watcher/dispatchers/file_change.rs:103: git file change project_id=16a46fcf-f25a-4da1-a036-56b459b88073 file_path=.git/index
2024-02-17T10:05:18.404556Z  INFO can_apply_virtual_branch: gitbutler-app/src/virtual_branches/commands.rs:354: new project_id="16a46fcf-f25a-4da1-a036-56b459b88073" branch_id="00766fe1-3d81-4a19-9ca6-b55210862d6b"
2024-02-17T10:05:18.404585Z  INFO can_apply_virtual_branch: gitbutler-app/src/virtual_branches/commands.rs:354: new project_id="16a46fcf-f25a-4da1-a036-56b459b88073" branch_id="b3f40b24-df6b-4908-b6fb-c948c70056c5"
2024-02-17T10:05:18.404644Z  INFO can_apply_virtual_branch: gitbutler-app/src/virtual_branches/commands.rs:354: new project_id="16a46fcf-f25a-4da1-a036-56b459b88073" branch_id="9cd1a6f1-e843-4922-aedc-66fc9a7c5ffb"
2024-02-17T10:05:18.407161Z  INFO can_apply_virtual_branch: gitbutler-app/src/virtual_branches/commands.rs:354: close time.busy=2.58ms time.idle=27.7µs project_id="16a46fcf-f25a-4da1-a036-56b459b88073" branch_id="00766fe1-3d81-4a19-9ca6-b55210862d6b"
2024-02-17T10:05:18.408121Z  INFO can_apply_virtual_branch: gitbutler-app/src/virtual_branches/commands.rs:354: close time.busy=951µs time.idle=2.59ms project_id="16a46fcf-f25a-4da1-a036-56b459b88073" branch_id="b3f40b24-df6b-4908-b6fb-c948c70056c5"
2024-02-17T10:05:18.535438Z  INFO can_apply_virtual_branch: gitbutler-app/src/virtual_branches/commands.rs:354: close time.busy=127ms time.idle=3.50ms project_id="16a46fcf-f25a-4da1-a036-56b459b88073" branch_id="9cd1a6f1-e843-4922-aedc-66fc9a7c5ffb"

CPU Activity

Screenshot 2024-02-17 at 11 02 13

Delete success message

Shown before lane is visually removed.

Screenshot 2024-02-17 at 11 30 07
krlvi commented 9 months ago

Hey @dobcey! thanks for reporting this - this is definitely something of a high prio for us to fix. Do you remember if you had a large number of files (15+) modified or if the diffs were particularly big (in the thousands of LoC)? Does your repository happen to have a particularly large number of (remote) branches? e.g 100+

Earlier today i released a patch update (0.10.11 - discord link) with some performance improvements, but I suspect that they would not be applicable for your specific situation.

dobcey commented 9 months ago

I upgraded to 0.10.11 with the same result, as you suspected. I had 6 modified files, none of which had a large diff. The repo does not have a large numer of remote branches. It does however use git-lfs that points to a 23 Mb binary file.

The behaviour (max CPU and wait time) seems to be the same for many (if not all) git related operations; commiting, undoing commits, amending. The same also happens when I launch GitButler and it loads the Workspace. I see a spinner for 10 seconds and the CPU maxes out.

dobcey commented 9 months ago

I must also say that I'm exited about your product. Thank you for building this @krlvi!

krlvi commented 9 months ago

the git-lfs is an interesting pointer for me to investigate! i will ping you in this thread if i have a suspected fix :) thank you @dobcey for being patient with us!

nvandessel commented 8 months ago

I have also been encountering significant slow downs on repositories that use git-lfs, which results in a non-trivial changelist on some projects. One project in particular has over ~130 changed files, which are not actually changed; just simply incorrect due to the lack of git-lfs support.

krlvi commented 5 months ago

Hey, it's an old issue but I wanted to update here as well since there has been a bunch of work on this front. There are some performance improvements which just landed with the latest patch release 0.12.5. Let me know how it works for you

krlvi commented 3 months ago

@dobcey are you still experiencing this issue with the more recent versions of the app? We have done quite a bit of changes to this flow, and I expect that the issue specific to deleting branches should be fixes

krlvi commented 2 months ago

Closing this one since we havent heard back from the author. Feel free to create a new issue if this is still an issue. Thank you.