GNOME Bugzilla – Bug 705415
gio: incredibly inefficient when playing mp3s from smb servers
Last modified: 2013-08-27 11:23:18 UTC
When playing an mp3 from an smb server, the source gets 64k read requests that have over 60k of overlap. giosrc caches the last buffer it read, but only uses it if it can completely satisfy the next read request. The end result of this is that giosrc issues each of those 64k read requests to the smb server as-is, which means a lot more network traffic than is required to play the file. Somewhere around 30Mbit/s to play a 320kbps mp3 file. Users notice this sort of thing when trying to play files from a network share in rhythmbox, and they see strange results like being able to play files when using a wired connection, but not over wifi. It seems particularly bad with mp3s, probably because whatever's deciding it wants 64k buffers is mp3-specific. I think I saw it in mpegaudioparse, but I may be misremembering. I'm attaching a patch that makes giosrc partially satisfy the read from the cached buffer and only read the rest, which makes everything look much more sensible. The read requests sent to the server are much smaller, which may not be a great thing overall.
Created attachment 250775 [details] [review] make better use of the cached buffer
Review of attachment 250775 [details] [review]: Looks good generally just: ::: gst/gio/gstgiobasesrc.c @@ +372,3 @@ * at least the requested amount of bytes or a read returns * nothing. */ + mem = gst_allocator_alloc (NULL, cachesize - read, NULL); I think it makes sense to still read cachesize bytes. Otherwise you might end up reading just a byte or two here which is a bit inefficient when going through e.g. gvfs
Created attachment 251211 [details] [review] do the full read too
Good point. I initially wanted to make it behave this way, but I didn't realise how easy it would be.
Fixed some memory leaks in error cases and pushed. commit cc1de5ae9403761155e24c4fe6f88cd788e92400 Author: Jonathan Matthew <jonathan@d14n.org> Date: Sun Aug 4 01:01:25 2013 +1000 gio: make better use of the cached buffer When playing mp3 files from a smb server, we get 64k read requests that mostly overlap. Without using the cache to partially satisfy these, we send these requests straight to the server, resulting in a lot more network traffic than necessary. https://bugzilla.gnome.org/show_bug.cgi?id=705415
Cherry-picked into 1.0 branch for 1.0.10.