Skip to content

GstValue various optimizations

Edward Hervey requested to merge bilboed/gstreamer:gstvalue-inline into master

Also part of #519

gstvalue: Inline GstValueList/GstValueArray

This tries to inline as much as possible array/list and its contents
in order to avoid double allocation/freeing. This also improves the
locality of data.

The internal value is still API/ABI compatible with the *public*
GArray structure. This allows READ-ONLY backwards compatibility with
any external users that assume that the content of a list/array value
is backed by a GArray.

gstvalue: Optimize some list<=>list functions

For subtracting a list from another, the previous implementation would
do a double subtraction of one from another (which would create temporary
arrays/values which would then be discarded). Instead iterate and do
the comparision directly.

For intersecting a list with another, we can directly iterate both at
once and therefore avoid doing a *full* check of all values of the list
against all other values of the list.

capsnego benchmark

time taken (average of 3 runs)

time ./build/subprojects/gstreamer/tests/benchmarks/capsnego

before after diff speedup
reached PAUSED state 3.3368 2.2224 1.1144 x 1.5

heaptrack memory usage

heaptrack ./build/subprojects/gstreamer/tests/benchmarks/capsnego

before after diff % of before
allocations 89 122 840 45 361 784 43 761 056 49
temporary allocations 33 564 22 492 11 072 33
peak heap memory consumption 17.5 MB 15.9 MB 1.6MB 91

crazy video capsnego

time taken (average of 3 runs)

GST_UPDATE_REGISTRY=no time gst-launch-1.0 videotestsrc num-buffers=1 ! { 42 x videoconvert } ! autovideosink

before after diff speedup
user 7.16 0.8 6.36 x 8.9
system 0.02 0.01
elapsed 7.3 0.94 6.36 x7.8

heaptrack memory usage

GST_UPDATE_REGISTRY=no heaptrack gst-launch-1.0 videotestsrc num-buffers=1 ! { 42 x videoconvert } ! autovideosink

before after diff % of before
allocations 4 292 406 4 137 447 154959 3.6
temporary allocations 7 328 5 880 1448 20
peak heap memory consumption 3.5 MB 3.5 MB
Edited by Edward Hervey

Merge request reports