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 437457 - saving relocations for GstElementDetails
saving relocations for GstElementDetails
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
git master
Other Linux
: Normal enhancement
: 0.10.14
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2007-05-10 14:30 UTC by Stefan Sauer (gstreamer, gtkdoc dev)
Modified: 2007-06-22 10:14 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
save relocs for GTypeInfo (4.50 KB, patch)
2007-05-22 06:23 UTC, Stefan Sauer (gstreamer, gtkdoc dev)
committed Details | Review
save relocs caused by GstElementDetails (25.12 KB, patch)
2007-05-22 07:13 UTC, Stefan Sauer (gstreamer, gtkdoc dev)
committed Details | Review

Description Stefan Sauer (gstreamer, gtkdoc dev) 2007-05-10 14:30:46 UTC
replacing this code:

static const GstElementDetails gst_identity_details =
GST_ELEMENT_DETAILS ("Identity",
    "Generic",
    "Pass data without modification",
    "Erik Walthinsen <omega@cse.ogi.edu>");
gst_element_class_set_details (gstelement_class, &gst_identity_details);

with

gst_element_class_set_details_simple (gstelement_class, "Queue",
    "Generic",
    "Simple data queue",
    "Erik Walthinsen <omega@cse.ogi.edu>");

and having this in e.g gstelement.c
void
gst_element_class_set_details_simple (GstElementClass * klass, gchar *longname,
  gchar *classification, gchar *description, gchar *author)
{
  const GstElementDetails details =
    GST_ELEMENT_DETAILS (longname, classification, description, author);

  g_return_if_fail (GST_IS_ELEMENT_CLASS (klass));

  __gst_element_details_copy (&klass->details, &details);
}

saves 4 relocations per GstElementDetails. You can check as below:
readelf -d /usr/lib/gstreamer-0.10/libgstcoreelements.so  | grep REL

For some background please read: http://bugzilla.gnome.org/show_bug.cgi?id=337058
Comment 1 Jan Schmidt 2007-05-21 14:34:33 UTC
It'd be nice to have a patch to try out.
Comment 2 Stefan Sauer (gstreamer, gtkdoc dev) 2007-05-22 06:23:14 UTC
Created attachment 88579 [details] [review]
save relocs for GTypeInfo

This imho is save to apply.
Comment 3 Stefan Sauer (gstreamer, gtkdoc dev) 2007-05-22 07:13:34 UTC
Created attachment 88580 [details] [review]
save relocs caused by GstElementDetails

there is a '#if 0' in there to switch before/after for easy testing. I am not 100% sure about this one. It lowers the number of relocs (as explained in detail on the -devel maling-list), but makes the binary grow also.
Comment 4 David Schleef 2007-05-22 19:08:29 UTC
I'm in favor of this change because it makes the code (IMO) easier to read.  I've always been a bit uncomfortable with using static constructor for something that is easily constructed with a function call.

FWIW, I feel the same way about static pad templates and static caps, too.
Comment 5 Jan Schmidt 2007-05-23 10:14:01 UTC
Because it adds API, I'd like to punt it until after the release, then apply it immediately so we have time to let it settle.
Comment 6 Stefan Sauer (gstreamer, gtkdoc dev) 2007-05-23 13:44:49 UTC
agreed. I marked the patches as commit-after-freeze.
Comment 7 Tim-Philipp Müller 2007-06-19 14:45:23 UTC
I think this can be committed now, no?
Comment 8 Stefan Sauer (gstreamer, gtkdoc dev) 2007-06-21 15:03:35 UTC
2007-06-21  Stefan Kost  <ensonic@users.sf.net>

	* gst/gstelement.c: (gst_element_class_set_details_simple):
	* gst/gstelement.h:
	* gst/gstutils.c: (gst_type_register_static_full):
	* gst/gstutils.h:
	* plugins/elements/gstcapsfilter.c: (gst_capsfilter_base_init):
	* plugins/elements/gstfakesink.c: (gst_fake_sink_base_init):
	* plugins/elements/gstfakesrc.c: (gst_fake_src_base_init):
	* plugins/elements/gstfdsink.c: (gst_fd_sink_base_init):
	* plugins/elements/gstfdsrc.c: (gst_fd_src_base_init):
	* plugins/elements/gstfilesink.c: (gst_file_sink_base_init):
	* plugins/elements/gstfilesrc.c: (gst_file_src_base_init):
	* plugins/elements/gstidentity.c: (gst_identity_base_init):
	* plugins/elements/gstmultiqueue.c: (gst_multi_queue_base_init):
	* plugins/elements/gstqueue.c: (gst_queue_base_init),
	(apply_buffer), (gst_queue_chain):
	* plugins/elements/gsttee.c: (gst_tee_base_init):
	* plugins/elements/gsttypefindelement.c:
	(gst_type_find_element_base_init),
	(gst_type_find_element_class_init):
	  Saving relocations for GTypeInfo and GstElementDetails. Fixes #437457.

Comment 9 Jan Schmidt 2007-06-21 15:33:09 UTC
Sorry, I know you just committed stuff and closed the bug, but I have to ask, because I don't really understand this new API:
  Instead of static const GTypeInfo, we now call a function which pushes the contents of a GTypeInfo onto the stack as arguments, then pulls it off to put 
into a stack allocated GTypeInfo and passes that to g_type_register_static. Wouldn't removing 'static' from the existing GTypeInfo do the same thing?

Comment 10 Stefan Sauer (gstreamer, gtkdoc dev) 2007-06-22 10:02:49 UTC
@Jan, its quick tricky: Here is what happens:

libgstaudiodelay is a plugin with one element, that had the global static const GstElementDetails (before). Next I moved it as a local var into _base_init(). Then I removed static and finally I used the gst_element_class_set_details_simple().

These are the binary sizes:

51029 libgstaudiodelay.before.so*
51035 libgstaudiodelay.local-nonstatic.so*
51035 libgstaudiodelay.local.so*
50972 libgstaudiodelay.simple.so*

> readelf -d libgstaudiodelay.before.so | grep REL
 0x00000002 (PLTRELSZ)                   320 (bytes)
 0x00000012 (RELSZ)                      200 (bytes)
 0x6ffffffa (RELCOUNT)                   21

> readelf -d libgstaudiodelay.local.so | grep REL
 0x00000002 (PLTRELSZ)                   320 (bytes)
 0x00000012 (RELSZ)                      200 (bytes)
 0x6ffffffa (RELCOUNT)                   21

> readelf -d libgstaudiodelay.local-nonstatic.so | grep REL
 0x00000002 (PLTRELSZ)                   320 (bytes)
 0x00000012 (RELSZ)                      200 (bytes)
 0x6ffffffa (RELCOUNT)                   21

> readelf -d libgstaudiodelay.simple.so | grep REL
 0x00000002 (PLTRELSZ)                   320 (bytes)
 0x00000012 (RELSZ)                      168 (bytes)
 0x6ffffffa (RELCOUNT)                   17

Some of the savings in file-size are because now there is no code to initialize the struct and only a little more code for the function call. The savings of reloc-entries is because the struct contains pointers to strings which need to be relocated. It the struct would only contain constant numbers (like a bitrate table) it would be fine.
Comment 11 Jan Schmidt 2007-06-22 10:14:01 UTC
Nicely summarised :)

OK, that explains it well, thanks!