Re: avoiding relocations in type registration

On Mon, 3 Apr 2006, Matthias Clasen wrote:

Sorry mitch, forgot to cc you. Here is mail I sent to Tim.

Hey Tim,

we discussed this on irc a bit, the static const GTypeInfo structs used
for g_type_register_static cause quite a few relocations, and also, in
90% of the cases, most of the structs is always the same. The cost of
relocations can in most cases alleviated by prelink (though
LD_DEBUG=statistics shows me that prelink is not as reliable as one
might hope, at least on ix86. Jakub tells me this is due to the kernel
mapping the vDSO in an area that conflicts with prelinked libraries...).

Here is a proposal to avoid the use of a static const struct (see the
attached patch):

g_type_register_static_simple (GType             parent_type,
			       const gchar      *type_name,
                              guint16           class_size,

can you make this a guint instead?

                              GClassInitFunc    class_init,
                              guint16           instance_size,

and this? i don't think restricting to guint16 here really buys us anything.

                              GInstanceInitFunc instance_init,
                              GTypeFlags        flags);

The current trivial implementation fills a GTypeInfo struct on the
stack, but it should be possible to avoid the use of a struct

you mean inside g_type_register_static_simple? i don't see what's
wrong with the way you did it, i'd leave it as that.

When doing this conversion for a single type in GTK+,
I see .text grow by 16 bytes, while .data shrinks by 62, so it
should be an overall win.

yeah, considerably even since .text is ro and shared.
thanks Matthias, can you commit this please? provided
it's properly tested.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]