Skip to content

speed up display by caching formatter_helpstr #2830

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

midichef
Copy link
Contributor

@midichef midichef commented Aug 2, 2025

formatter_helpstr is slow, and runs once per command, including all movements like go-down. On my system it adds an average delay of about 7 ms. Every so often it adds 20-30 ms.

The code that calls this is drawRightStatus(). The use of formatter_helpstr was already being cached, but the cache is cleared between commands. This PR caches the result permanently, once per sheet.

The 7 ms delay is in the creation of HelpSheet. I don't know why the delays are irregular, spiking up to 20-30ms about 2% of the time. I suspect it's due to the vd.sync() call in vd.sync(self.helpsheet.ensureLoaded()).

In my testing, the net effect of this PR is about a 40% speedup for draw_all().

Speeds up display significantly, by 7 milliseconds per command.
Copy link
Owner

@saulpw saulpw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, thanks for drilling down into this! A 40% speedup is nothing to sneeze at, for one token change. How long did this take you to figure out?

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.

2 participants