-
Notifications
You must be signed in to change notification settings - Fork 236
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
Startup performance improvements #361
base: main
Are you sure you want to change the base?
Conversation
by moving the font registering code into its foreign Thread saving ~2seconds.
I initially followed your TODO comments but as it seems, the removal of the loop fixed it. Got up to only about a second for it by downloading every single library there is. I see this as no longer an issue (you can remove the todos). |
Also a question that is not related to the pr: |
Thanks for looking into it. Please first check whether it's Also, most functions like this need to happen on the EDT, where it's safe to perform AWT operations. So I'm a little nervous that we can't just throw it in a non-EDT thread like this, but should make sure we're safe. And one more, that font needs to be available for the rest of the UI. So we need to make sure it's loaded before anything else is in use, so if we make this change we're gonna have to ensure that none of the other UI elements that expect the font to be available are being initialized in the meantime. |
It is not the class loading that takes that long, but the registering process. I don't really know about AWT and EDT in Java - What should be unsave when calling this code in a separate thread? Also this code is first executed from the Main Thread (constructor of Base) (is this isn't the EDT Thread right?) so I think it should be possible to export the function into its own thread. I thought you were only using the registered font when calling for all accessible fonts in the settings, else using this function to get it (because it returns the font). |
So the first use case is in the EDIT: All Editor functions refer to the |
How and how much time can we save
I followed your timing Todos and commented code, found that these two lines of code take about two seconds to run on the first call.
https://github.com/processing/processing4/blob/5fef895e84c20f4d30ed65a426e37c3c7397e5c7/app/src/processing/app/ui/Toolkit.java#L1225-L1226 By putting the font loading into a thread I was able to reduce the startup time by about two seconds.
I don't think this will cause bugs because
Difference in timings
Reports are seperated by three hyphens (---)
Notice the first font call (Mirroring in ManagerFrame->ContribInit->All)
I want to test that
I also comited and pushed my timing code extending your code on this branch: codeac-timings
Merge the codeac-startup-performance branch into it to see the difference in the first Font call.