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 459501 - gst_registry_lookup_feature_locked is slow
gst_registry_lookup_feature_locked is slow
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
git master
Other Linux
: Normal normal
: 0.10.14
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2007-07-23 11:20 UTC by Stefan Sauer (gstreamer, gtkdoc dev)
Modified: 2007-07-23 11:42 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
use hashmap to speedup lookups (3.52 KB, patch)
2007-07-23 11:27 UTC, Stefan Sauer (gstreamer, gtkdoc dev)
committed Details | Review

Description Stefan Sauer (gstreamer, gtkdoc dev) 2007-07-23 11:20:11 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.
Comment 1 Stefan Sauer (gstreamer, gtkdoc dev) 2007-07-23 11:27:36 UTC
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
Comment 2 Stefan Sauer (gstreamer, gtkdoc dev) 2007-07-23 11:42:32 UTC
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.