Re: gobject n_preallocs



tom <tom dbservice com> writes:

> Owen Taylor wrote:
> 
> >tom <tom dbservice com> writes:
> >
> >
> >>i  made a improved test... (file below)
> >>
> >>with n_prealloc = 1000:
> >>created:  ~200000
> >>freed: ~1500
> >>
> >>and n_prealloc = 0:
> >>created: ~150000
> >>freed: ~1500
> >>
> >>if you look at this you see that setting n_prealloc even decreases
> >>performance...
> >>
> >
> >Nothing very unexpected about this. n_preallocs makes GObject
> >use GMemChunk, and normal malloc is known to be faster than
> > GMemChunk except on systems with highly broken malloc()
> > implementions.
> >
> >I'd ignore this feature of GObject.
> >
> so for what is GMemChunk implemented in glib?
> or why do you use GMemChunk in glib?

 - It was thought to be faster at the time (7 years ago), 
   and maybe it was, then.

 - ALLOC_ONLY memchunks are quite fast. It's ALLOC_AND_FREE
   memchunks that are slow. All or almost current uses of 
   memchunks in GLib and GTK+ are ALLOC_ONLY.

 - GMemChunk does save a little bit of memory if you
   are allocating a large number of small structures.
   (4 bytes per structure)

Regards,
                                        Owen



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