Skip to content

Conversation

Byron
Copy link
Collaborator

@Byron Byron commented Sep 14, 2024

Initially I didn't know where it would be beneficial to use gitoxide tree editing capabilities, but now found create_wd_tree() as candidate.

Despite not exactly knowing why it's needed when applying a branch, it's easy for me to trigger it this way, while noting that it's also used
in many other places.

Baseline

735ms as baseline in the GitLab repository is quite respectable!

INFO     create_virtual_branch_from_branch [ 2.05s | 0.02% / 100.00% ] project_id: d4abe90e-4fed-4d86-bb80-048e3740f003 | branch: Local(Refname { branch: "Virtual-branch", remote: None }) | remote: None
DEBUG    ┕━ create_virtual_branch_from_branch [ 2.05s | 9.48% / 99.98% ] branch: Local(Refname { branch: "Virtual-branch", remote: None }) | remote: None
INFO        ┝━ create_snapshot [ 102ms | 4.97% ]
DEBUG       ┕━ apply_branch [ 1.75s | 0.02% / 85.53% ] branch_id: a5d78a15-5777-471f-be76-a8dcfe578d9c
DEBUG          ┕━ finalize [ 1.75s | 36.14% / 85.51% ]
DEBUG             ┝━ create_wd_tree [ 735ms | 35.84% ]     <-------------------- Before
DEBUG             ┕━ update_workspace_commit [ 277ms | 5.58% / 13.52% ]
DEBUG                ┕━ get_workspace_head [ 163ms | 7.95% ]

After

Now it runs slightly faster at 549ms for a 33% speedup. However, the is likely going to be faster once it actually has to add objects, as these are now added in the main thread, while another thread is producing the status information.

INFO     create_virtual_branch_from_branch [ 1.88s | 0.03% / 100.00% ] project_id: d4abe90e-4fed-4d86-bb80-048e3740f003 | branch: Local(Refname { branch: "Virtual-branch", remote: None }) | remote: None
DEBUG    ┕━ create_virtual_branch_from_branch [ 1.88s | 10.48% / 99.97% ] branch: Local(Refname { branch: "Virtual-branch", remote: None }) | remote: None
INFO        ┝━ create_snapshot [ 99.4ms | 5.30% ]
DEBUG       ┕━ apply_branch [ 1.58s | 0.02% / 84.19% ] branch_id: 1f725f79-8a3c-4c8b-a2ce-cd5a7f8fd15a
DEBUG          ┕━ finalize [ 1.58s | 39.59% / 84.17% ]
DEBUG             ┝━ create_wd_tree [ 549ms | 29.29% ]  <------------------- After
DEBUG             ┕━ update_workspace_commit [ 287ms | 6.31% / 15.30% ]
DEBUG                ┕━ get_workspace_head [ 169ms | 8.99% ]

Tasks

  • use gix
  • remeasure performance

Notes for the Reviewer

  • This PR adds a lot of complexity to what was 4 lines of code previously. In return, one gets performance, more even when it's actually adding objects, and control over every aspect of the operation, an operation that essentially is a manual index.add_all(). The 'control' part is particularly interesting as eventually, I'd really hope it's possible to avoid adding worktree files without user request.
  • My intuition here is that it probably should skip large files right away, but for now I left it like it was to keep the PR focussed.
  • Should IO errors be ignored to make this method more resilient? I don't know what that means for correctness though.

Copy link

vercel bot commented Sep 14, 2024

@Byron is attempting to deploy a commit to the GitButler Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions bot added the rust Pull requests that update Rust code label Sep 14, 2024
@Byron Byron requested a review from krlvi September 14, 2024 14:23
@Byron Byron marked this pull request as ready for review September 14, 2024 14:25
@krlvi krlvi merged commit 5a0cfcd into gitbutlerapp:master Sep 16, 2024
16 of 17 checks passed
@Byron Byron deleted the create-wd-tree branch September 16, 2024 10:14
@Byron Byron mentioned this pull request Jan 4, 2025
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants