Re: instance-private-data issue
- From: Mathieu Lacage <mathieu_lacage myrealbox com>
- To: Owen Taylor <otaylor redhat com>
- Cc: gtk-devel-list gnome org, timj gtk org
- Subject: Re: instance-private-data issue
- Date: 05 Aug 2003 10:00:57 +0200
Le lun 04/08/2003 à 12:48, Owen Taylor a écrit :
> > > So, how do we fix the problem? Two ideas I can come up with:
> > >
> > > - increase GTypeInstance from 4 bytes to 8 bytes (on
> > > 32 bits), caching the real type *before* the public g_class field.
>
> Actually, it's from 4 bytes to 12 bytes since the result of
> g_type_create_instance() needs to be maximally aligned - e.g,
> so we can do;
>
> struct MyA
> {
> GObject parent_instance;
> gdouble foo;
> };
>
> > > - Use thread-private data to keep track of a stack of
> > > currently-being-initialized objects with their real types, and
> > > have g_type_instance_get_private() check that.
> > >
> >
> > I'd go for the thread-private stack: increasing the GTypeInstance size
> > feels like unneeded overhead at all times when there is need only for
> > specific overhead at one point in time (ie: initialization).
> >
> > However, the cost in terms of additional implementation complexity might
> > not be worth it (given the beauty of the current codebase, it might be
> > worth not trying to make it any more beautiful :). Are there really
> > people around who rely on being able to create thousands of small GTypes
>
> My concern is not beauty, but rather efficiency; looking up a
> thread-private data key isn't free (*), and
> g_type_instance_get_private()
> is intended to be just a few cycles. That already isn't the
> really the case, which is why we are putting ->priv pointers into new
> Gtk types, but I'm a little reluctant to make it worse.
Why did you started to do this ? Is it because it was too slow ? Did you
have any specific scenario usage which felt really badly slow ?
I must say I don't see the point of having private instance pimples in
GType and not using them in GTK+.
>
> Some timing is probably needed here.
I'll just repeat what I said: it feels like a very bad idea to trade
memory at all times for speed at one time. I must say I never expected
myself that g_type_instance_get_private would be just a few cycles long.
Is this something you see on your profiles ?
>
> The other advantage of the "bloat GTypeInstance" approach is that
> this may not be the only problem of the form "G_TYPE_FROM_INSTANCE()
> produces unexpected results in instance_init()".
My personal god (namely Darin) would laugh at me if I tried to justify a
patch with a sentence including the word "may".
Mathieu
--
Mathieu Lacage <mathieu gnu org>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]