After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 760033 - Improve start up time
Improve start up time
Status: RESOLVED FIXED
Product: gnome-music
Classification: Applications
Component: general
unspecified
Other Linux
: Normal enhancement
: ---
Assigned To: gnome-music-maint
gnome-music-maint
Depends on:
Blocks:
 
 
Reported: 2015-12-31 19:02 UTC by Carlos Garnacho
Modified: 2016-01-03 18:27 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
albumartcache: Make albumart fetching truly asynchronous (4.35 KB, patch)
2015-12-31 19:03 UTC, Carlos Garnacho
committed Details | Review
notification: Defer serialization of default icon (2.54 KB, patch)
2015-12-31 19:03 UTC, Carlos Garnacho
committed Details | Review
view: Set model on the view after all insertions happened (2.59 KB, patch)
2015-12-31 19:03 UTC, Carlos Garnacho
committed Details | Review
albumartcache: Remove check for dup jobs (1.38 KB, patch)
2015-12-31 19:03 UTC, Carlos Garnacho
committed Details | Review
view: Remove check for duplicate jobs (1.17 KB, patch)
2015-12-31 19:03 UTC, Carlos Garnacho
committed Details | Review
view: Remove queue_draw() calls (1.34 KB, patch)
2015-12-31 19:04 UTC, Carlos Garnacho
committed Details | Review
view: Don't add items on idle (1.68 KB, patch)
2015-12-31 19:04 UTC, Carlos Garnacho
committed Details | Review

Description Carlos Garnacho 2015-12-31 19:02:14 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.
Comment 1 Carlos Garnacho 2015-12-31 19:03:38 UTC
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.
Comment 2 Carlos Garnacho 2015-12-31 19:03:43 UTC
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.
Comment 3 Carlos Garnacho 2015-12-31 19:03:48 UTC
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.
Comment 4 Carlos Garnacho 2015-12-31 19:03:53 UTC
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.
Comment 5 Carlos Garnacho 2015-12-31 19:03:58 UTC
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.
Comment 6 Carlos Garnacho 2015-12-31 19:04:03 UTC
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.
Comment 7 Carlos Garnacho 2015-12-31 19:04:08 UTC
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.
Comment 8 Felipe Borges 2016-01-03 17:42:21 UTC
Review of attachment 318084 [details] [review]:

awesome!
Comment 9 Felipe Borges 2016-01-03 17:42:49 UTC
Review of attachment 318085 [details] [review]:

sure.
Comment 10 Felipe Borges 2016-01-03 17:43:11 UTC
Review of attachment 318086 [details] [review]:

sure.
Comment 11 Felipe Borges 2016-01-03 17:43:46 UTC
Review of attachment 318087 [details] [review]:

good.
Comment 12 Felipe Borges 2016-01-03 17:43:48 UTC
Review of attachment 318087 [details] [review]:

good.
Comment 13 Felipe Borges 2016-01-03 17:44:04 UTC
Review of attachment 318088 [details] [review]:

+1
Comment 14 Felipe Borges 2016-01-03 17:44:25 UTC
Review of attachment 318089 [details] [review]:

sure.
Comment 15 Felipe Borges 2016-01-03 17:44:26 UTC
Review of attachment 318089 [details] [review]:

sure.
Comment 16 Felipe Borges 2016-01-03 17:44:46 UTC
Review of attachment 318090 [details] [review]:

right.
Comment 17 Carlos Garnacho 2016-01-03 18:27:13 UTC
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