Repository navigation
Improve startup time - #5934
Merged
Merged
Improve startup time#5934
Conversation
Everything in performRefresh is meant to read as "if this scope was asked for, refresh it", with the scopes that always change together expanded into each other up front so that each check can name a single one. The commits and the branches were the exception: one condition asking for either of them refreshed both, so what that block does only followed from reading it together with the expansion at the top of the function. The rebase commits hung off the same condition as an else, even though it is the commits refresh they are an alternative to. Expand those two into each other like the other pairs, and give each of them a check of its own. They now capture their inputs separately, which is what every other scope has always done. The reflog stays with the branches rather than getting a check of its own, because sorting the branches by recency needs it loaded first. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The worktrees were loaded and written by the branches refresh whenever both were in scope, because the branches view shows worktrees against branches: refreshing them separately rendered that view twice, once with worktrees that were still stale. Ordering the two is enough for that, and it leaves each scope owning its own model again. The worktrees refresh now runs first and queues its model write before it reports being done, so a branches refresh that waits for it queues its own write behind that one, and renders once with both. The worktrees scope only renders the branches view itself when nobody else is going to. As a side effect the two loads now run concurrently, where the branches refresh used to load the worktrees after its own branches. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
We show this with a worktree icon (which is only shown when nerd fonts are used, so turn these on), but also we strip the trailing `/` that "git status" reports, so that it shows as a file rather than a directory with a bogus file in it. The reason for adding the test is that we are going to touch the logic that determines whether an item in the Files panel is a linked worktree, and this guards against regressing.
Finding out which of the files are worktrees of ours had its own answer to where this repo's worktrees are, walking the directory that git keeps them in. The worktrees panel asks git itself, and that is the better answer: it is the one git gives for the same question elsewhere in the app, and it doesn't need to know where git records what. The model that panel fills is all the files need, so mark them from it. That takes the work out of the file loader, whose other two callers were paying for it without wanting it, and it costs no git call at all: both models are written on the UI thread, so whichever of the two refreshes lands second marks the files against the other's fresh data. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
A terminal that supports focus reporting answers with the state it is already in when we turn reporting on, so at startup we were told that we had gained focus that we never lost, and refreshed everything a second time on top of the refresh that loading the repo had just started. The two ran at once, each with its own `git status`, which made both of them slower than the one refresh needed to be. Keep track of what the reports say, then, and pass on only the ones that change it. Assuming that we start out focused costs us nothing when we don't: that same first report says so, so a lazygit started in a window that isn't in front knows it from the start. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
|
Before the change, in my "test" repo where i reproduced the original issue: After the change: The improvement is definitely noticeable I guess in my original work repo with many submodules and many worktrees that will help a lot. |
1 task
social4hyq
pushed a commit
to social4hyq/homebrew-core
that referenced
this pull request
Sep 20, 2026
lazygit 0.65.0 Created-by: HarmonybrewBot Commit-by: HarmonybrewBot Merged-by: HarmonybrewBot Description: Created by `brew bump` --- Created with `brew bump-formula-pr`.<details> <summary>release notes</summary> <pre><!-- Release notes generated using configuration in .github/release.yml at v0.65.0 --> ## What's Changed ### Enhancements 🔥 * Draw the UI in a more inactive look when the window is not focused by @stefanhaller in jesseduffield/lazygit#5935 * Keep the last conflict file selected after resolution by @stefanhaller in jesseduffield/lazygit#5936 * Auto-select the conflicted commit when stopping in rebase by @stefanhaller in jesseduffield/lazygit#5937 * Keep showing files whose conflicts have been resolved by @stefanhaller in jesseduffield/lazygit#5940 * Allow filtering worktrees by branch name in Worktrees pane by @stefanhaller in jesseduffield/lazygit#5980 * Allow filtering the keybindings and recent repos menus more directly (simply by typing) by @stefanhaller in jesseduffield/lazygit#5985 ### Fixes 🔧 * Scroll the selection into view by default again by @stefanhaller in jesseduffield/lazygit#5928 * Disable staging all files when there are none to stage by @stefanhaller in jesseduffield/lazygit#5932 * Fix flicker, scroll glitches, and crashes in async diff rendering by @stefanhaller in jesseduffield/lazygit#5938 * Show renames when selecting a directory that a file was moved into or out of by @stefanhaller in jesseduffield/lazygit#5924 * Fix visual glitches when moving a rebase todo by @stefanhaller in jesseduffield/lazygit#5977 * Validate the context names in the "context" field of custom commands by @stefanhaller in jesseduffield/lazygit#5989 * Fix some obscure selection highlighting bugs by @stefanhaller in jesseduffield/lazygit#5990 * Re-render the focused main view if its content changes while it is being searched by @stefanhaller in jesseduffield/lazygit#5993 ### Maintenance ⚙️ * Bump gofumpt to version 0.11.0 by @stefanhaller in jesseduffield/lazygit#5925 * Avoid gofumpt'ing other worktrees by @stefanhaller in jesseduffield/lazygit#5931 * Two small improvements to the debug log by @stefanhaller in jesseduffield/lazygit#5933 * Bump golangci-lint to v2.12.2 by @stefanhaller in jesseduffield/lazygit#5941 * Bump github.com/xo/terminfo from 0.0.0-20220910002029-abceb7e1c41e to 1.0.0 by @dependabot[bot] in jesseduffield/lazygit#5950 * Bump github.com/stretchr/testify from 1.11.1 to 1.12.1 by @dependabot[bot] in jesseduffield/lazygit#5968 * Bump github.com/gdamore/tcell/v3 from 3.4.1 to 3.4.2 by @dependabot[bot] in jesseduffield/lazygit#5970 * Bump github.com/sirupsen/logrus from 1.9.4 to 1.10.2 by @dependabot[bot] in jesseduffield/lazygit#5987 ### Docs 📖 * Fix example for args field in rawGit diff renderer docs by @stefanhaller in jesseduffield/lazygit#5927 ### I18n 🌎 * Update translations from Crowdin by @stefanhaller in jesseduffield/lazygit#5994 ### Performance Improvements 📊 * Improve startup time by @stefanhaller in jesseduffield/lazygit#5934 * Improve performance of moving rebase todos by @stefanhaller in jesseduffield/lazygit#5978 **Full Changelog**: jesseduffield/lazygit@v0.64.1...v0.65.0 </pre> <p>View the full release notes at <a href="https://github.com/jesseduffield/lazygit/releases/tag/v0.65.0">https://github.com/jesseduffield/lazygit/releases/tag/v0.65.0</a>.</p> </details> <hr> See merge request: Harmonybrew/homebrew-core!18514
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR has two separate improvements for the startup time, in particular for the time until the Files panel shows the modified files:
.git/workspacesdir recursively, looking for the gitdir files of linked worktrees. This code was not used to populate the worktrees panel, but only for the decision in the Files panel whether to show an entry with the worktree icon; it was doing unnecessary work, because walking the.git/workspacesdir recursively is pointless (git stores the worktree gitdir files only at the top level, so a flat read of that directory would have been enough), and can take significant time in large repos, especially when they have many submodules. Instead of fixing that code, remove it entirely and rearrange the refresh code so that we can use the regular worktree model for this Files panel decision.Both of these together reduce the time it takes for the Files panel to show its files at startup (in my regular work repo with three worktrees and ~30 submodules) from 860ms to 440ms, so almost a factor of two. If you want to measure this in your own repo, here's a small throwaway patch that you can use for that:
To use it, run
./lazygit -l | grep "first files refresh"in one terminal, andlazygit -din the one that you want to test. I'm curious about your before/after measurements, feel free to post them below in the comments.