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 632778 - Optimisations to GstBaseSink
Optimisations to GstBaseSink
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
unspecified
Other All
: Normal normal
: 0.10.32
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2010-10-21 09:59 UTC by Edward Hervey
Modified: 2010-12-03 14:16 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
basesink: Switch enable_last_buffer to an atomic int (2.87 KB, patch)
2010-10-21 09:59 UTC, Edward Hervey
committed Details | Review
basesink: Pass along miniobject type through various functions (13.20 KB, patch)
2010-10-21 09:59 UTC, Edward Hervey
committed Details | Review
gstclock: New API to re-use a single shot GstClockID (2.71 KB, patch)
2010-10-21 09:59 UTC, Edward Hervey
committed Details | Review
basesink: Re-using GstClockID instead of constantly recreating one (2.79 KB, patch)
2010-10-21 09:59 UTC, Edward Hervey
committed Details | Review

Description Edward Hervey 2010-10-21 09:59:16 UTC
These patches provide the following optimisations
* Use an atomic integer for checking whether we should store the last_buffer
  or not (instead of taking/releasing a lock for nothing)
* Avoid checking the type of miniobjects again and again
* Avoid creating/destroying GstClockID and instead re-use a cached one
Comment 1 Edward Hervey 2010-10-21 09:59:19 UTC
Created attachment 172911 [details] [review]
basesink: Switch enable_last_buffer to an atomic int

Avoids having to take a lock to read/write it.
Comment 2 Edward Hervey 2010-10-21 09:59:23 UTC
Created attachment 172912 [details] [review]
basesink: Pass along miniobject type through various functions

Avoids doing useless GST_IS_*
Comment 3 Edward Hervey 2010-10-21 09:59:26 UTC
Created attachment 172913 [details] [review]
gstclock: New API to re-use a single shot GstClockID

API: gst_clock_single_shot_id_reinit
Comment 4 Edward Hervey 2010-10-21 09:59:30 UTC
Created attachment 172914 [details] [review]
basesink: Re-using GstClockID instead of constantly recreating one

Makes _sink_wait_clock at least 2 times faster.
Comment 5 Sebastian Dröge (slomo) 2010-10-23 19:33:55 UTC
Review of attachment 172911 [details] [review]:

Looks good

::: libs/gst/base/gstbasesink.c
@@ +238,2 @@
   /* the last buffer we prerolled or rendered. Useful for making snapshots */
+  gint enable_last_buffer;      /* atomic */

Shouldn't this be marked as volatile?
Comment 6 Sebastian Dröge (slomo) 2010-10-23 19:39:47 UTC
Review of attachment 172912 [details] [review]:

::: libs/gst/base/gstbasesink.c
@@ +2221,3 @@
+      obj_type = _PR_IS_EVENT;
+    else if (GST_IS_BUFFER_LIST (obj))
+      obj_type = _PR_IS_BUFFERLIST;

Maybe add a "else g_return_if_reached()" here

@@ +3120,3 @@
+    ret =
+        gst_base_sink_render_object (basesink, pad,
+        GST_IS_BUFFER (o) ? _PR_IS_BUFFER : _PR_IS_EVENT, o);

This could be a bufferlist too here, right?

@@ +3163,3 @@
  * This function takes ownership of obj.
+ *
+ * Note: Only GstEvent seem to be passed to this private method

Maybe add an assertion for this here
Comment 7 Sebastian Dröge (slomo) 2010-10-23 19:40:29 UTC
Review of attachment 172913 [details] [review]:

Looks good, I'll add the same for periodic clock ids after you pushed this :)
Comment 8 Sebastian Dröge (slomo) 2010-10-23 19:42:01 UTC
Review of attachment 172914 [details] [review]:

Looks good but the cache clock id is not unreffed in PAUSED->READY or READY->NULL or finalize or something
Comment 9 Edward Hervey 2010-12-03 14:15:37 UTC
commit ece40dacbc0ae6842e66b2665ee6767b56fa9d39
Author: Edward Hervey <bilboed@bilboed.com>
Date:   Wed Oct 20 17:41:28 2010 +0200

    basesink: Re-using GstClockID instead of constantly recreating one
    
    Makes _sink_wait_clock at least 2 times faster.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=632778

commit b4285611ad177b67dd32c5022b62d255b5cdd5f5
Author: Edward Hervey <bilboed@bilboed.com>
Date:   Wed Oct 20 17:40:43 2010 +0200

    gstclock: New API to re-use a single shot GstClockID
    
    API: gst_clock_single_shot_id_reinit
    
    https://bugzilla.gnome.org/show_bug.cgi?id=632778

commit 7115b77aaba7a49f1a8bf9ba4bbc34c4609ed0c5
Author: Edward Hervey <bilboed@bilboed.com>
Date:   Wed Oct 20 13:52:02 2010 +0200

    basesink: Pass along miniobject type through various functions
    
    Avoids doing useless GST_IS_*
    
    https://bugzilla.gnome.org/show_bug.cgi?id=632778

commit 606e59468dd176a5352961576d4c937751f66b58
Author: Edward Hervey <bilboed@bilboed.com>
Date:   Wed Oct 20 13:08:08 2010 +0200

    basesink: Switch enable_last_buffer to an atomic int
    
    Avoids having to take a lock to read/write it.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=632778