Re: big number of relocations in gtk2 binding

On Feb 9, 2008, at 2:49 PM, Torsten Schoenfeld wrote:

Nice. With this applied, I see a 9% size reduction of the shared object (11MiB -> 10MiB, with debugging symbols) and a 7% start speedup (0.067s
-> 0.062s, measured via timing many runs of `perl -MGtk2 -e'exit'´).

I had to add one more closing parentheses at the end of the definition
of __hidden__ to make it compile, though.

D'oh!   That's what i get for editing patch files directly.

If defined, we could use G_GNUC_INTERNAL (from glib >= 2.6).

Good point.  That supports the Sun Pro compiler, too.

I put a new version of the patch at .

Diffstat says:

   213 files changed, 328 insertions(+), 226 deletions(-)

and says:

267 relocations, 228 relative (85%), 3845 PLT entries, 26 for local syms (0%), 0 users

That's 85% versus 76% with the previous patch, and a drop of 3 PLTs. Nearly all of the PLTs are for things from dependent libraries, so there's not much we can do about that.

This patch is slightly more invasive. Move __hidden__ to the beginning, since we prefer G_GNUC_INTERNAL if it's available from GLib. Add include guards to gtk2perlinternal.h. In gtk2perl- private.h, add the hidden attribute to the private-but-shared symbols declared there. Add static to several helper functions which appear to have been missed by oversight. And, the real win, also use hidden visibility in Gtk2.xs, by adding this change to the end of the file:

@@ -626,3 +626,15 @@ bool
 PANGO_CHECK_VERSION (class, int major, int minor, int micro)
        major, minor, micro
+## xsubpp will generate the BOOT section, specifically boot_Gtk2(), after +## this point in the file. We need boot_Gtk2() to be callable from outside +## our .so, so undo the visibility magic before that function is defined.
+#undef __hidden__
+#define __hidden__

Is the optimization worth all these shenanigans? Should we worry about stuff like internal uses of exported functions (e.g. gtk2perl_new_gtkobject(), which is called in ~270 places)?

The Master in the art of living makes little distinction between his work and his play, his labor and his leisure, his mind and his body, his education and his recreation, his love and his religion. He hardly knows which is which. He simply pursues his vision of excellence in whatever he does, leaving others to decide whether he is working or playing. To him he is always doing both.

  -- Zen Philosophy

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