gstvalue: No longer store same-type intersection functions in table
The intersection function table is a legacy of 2005, when one could register random intersection functions. This is no longer the case.
The only place where that table was used was:
-
gst_value_can_intersect()
, where it was already only used for identical GType -
gst_value_intersect()
, where the table iteration was insanely expensive
Instead this patch:
- Only stored intersection functions for different types (of which there are only 4)
- Make gst_value_intersect directly call the same-type intersection functions and only use the table if ever it doesn't match.
Before patch
capsnego benchmark
audio | video | |
---|---|---|
Reached PAUSED state (50 loops) | 2.209 s | 3.694 s |
valgrind --tool=callgrind ./build/subprojects/gstreamer/tests/benchmarks/capsnego -l 10
- Note:
gst_value_intersect
is the outer call (generally calling list intersection) andgst_value_intersect'2
is the inner one (doing non-list intersection).
Incl | Self | Called | Incl/call | Self/Call | % self vs incl | |
---|---|---|---|---|---|---|
audio: gst_value_intersect | 6 731 882 733 | 126 159 695 | 2 624 965 | 2565 | 48 | 1.87 % |
audio: gst_value_intersect'2 | 5 228 500 433 | 2 296 479 673 | 17 196 707 | 304 | 134 | 44.1 % |
video: gst_value_intersect | 9 607 127 010 | 54 215 320 | 910 230 | 10555 | 60 | 0.6 % |
video: gst_value_intersect'2 | 6 757 389 844 | 2 411 092 990 | 19 390 680 | 348 | 124 | 35.6 % |
With patch
capsnego benchmark
audio | video | |
---|---|---|
Reached PAUSED state (50 loops) | 2.099 s | 3.6028 s |
valgrind --tool=callgrind ./build/subprojects/gstreamer/tests/benchmarks/capsnego -l 10
Incl | Self | Called | Incl/call | Self/Call | % self vs incl | |
---|---|---|---|---|---|---|
audio: gst_value_intersect | 5 655 920 083 | 128 756 619 | 2 620 240 | 2159 | 49 | 2.3 % |
audio: gst_value_intersect'2 | 4 151 869 777 | 1 227 020 741 | 17 171 029 | 242 | 71 | 29.3 % |
video: gst_value_intersect | 8 536 757 174 | 61 847 040 | 910 230 | 9378 | 68 | 0.7 % |
video: gst_value_intersect'2 | 5 698 731 871 | 1 344 703 050 | 19 390 680 | 294 | 69 | 23.5 % |
Difference
Reached PAUSED state (50 loops) | Before | After | Savings |
---|---|---|---|
audio | 2.209 s | 2.099 s | 5 % |
video | 3.694 s | 3.603 s | 2.5 % |
Average Inst. per call | Before | After | Savings |
---|---|---|---|
audio: intersect | 2565 | 2159 | 15.8 % |
video: intersect | 10555 | 9378 | 11.2 % |