Skip to content
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

Profile startup #3095

Closed
willmcgugan opened this issue Aug 14, 2023 · 14 comments
Closed

Profile startup #3095

willmcgugan opened this issue Aug 14, 2023 · 14 comments
Assignees
Labels
enhancement New feature or request Task

Comments

@willmcgugan
Copy link
Collaborator

A user reported that starting up the demo is slow on a Raspberry Pi zero, but runs adequately.

We should profile startup and look for improvements.

demo.py seems a good place to start.

@willmcgugan
Copy link
Collaborator Author

I think we should configure an app to exit immediately (on App.on_ready), and profile that with pyinstrument.

There may be slow routines that stand out. If those are easily optimizable it could be done as part of this issue. Or it could result in optimization issues for later work.

@davep davep self-assigned this Aug 28, 2023
@davep
Copy link
Contributor

davep commented Aug 28, 2023

Initially starting with this app:

from textual.app import App

class GNDN(App[None]):

    def on_ready(self) -> None:
        self.exit()

if __name__ == "__main__":
    GNDN().run()

@davep
Copy link
Contributor

davep commented Aug 28, 2023

Starting on macOS... using the above, initially it looks like the two main areas of work on startup are in getting the driver up and running, and also parsing the initial styles:

Screenshot 2023-08-28 at 09 49 13

@davep
Copy link
Contributor

davep commented Aug 28, 2023

Testing on Windows 11 (under Parallels on macOS), there seems to be a split of similar nature, but with a rather different balance.

Screenshot 2023-08-28 at 09 55 48

@davep davep added enhancement New feature or request Task labels Aug 28, 2023
@EricWF
Copy link
Contributor

EricWF commented Sep 2, 2023

What tool are you using to generate those profiles?

@davep
Copy link
Contributor

davep commented Sep 2, 2023

pyinstrument; see https://github.com/davep/profile-textual for the repo where I've put together some files and a Makefile for testing.

@willmcgugan
Copy link
Collaborator Author

@davep is this in progress or is it stalled?

@davep
Copy link
Contributor

davep commented Nov 21, 2023

As mentioned a couple of weeks back: waiting until you're happy for me to spend some time testing out on the Pi - you said to leave it some time back.

@willmcgugan
Copy link
Collaborator Author

It doesn't need to be on the Raspberry Pi. The relative performance probably isn't going to change that much.

@davep
Copy link
Contributor

davep commented Nov 21, 2023

Having failed to reproduce what the user originally reported, and not found anything obvious that could cause the effect, our conclusion was we should finally test in a similar environment. That's the remaining step here.

@willmcgugan
Copy link
Collaborator Author

As I said: it doesn't need to be on the Raspberry PI. I'm looking for optimisation wins. Going to move this back to Todo.

For the benefit of whoever picks this up. Please don't spend more than half a day. If there are quick wins, go ahead and implement them. Otherwise document them here.

Resolution may very well be that there are no significant improvements.

@willmcgugan willmcgugan assigned willmcgugan and unassigned davep Nov 22, 2023
@willmcgugan
Copy link
Collaborator Author

#3753

@willmcgugan
Copy link
Collaborator Author

#3756

Copy link

Don't forget to star the repository!

Follow @textualizeio for Textual updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Task
Projects
None yet
Development

No branches or pull requests

3 participants