GNOME Bugzilla – Bug 760033
Improve start up time
Last modified: 2016-01-03 18:27:42 UTC
Starting gnome-music takes some noticeable amount of time till you are able to manipulate it. I've tested by setting an exit() call on ViewContainer._add_item(), in the "if remaining == 0" branch (basically, the moment where you have all items populated), and running with "time ./gnome-music". In the current state, I get startup times around the 3.7s (mileage may vary depending on hdd speed, amount of music files, etc). I've noticed a few bottlenecks along startup, which I'm attaching patches for. With these patches the startup time as measured above is reduced to a more bearable ~1.3s here.
Created attachment 318084 [details] [review] albumartcache: Make albumart fetching truly asynchronous Despite spawning this into a separate thread, this is still processed quasi-synchronously, delaying the whole insertion. Instead, use GIO/GdkPixbuf asynchronous APIs to load pixbufs, being set as a low priority idle, the actual pixbuf loading will be deferred until the UI is shown. this also means the "..." loading icons will be visible.
Created attachment 318085 [details] [review] notification: Defer serialization of default icon We don't need it until we're playing a song with no album art, so delay it's creation until we do need it. The serialization operation is costly enough that it's noticeable in startup times, so best to take it out of there.
Created attachment 318086 [details] [review] view: Set model on the view after all insertions happened This avoids the burst of ::row-inserted signals, and the resulting side activity. Inserting all items at once when there's still no connected handlers will be faster.
Created attachment 318087 [details] [review] albumartcache: Remove check for dup jobs This incurs in O(n²) behavior, worsened by the fact that we never remove iters from the cache. Instead rely on the query returning unique results.
Created attachment 318088 [details] [review] view: Remove check for duplicate jobs This incurs into O(n²) behavior. Let's instead rely on the query returning unique results.
Created attachment 318089 [details] [review] view: Remove queue_draw() calls Widgets are usually smart enough to redraw themselves, and only the relevant parts. There's no need to make these fully redraw.
Created attachment 318090 [details] [review] view: Don't add items on idle Now that we've removed the bottlenecks from these paths, we can just do this inside the code flow.
Review of attachment 318084 [details] [review]: awesome!
Review of attachment 318085 [details] [review]: sure.
Review of attachment 318086 [details] [review]: sure.
Review of attachment 318087 [details] [review]: good.
Review of attachment 318088 [details] [review]: +1
Review of attachment 318089 [details] [review]: sure.
Review of attachment 318090 [details] [review]: right.
Cheers! Attachment 318084 [details] pushed as 855b710 - albumartcache: Make albumart fetching truly asynchronous Attachment 318085 [details] pushed as b31398c - notification: Defer serialization of default icon Attachment 318086 [details] pushed as 7541059 - view: Set model on the view after all insertions happened Attachment 318087 [details] pushed as e7f1368 - albumartcache: Remove check for dup jobs Attachment 318088 [details] pushed as 7c65baf - view: Remove check for duplicate jobs Attachment 318089 [details] pushed as 278d0cd - view: Remove queue_draw() calls Attachment 318090 [details] pushed as 2cab31f - view: Don't add items on idle