Go forward in time to February 2006.
Dave Jones just posted the first pass of his boot/login analysis. Awesome, awesome stuff. I must admit that this got me a lot more excited than a lot of the dtracing that has been going on ;)
The systemtap dudes are at it, too.
Tuomas has empirically validated the famous R.M.L. conjecture on the futility of CPU-focused optimizations:
As processor speed increases, the time spent in I/O approaches 100% of total execution time, until all processes are fully I/O bound.
Mark: Indeed, the combination of a *priv field and GObject private data is what we ended up using in PangoFcFont.
Before my patch, the public PangoFcFont looked like this:
struct _PangoFcFont
{
PangoFont parent_instance;
FcPattern *font_pattern; /* fully resolved pattern */
PangoFontMap *fontmap; /* associated map */
gpointer context_key; /* used internally */
PangoMatrix matrix; /* used internally */
PangoFontDescription *description;
GSList *metrics_by_lang;
guint is_hinted : 1;
guint is_transformed : 1;
};
That structure had no padding fields for extensions, so it wouldn't have been posible to simply add a *priv field. But after reading the Pango code, I found that the context_key field is really only used internally, and it really doesn't make sense to access it from the outside, since it is an opaque token. So, I did this:
Move "gpointer context_key" to PangoFcFontPrivate. Add a setter/getter for that field; change the relevant code to use them.
In the public PangoFcFont, replace "gpointer context_key" with "gpointer priv".
Simply allocate PangoFcFontPrivate with g_new(), and stuff it into the priv field in the instance_init() method.
Some misguided souls, lured by the siren call of exotic APIs, replaced my scheme by what you describe: use g_type_class_add_private() in class_init(), use G_TYPE_INSTANCE_GET_PRIVATE() in instance_init() to get a pointer to the private area, and stuff that pointer in the priv field. Let's compare both schemes.
| g_new() and priv | g_type_class_add_private() and priv | |
|---|---|---|
| Code changes |
|
|
| New APIs to learn | NONE | g_type_class_add_private(), G_TYPE_INSTANCE_GET_PRIVATE() |
Summary: In this case, we got lucky because we actually had room for a priv field in the public structure. If we hadn't had that luxury, we wouldn't have been able to make the optimization to bring pango_fc_font_get_glyph() from being 8% of the benchmark's time to just over 1%.
Pvanhoof: note that blindly using G_TYPE_INSTANCE_GET_PRIVATE() can lead to performance problems if you use it in a critical code path.
Since the dawn of time, the GNOME Programming Guidelines have recommended that you use a "*priv" field in your objects to point to the private data. This is perfect when implementing new APIs, since you can plan in advance and have a *priv since the beginning.
G_TYPE_INSTANCE_GET_PRIVATE() and friends were added to make it easier to add private data to existing APIs which cannot be changed and do not have *priv fields already. When you register a new GType, you can call g_type_class_add_private() to tell GType, "when instantiating an object of this type, also allocate a chunk of a certain size, which I'll access with G_TYPE_INSTANCE_GET_PRIVATE() when I need it".
This is is pretty useful, but consider how G_TYPE_INSTANCE_GET_PRIVATE() has to be implemented. Remember that you call it like this:
MyPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (my_obj, MY_OBJECT_TYPE, MyPriv);
So, we end up doing this:
MY_OBJECT_TYPE is my_object_get_type(), which is a function call.
Get the class of the my_obj instance. Get the type from the class. Do a type lookup for the metadata of that type, so that we can find the size of MyObj without taking the private data into account.
Look up the type metadata for MY_OBJECT_TYPE.
Get the offset of the private data chunk as specified in the metadata. This offset is then added to to my_obj and the size from (2).
And *then* you can dereference the pointer to the private data. This is a lot more work than having a *priv field in the first place: g_type_instance_get_private() compiles to a few hundred instructions, while "myobj->priv>some_private_field" is trivial.
Yesterday Hans Petter and I flew to Boston. A girl was dragging a huge, freaky doll around the Mexico City airport.
And they give you trouble if you try to carry a pocket knife. Anyway, after some running in the Houston airport due to slow lines at immigration, and an uneventful flight, we arrived to the North Pole. Temperature, -5°C.
We dropped our stuff at the hotel and went for dinner. Pho Pasteur is a wonderful place in Harvard Square. We had a rich soup with noodles and meat — great for the cold — and a pot where you boil thin slices of meat along with chunks of pineapple. You then put the cooked meat in rice paper, add some fresh herbs, and a delicious peanut-based hot sauce. Eating such a Vietnamese taco with chopsticks is tricky.
How cold is it in Boston? It was about -10°C by the time we came out of the restaurant. Humidity freezes on the inside of the hotel's bedroom windows.
Smoke-testing the GNOME 2.13.4 release
With much help from Elijah and Vincent, today I prepared the GNOME 2.13.4 release. I did some quick smoke-testing, and some things came up.
Look and feel
|
Stock, blank desktop is boring. Window title is too blue. Controls are too gray. Plain black foot in menu bar? Color/shade it somehow? Spacing between foot and "Applications" is the same as the space between the other menu items. So, the foot looks like a different item than "Applications". Gray-bluish background is boring. Photo contest? Panel tooltips for menu, launchers are instantaneous. They should have the normal delay. |
|
|
Nothing in notification area; it just appears as a drawing glitch. |
|
|
Nothing in initial window list; handle appears as a drawing glitch. |
|
|
Window menu icon has a visible break with the rest of the panel. |
|
|
Clearlooks doesn't seem to have a "resize grip" in the status bar, yet I can resize from that spot. |
|
|
Menu bar gradient breaks off with window frame. |
|
|
Close "X" in window manager menu is too thin. |
|
Bugs:
Clearlooks has a drawing glitch in scrollbars: bug #325818.
Gucharmap - doesn't display your own script at startup: bug #311912.
Gedit File/Quit is disabled if all documents are closed: bug #325814.
Gnome-settings-daemon didn't exit upon logout while the X server was still up. Normally it gets killed when X dies, but it should exit by itself anyway.
Gnome-screenshot's UI is plain weird. If I must pick a file, why not use a full-fledged file chooser rather than the current combination of GtkEntry+GtkFileChooserButton? Also, GtkFileChooserButton displays "Home" instead of your $HOME name, in inconsistent fashion with GtkFileChooser and Nautilus: bug #325817.
Go backward in time to December 2005.
Federico Mena-Quintero <federico@gnome.org> Wed 2006/Jan/04 19:13:15 CST