GNOME Bugzilla – Bug 731756
gstvalue: Speed up gst_value_intersect/_subtract
Last modified: 2014-06-19 05:23:54 UTC
Both gst_value_intersect and gst_value_subtract will call gst_value_compare if one of their arguments isn't a list. gst_value_compare will then re-do a check to see if one of the arguments is a list (for the special case of comparing a unitary value with a list of length 1). The problem is that the various G_VALUE_HOLDS represent an expensive amount of calling gst_value_compare (almost half of it) to see if the provided arguments are list. These checks can be done without when we know that the arguments aren't lists. * Create a new "pure" gst_value_compare which avoids that special case comparision Benchmarks: valgrind/callgrind: average speedup in instruction calls for gst_value_intersect and gst_value_subtract is around 56% (Makes 63% of the calls it used to take previously) tests/benchmarks/capsnego: With default settings (depth 4, children 3 607 elements), time taken for transition from READY to PAUSED: Before : 00.391519153 After : 00.220397492 56% of the time previously used, +77% speedup
Created attachment 278569 [details] [review] gstvalue: Speed up gst_value_intersect/_subtract
Go for it, but it sounds a bit odd that a bunch of GType comparisons (those are non-subclassable fundamental types, so it should be really cheap) is so expensive. But then there's the G_IS_VALUE() as well I guess. Maybe call it _nolist() though or _internal() ? 'pure' usually means something else and it's not clear how that applies more to the stripped down compare function than to the public one.
it's the G_VALUE_HOLDS which is expensive actually. That calls g_type_check_value_holds() which is expensive :( I'll rename it to _nolist()
Attachment 278569 [details] pushed as b0b20b4 - gstvalue: Speed up gst_value_intersect/_subtract
Created attachment 278623 [details] [review] gtype: G_VALUE_HOLDS optimisation for case where types are different How about this? Takes off another 15-20% for me here.
Let's open a glib bug for that one ?