GNOME Bugzilla – Bug 341818
[matroskademux] poor concurrent performance
Last modified: 2006-05-17 08:13:01 UTC
Currently, the ebml reader of the Matroska demuxer (ebml-read.c) makes a heavy use of gst_buffer_create_sub() to extract data from the main buffer. The problem is, that creating and destroying of the subbuffer involve calls to GLib's type identification machinery, and require a serialization using one global mutex. This is expensive performance-wise, and many concurrent instances of this plugin running, it leads to fatal mutex contention. The attached patch modifies ebml-read.c to simply use pointers instead of a subbuffer where possible. The gst_ebml_read_peek_bytes() function now accepts two parameters for a return value, GstBuffer ** and guint **, and returns the subbuffer or just a data pointer any of them which is non-null. Inside ebml-read, which does mostly trivial actions, and would discard the subbuffer immediately, the pointers are used exclusively. Outside of ebml-read, the subbuffers are exported as before. We observed at least a ten-fold performance increase in the terms of concurent streams after this change.
Created attachment 65481 [details] [review] Patch to ebml-read.c
Indeed, very silly and inefficient code there (left over from when the demuxer was ported to 0.10). Thanks for the patch! 2006-05-16 Tim-Philipp Müller <tim at centricular dot net> Patch by: Jindrich Makovicka <jindrich.makivicka at itonis tv> * gst/matroska/ebml-read.c: (gst_ebml_read_peek_bytes), (gst_ebml_read_pull_bytes), (gst_ebml_read_element_id), (gst_ebml_read_element_length), (gst_ebml_read_buffer), (gst_ebml_read_bytes), (gst_ebml_read_uint), (gst_ebml_read_sint), (gst_ebml_read_float), (gst_ebml_read_ascii), (gst_ebml_read_binary): Don't create unnecessary sub-buffers all the time. Dramatically improves performance with multiple concurrently running matroskademux instances (#341818) (and generally avoids doing unnecessarily inefficient things).