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 732152 - multiudpsink: use sendmmsg() to send multiple packets to multiple recipients in one go
multiudpsink: use sendmmsg() to send multiple packets to multiple recipients ...
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-good
git master
Other Linux
: Normal enhancement
: 1.5.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on: 719646
Blocks:
 
 
Reported: 2014-06-24 11:42 UTC by Tim-Philipp Müller
Modified: 2014-12-16 20:28 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Tim-Philipp Müller 2014-06-24 11:42:11 UTC
As the subject says, on Linux we have sendmmsg() which allows us to send multiple messages in one go, each made up of different memory chunks, and possibly going to different recipients. This drastically reduces the number of syscalls required when sending high-bitrate video or sending the same data to multiple recipients, which will help with performance especially on embedded systems.

Depends on a g_socket_send_messages() addition to GLib.

WIP patches here: http://cgit.freedesktop.org/~tpm/gst-plugins-good/log/?h=udpsink-send-messages
Comment 1 Jake Foytik 2014-07-08 13:16:50 UTC
Tim-Philipp, this looks like a nice enhancement. Are these patches planned to be included in 1.4.0 and do you know when g_socket_send_messages() will be included in a GLib release?
Comment 2 Tim-Philipp Müller 2014-07-08 16:58:47 UTC
I don't know when g_socket_send_messages() will end up in GLib. Those patches won't be included in 1.4.0 I'm afraid, I'm actually waiting for 1.4.0 to be out before pushing them. I might cherry-pick some of the smaller improvements into 1.4.x to fix the locking issue in the other bug though if there are problems with the patches, we'll have to see how it goes.
Comment 3 Tim-Philipp Müller 2014-12-16 20:28:36 UTC
g_socket_send_messages() landed in the latest GLib development release (2.43.2), so will be in the 2.44.0 stable release.

commit 4dd7d79b5257730c91968bdadf90b1e6e927451a
Author: Tim-Philipp Müller <tim@centricular.com>
Date:   Fri Dec 12 23:06:07 2014 +0000

    udpsink: allocate scratch space for render functions on the heap
    
    and not the stack. Our allocations could get a bit too large
    to be sure it's not going to cause trouble using the stack.

commit 97a2eb7afbe004edf95a49468e48f2cab23db84d
Author: Tim-Philipp Müller <tim@centricular.com>
Date:   Tue Jun 24 01:16:37 2014 +0100

    multiudpsink: re-use send_buffers() code path for render() function
    
    It's like rendering a buffer list, just with one buffer.
    Has the added advantage that if there are multiple clients
    we can send the buffer to all the clients in one go.

commit 54a9a436ba04e47000300377f899a5d3858c74d8
Author: Tim-Philipp Müller <tim@centricular.com>
Date:   Tue Jun 24 01:15:25 2014 +0100

    multiudpsink: keep client list consistent during removals
    
    We unlock and re-lock the client lock while emitting the
    removed signal, which causes inconsistencies in the client
    list vs. the client counts. Instead, remove the client from
    the list already before emitting the signal and put it into
    a temporary list of clients to be removed. That way things
    look consistent to the streaming thread, but signal callbacks
    can still do things like get stats from removed clients.

commit fa3ef2e54ceb7437368dd6c61ef4531adc3068dd
Author: Tim-Philipp Müller <tim@centricular.com>
Date:   Tue Jun 24 00:56:27 2014 +0100

    multiudpsink: fix client count after removal

commit 7bdf7500a1b0bcfa8229cc513e45d4604a64bdb8
Author: Tim-Philipp Müller <tim@centricular.com>
Date:   Mon Jun 23 18:43:21 2014 +0100

    multiudpsink: keep client list sorted by socket family
    
    We make use of in the send_buffers() function if we
    need to use different sockets to send to IPv4 and
    IPv6 destinations.

commit e1a7deb27f7eeb037e3361551e5e853df0920b05
Author: Tim-Philipp Müller <tim@centricular.com>
Date:   Fri Jun 20 11:36:19 2014 +0100

    multiudpsink: add sendmmsg-ready render_list function prototype
    
    Add prototype for a render_list() function that can use a
    sendmmsg-style g_socket_send_messages() function once it lands
    in GLib. We can use this infrastructure to send multiple buffers
    made up by multiple memories to multiple clients in one go, which
    drastically reduces the number of syscalls made when sending
    high-bitrate video streams.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=732152

commit dead5c2476ff1033c8765764fbe970a084ad888a
Author: Tim-Philipp Müller <tim@centricular.com>
Date:   Thu Jun 19 19:16:01 2014 +0100

    multiudpsink: make udp client structure refcounted
    
    Use the refcount for memory management and keep track
    of the number of duplicate clients in a separate
    variable. This will be useful later, and means we
    don't have to hold the OBJECT_LOCK all the time.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=732866

commit 675384a8cb43277643ac7302c9fa5878f1893887
Author: Tim-Philipp Müller <tim@centricular.com>
Date:   Thu Jun 19 18:31:05 2014 +0100

    multiudpsink: keep count of number of unique and non-unique IPv4 and IPv6 clients
    
    This will come in handy later.