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 582564 - [controller] Use ordered GSequence instead of GList in the interpolation control source
[controller] Use ordered GSequence instead of GList in the interpolation cont...
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
git master
Other Linux
: Normal enhancement
: 0.10.24
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2009-05-14 04:13 UTC by Sebastian Dröge (slomo)
Modified: 2009-06-01 08:13 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
controller-sequence.diff (17.86 KB, patch)
2009-05-14 04:13 UTC, Sebastian Dröge (slomo)
none Details | Review
controller-sequence.diff (18.84 KB, patch)
2009-05-14 07:21 UTC, Sebastian Dröge (slomo)
committed Details | Review

Description Sebastian Dröge (slomo) 2009-05-14 04:13:19 UTC
Hi,
the attached patch changes GstInterpolationControlSource to use a GSequence instead of a GList for the control points. This lowers the worst case O(n) lookup to a O(log n) lookup and also speeds up the insertion a lot ( before it was always O(n), now it's O(log n)).

Please test if this introduces any regressions, I'll add some more comments to the changes later...
Comment 1 Sebastian Dröge (slomo) 2009-05-14 04:13:51 UTC
Created attachment 134623 [details] [review]
controller-sequence.diff
Comment 2 Sebastian Dröge (slomo) 2009-05-14 07:21:29 UTC
Created attachment 134628 [details] [review]
controller-sequence.diff
Comment 3 Stefan Sauer (gstreamer, gtkdoc dev) 2009-05-14 20:06:06 UTC
Cool stuff. Works fine for me.
Comment 4 Sebastian Dröge (slomo) 2009-05-14 20:13:58 UTC
commit ec5c918dbd9098e56e1c2802625af911c56a487c
Author: Sebastian Dröge <sebastian.droege@collabora.co.uk>
Date:   Thu May 14 22:11:57 2009 +0200

    controller: Use ordered GSequence instead of GList
    
    This makes lookups and insertions O(log n) instead of
    always O(n) for insertions and O(n) in worst case for
    lookups.
    
    Fixes bug #582564.

Comment 5 Jonathan Matthew 2009-05-17 14:33:52 UTC
This seems to be causing a lot of critical warnings in rhythmbox.  

For the first track played, per buffer:
  GLib-CRITICAL **: g_sequence_get_begin_iter: assertion `seq != NULL' failed

and for every track after that, when fading in:
  GLib-CRITICAL **: g_sequence_free: assertion `seq != NULL' failed

Partial stack trace for the first warning:

  • #7 IA__g_sequence_get_begin_iter
    at /build/buildd-glib2.0_2.20.1-2-i386-hGzT8z/glib2.0-2.20.1/glib/gsequence.c line 1067
  • #8 _interpolate_linear_get_double
    at gstinterpolation.c line 606
  • #9 interpolate_linear_get_double
    at gstinterpolation.c line 606
  • #10 gst_control_source_get_value
    at gstcontrolsource.c line 96
  • #11 gst_controller_sync_values
    at gstcontroller.c line 697
  • #12 gst_object_sync_values
    at gsthelper.c line 184
  • #13 volume_before_transform
    at gstvolume.c line 730

At this point there would not be any control points set.

The second occurs in gst_interpolation_control_source_unset_all.  There's no check to see if self->priv->values is NULL in _unset_all (or in _unset).

Comment 6 Sebastian Dröge (slomo) 2009-05-17 14:56:40 UTC
Thanks, I'll take a look at this in the next days. Good to know that RB also uses the controller :)
Comment 8 Jonathan Matthew 2009-05-22 09:34:21 UTC
Thanks, it's behaving itself now.
Comment 9 Stefan Sauer (gstreamer, gtkdoc dev) 2009-05-22 10:52:59 UTC
gstinterpolation.c still has a lot of
iter = g_sequence_get_begin_iter (self->priv->values);
where we don't check that self->priv->values!=NULL.

Regarding that I wonder if we just want to create the sequence when creating the control-source, to avoid the checks.

Then there is code like this:
  iter = g_sequence_get_begin_iter (self->priv->values); \
  cp = g_sequence_get (iter); \
or this
  iter = g_sequence_iter_next (iter); \
  cp = g_sequence_get (iter); \
where we probably need to cehck the iter against NULL :/
Comment 10 Stefan Sauer (gstreamer, gtkdoc dev) 2009-05-24 20:24:44 UTC
Regarding perfromance, its worth it. I added a performance test app in core (test/benchmark controller) and this is the before/after

linear insert of control-points: 0:00:00.491924240
random insert of control-points: 0:00:00.029950985
linear read   of control-points: 0:00:01.618321687

linear insert of control-points: 0:00:00.051068274
random insert of control-points: 0:00:00.000325157
linear read   of control-points: 0:00:00.877610880
Comment 11 Stefan Sauer (gstreamer, gtkdoc dev) 2009-06-01 08:13:36 UTC
I added another test. The cubis interpolation cehck the number of controlpoints and does a fallback to linear if there a re not enough.