Skip to content

Redraw only the spinner when nothing else has changed#5571

Open
AntoineGS wants to merge 1 commit intojesseduffield:masterfrom
AntoineGS:spinner-cpu-usage
Open

Redraw only the spinner when nothing else has changed#5571
AntoineGS wants to merge 1 commit intojesseduffield:masterfrom
AntoineGS:spinner-cpu-usage

Conversation

@AntoineGS
Copy link
Copy Markdown
Contributor

PR Description

This fixes #4734, where lazygit would use a lot of CPU when the spinner was shown due to redrawing the entire screen every time the spinner needed a redraw.
The change adds the ability to request a UI redraw without invalidating the full UI, thus only redrawing the spinner, re-routing the spinner to this new flow.
CPU usage on a chromebook went from 60% to 5% when the spinner is shown.

Changing the refresh rate of the spinner from 50ms to 200ms brings it down from 5% to 1% if ever we would like to change the default, personally I prefer the slower moving spinner, but that's subjective.

Please check if the PR fulfills these requirements

  • Cheatsheets are up-to-date (run go generate ./...)
  • Code has been formatted (see here)
  • Tests have been added/updated (see here for the integration test guide)
  • Text is internationalised (see here)
  • If a new UserConfig entry was added, make sure it can be hot-reloaded (see here)
  • Docs have been updated if necessary
  • You've read through your own file changes for silly mistakes etc

@AntoineGS AntoineGS force-pushed the spinner-cpu-usage branch from 88c40e0 to 84a9210 Compare May 1, 2026 18:23
@AntoineGS AntoineGS marked this pull request as draft May 1, 2026 18:47
@AntoineGS AntoineGS force-pushed the spinner-cpu-usage branch from 84a9210 to 7270d5a Compare May 1, 2026 18:49
@AntoineGS
Copy link
Copy Markdown
Contributor Author

Went in a rabbit hole so it'll take some time to wrap up a working solution, my original approach introduced a bug where the full redraw event could be lost while the spinner was shown. I'll let you know when I am done!

Fixes jesseduffield#4734, leverage tcell's dirty cell redraw to only redraw the
spinner instead of triggering a full UI redraw on each tick.
@AntoineGS AntoineGS force-pushed the spinner-cpu-usage branch from 7270d5a to 050ff91 Compare May 1, 2026 20:46
@AntoineGS AntoineGS marked this pull request as ready for review May 1, 2026 20:50
@AntoineGS
Copy link
Copy Markdown
Contributor Author

Alright so the problem was that some processes that update the layout do not themselves request a redraw and assumed it would be done through the ticker loop, adding a single full redraw after the ticker has completed (aka whatever job it was doing is done) fixed my issue.
Ready for review :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

High 'idle' CPU usage caused by rendering spinner of background fetch

1 participant