GNOME Bugzilla – Bug 684006
Make gstreamermm initialize faster
Last modified: 2012-09-17 20:40:55 UTC
Hi. In an e-mail discussion[1] on the GStreaer-devel list, the speed of initialization of the gstreamermm library was discussed and I discovered that it's most probably due to the fact that Gst::init() loads all the plug-ins that are wrapped to get their GTypes and then register their wrap_new() functions. [1] Since it is not possible to get any plug-in types from C code I think it's safe to remove the registration of the wrap_new() functions because these would be used only if a C type was created with the C API and someone tried to wrap it using a Glib::wrap() method and creating a plug-in type is just not possible with the C API. The patch to follow modifies gstreamermm so that Gst::wrap_init() does not register a wrap_new() function for plug-ins, thus reducing initialization significantly because the plug-ins are not pre-loaded but instead loaded when one is created. The patch relies on another patch which modifies glibmm's generate_wrap_init.pl script. That patch will also be attached. I think this will make gstreamermm faster to initialize, thus better for those that need a fast loading library.
Here's the discussion link: [1] http://lists.freedesktop.org/archives/gstreamer-devel/2012-September/037199.html
Created attachment 224301 [details] [review] gstreamermm patch to speed up initialization.
Created attachment 224302 [details] [review] glibmm patch to modify generate_wrap_init.pl to allow classes in files to not be registered.
Actually, there's a way for the plug-in types to not be registered in the wrap_init() function but then be registered later both when a new C++ of the plug-in is created and just before trying to wrap a C type of the plug-in should one be attained somehow. This would reduce startup up time and keep the wrapping system working as if the plug-in types had been registered. The updated patches will follow.
Created attachment 224359 [details] [review] glibmm patch to modify generate_wrap_init.pl to allow classes in files to not be registered.
Created attachment 224360 [details] [review] glibmm patch to allow _CLASS_GOBJECT classes to have custom Glib::wrap() functions.
Created attachment 224361 [details] [review] gstreamermm patch to speed up initialization.
Created attachment 224371 [details] [review] gstreamermm patch to speed up initialization. Updated because the custom Glib::wrap() functions of the plug-ins should call the plug-in *_get_type() functions which already do the registration and not use Glib::wrap_register() directly because it may cause the type to be registered more than once (when a C++ object is created and if the Glib::wrap() function is called).
Committed the patches to both glibmm and gstreamermm because they seem reasonable to get gstreamermm to load faster: http://git.gnome.org/browse/glibmm/commit/?id=1758d24a4fb494ea1e403c817758023216c0a93a http://git.gnome.org/browse/glibmm/commit/?id=7aa56b64d313241495b3f45a853f784036718426http://git.gnome.org/browse/gstreamermm/commit/?id=648b89f5fe715c7c96a5824df999e9f2acb6f220
The correct commit links are: http://git.gnome.org/browse/glibmm/commit/?id=1758d24a4fb494ea1e403c817758023216c0a93a http://git.gnome.org/browse/glibmm/commit/?id=7aa56b64d313241495b3f45a853f784036718426 http://git.gnome.org/browse/gstreamermm/commit/?id=648b89f5fe715c7c96a5824df999e9f2acb6f220