In a previous blog post I asked for volunteers to send in their shutdown profiles automatically. I’ve received hundreds of slow shutdown profiles, 30 profiles of which are over 10 seconds and one as high as 80 seconds! These profiles show us where Firefox is spending its time when closing down to the millisecond.
Before I started this experiment I asked around for what people thought was the cause of the slow shutdowns. The overwhelming response I got was that it was Garbage Collection and Cycle Collection. While those operations do make the shutdowns slower, they were rarely responsible for those 10 to 80 seconds shutdown times.
Here’s some interesting issues we found:
- A few start-up optimizations moved operations off the startup path and into timers that would update the startup cache, or load fonts. These timers were never canceled when shutting down so they would lead to things such as font loading while shutting down. Since you have to open & close the browser within a minute to see these issues they are not critical for our users but these are certainly bugs we are cleaning up. Keep in mind if you are running timers you should stop them on shutdown before they fire if they are no longer useful.
- On a related note we have timers going off during the shutdown. Particularly GC and CC timers. There is no guarantee that the shutdown will take long enough for these timers to run. If these are useless then we will waste time but if they are important they may not run.
- Stopping plug-ins can take up to a second. I do not capture what is happening in the plug-in process so I can’t tell if it’s our container or the plug-in.
- Releasing style sheets on shutdown will sometimes total over 1 second of execution on slow shutdown.
- Time spent in sqlite3close in some profiles is as high as 10 seconds.
- Bookmark backups are hurting us.
A big thumbs up to people who are submitting shutdown profiles. The data we are collecting is very valuable in helping us understand how Firefox behaves outside the labs.