GObject Private Data

Federico: the combination of a “*priv” field and GObject private data is the best way to go:

struct _PangoFcFont
{
   ...
   gpointer priv;
   ...
};

#define PANGO_FC_FONT_GET_PRIVATE(obj) ((PangoFcFontPrivate *) ((PangoFcFont *) obj)->priv)

static void
pango_fc_font_class_init (PangoFcFontClass *class)
{
  ...
  g_type_class_add_private (object_class, sizeof (PangoFcFontPrivate));
}

static void
pango_fc_font_init (PangoFcFont *fcfont)
{
  fcfont->priv = G_TYPE_INSTANCE_GET_PRIVATE (fcfont, PANGO_TYPE_FC_FONT, PangoFcFontPrivate)
}

Indeed, that’s why g_type_get_private() was added. You get the best of both worlds – the convenience of a priv pointer with the fact that the private data is allocated in the same chunk as the object itself, without the inefficiency of calling get_private() a lot or the extra static variable in Owen‘s original proposal.

LDAP Notifications

Figuring out what the story is with LDAP notifications isn’t terribly easy. There are a number of different protocol extensions out there:

The strangest thing about all this is that LCUP is the only one of these that progressed from Internet Draft to RFC, yet neither OpenLDAP nor Fedora Directory Server implement it. SYNC seems to have been proposed by the OpenLDAP crew because when they went to implement LCUP they found that it “requires server implementations to maintain complete history information in order to provide eventually convergent incremental refreshes”, which presumably wasn’t something that OpenLDAP already did. Yet the working group went ahead and progressed LCUP to RFC and not SYNC.

Anyway, moral of the story is that if you want notifications, then you want PSEARCH if you’re using Fedora Directory Server and SYNC if you’re using OpenLDAP.

If you’re using OpenLDAP’s client library, rather than the Mozilla LDAP C SDK, then it’s a little tricky since you have to manually create the psearch control and parse the entryChange controls. Here’s some example code.

Benchmarking Login Time Improvements

I finally got around to committing some changes to GConf which Lorenzo Colitti’s analysis of GNOME startup time showed would make a considerable improvement to login time. More details here.

The most frustrating part of this is just how difficult it is to get decent, reproducible figures of login time to show the improvements.

I first tried using bootchart to reproduce the results as Lorenzo had done. I hacked up a script to run gdm on a test machine, automatically login as a test user and get a bootchart of the time between gdm starting and the panel finishing loading the applets. I did a number of runs for each of my test cases – unmodified GConf, unmerged tree; unmodified GConf, merged tree; patched GConf, merged tree.

Unmodified Merged Tree Merged Tree, Split Translations

You can see improvements, just as Lorenzo predicted, but annoyingly each run of bootchart varied wildly from others, so you can’t really be sure exactly what difference you’ve made.

Next, I tried a much more low-tech approach. I wrote a script to record a timestamp in a text file in /tmp and ran that script from xinitrc and from the panel (once it had finished loading applets). By making the script reboot once it had recorded the second timestamp, and configuring GDM to login automatically, I could walk away from the machine and let it record a bunch of timings rather than sit there and watch it reboot.

Disappointingly, these results varied quite a bit too. But, by discarding obvious anomalies (note my ignorance of statistical methods) and taking an average, I got:

  • Unmodified GConf – 14.382s
  • Unmodified GConf; merged tree – 13.978s
  • Patched GConf; merged tree – 11.086s

That shows a ~20% improvement in login time, which is certainly promising.

xscope

xscope is so damn useful.

Here’s a patch to make it support the SHAPE extension. It’d be really good to get this thing into freedesktop.org and so people can hack on it to make it sane.

I should try out Soeren’s gtk xscope wrapper.

I’m not sure what’s the best way to build the thing, but if you check it out from keithp’s CVS and do:

$> imake -I/cvs/xorg/config/cf
$> make

then it seems to build just fine if you remove the malloc() prototype in common.c. Of course, if you have a space between the -I and the path to the xorg build on the imake command line, then you could find yourself spending a long time trying to figure out wtf is wrong.

Oh, yeah, one final tip. xscope is a proxy Xserver. So, when you connect your app to xscope, Xlib goes looking in ~/.Xauthority for an xauth cookie to use when authenticating. Because xscope has a different display number from the parent display, though, you need to use xauth to setup the cookie for this display number too. So, assuming the parent display is :0 and xscope is :1, you can do:

$> xauth list | grep '/unix:0' | while read display proto cookie; do xauth add ${display%0}1 $proto $cookie; done