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 705415 - gio: incredibly inefficient when playing mp3s from smb servers
gio: incredibly inefficient when playing mp3s from smb servers
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
git master
Other Linux
: Normal normal
: 1.0.10
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2013-08-03 15:08 UTC by Jonathan Matthew
Modified: 2013-08-27 11:23 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
make better use of the cached buffer (5.11 KB, patch)
2013-08-03 15:13 UTC, Jonathan Matthew
needs-work Details | Review
do the full read too (5.05 KB, patch)
2013-08-08 21:46 UTC, Jonathan Matthew
committed Details | Review

Description Jonathan Matthew 2013-08-03 15:08:11 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.
Comment 1 Jonathan Matthew 2013-08-03 15:13:33 UTC
Created attachment 250775 [details] [review]
make better use of the cached buffer
Comment 2 Sebastian Dröge (slomo) 2013-08-08 09:39:35 UTC
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
Comment 3 Jonathan Matthew 2013-08-08 21:46:41 UTC
Created attachment 251211 [details] [review]
do the full read too
Comment 4 Jonathan Matthew 2013-08-08 21:47:49 UTC
Good point. I initially wanted to make it behave this way, but I didn't realise how easy it would be.
Comment 5 Sebastian Dröge (slomo) 2013-08-12 13:25:49 UTC
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
Comment 6 Tim-Philipp Müller 2013-08-27 11:23:18 UTC
Cherry-picked into 1.0 branch for 1.0.10.