GNOME Bugzilla – Bug 459501
gst_registry_lookup_feature_locked is slow
Last modified: 2007-07-23 11:42:32 UTC
The registry has an unsorted list for all the feature. Whenever adding features, it checks for an existing feature of the same name. This is slow. For n features it does n*(n-1)/2 string comparission. For 1000 feature its half million strcmp operations. The attached patch uses a hashmap in addition to the list to speedup the lookups.
Created attachment 92196 [details] [review] use hashmap to speedup lookups I run this with registry removed and inplace. time gst-inspect >/dev/null = before = real 0m0.768s user 0m0.628s sys 0m0.084s real 0m0.781s user 0m0.648s sys 0m0.084s real 0m0.816s user 0m0.660s sys 0m0.080s real 0m0.098s user 0m0.060s sys 0m0.008s real 0m0.090s user 0m0.052s sys 0m0.008s real 0m0.080s user 0m0.044s sys 0m0.016s = after = samples % image name symbol name 153 25.8883 libgstreamer-0.10.so.0.12.0 gst_registry_lookup_feature_locked 63 10.6599 libgstreamer-0.10.so.0.12.0 _gst_plugin_feature_filter_plugin_name 56 9.4755 libgstreamer-0.10.so.0.12.0 .plt 29 4.9069 libgstreamer-0.10.so.0.12.0 gst_filter_run 17 2.8765 libgstreamer-0.10.so.0.12.0 __i686.get_pc_thunk.bx 17 2.8765 libgstreamer-0.10.so.0.12.0 gst_value_serialize 12 2.0305 libgstreamer-0.10.so.0.12.0 gst_registry_lookup_locked 12 2.0305 libgstreamer-0.10.so.0.12.0 gst_structure_to_string real 0m0.749s user 0m0.644s sys 0m0.068s real 0m0.765s user 0m0.636s sys 0m0.084s real 0m0.783s user 0m0.632s sys 0m0.060s real 0m0.074s user 0m0.040s sys 0m0.008s real 0m0.098s user 0m0.060s sys 0m0.008s real 0m0.075s user 0m0.040s sys 0m0.016s samples % image name symbol name 73 16.7816 libgstreamer-0.10.so.0.12.0 _gst_plugin_feature_filter_plugin_name 53 12.1839 libgstreamer-0.10.so.0.12.0 gst_filter_run 29 6.6667 libgstreamer-0.10.so.0.12.0 .plt 21 4.8276 libgstreamer-0.10.so.0.12.0 __i686.get_pc_thunk.bx 15 3.4483 libgstreamer-0.10.so.0.12.0 gst_registry_lookup_locked 14 3.2184 libgstreamer-0.10.so.0.12.0 gst_value_serialize 12 2.7586 libgstreamer-0.10.so.0.12.0 gst_structure_parse_simple_string 10 2.2989 libgstreamer-0.10.so.0.12.0 gst_registry_binary_read_cache 9 2.0690 libgstreamer-0.10.so.0.12.0 __gst_element_details_copy 9 2.0690 libgstreamer-0.10.so.0.12.0 gst_structure_to_string
2007-07-23 Stefan Kost <ensonic@users.sf.net> * gst/gstregistry.c: (gst_registry_init), (gst_registry_finalize), (gst_registry_remove_features_for_plugin_unlocked), (gst_registry_add_feature), (gst_registry_remove_feature), (gst_registry_lookup_feature_locked): * gst/gstregistry.h: Speed up gst_registry_lookup_feature_locked() by using a hashmap. Fixes #459501.