[Python-Dev] C API for gc.enable() and gc.disable()

Antoine Pitrou solipsis at pitrou.net
Mon Jun 23 12:40:26 CEST 2008


Martin v. Löwis <martin <at> v.loewis.de> writes:
> Currently, only youngest collections are triggered by allocation
> rate; middle and old are triggered by frequency of youngest collection.
> So would you now specify that the youngest collection should occur
> if-and-only-if a new arena is allocated? Or discount arenas returned
> from arenas allocated?

The latter sounds reasonable. IIRC an arena is 256KB, which is less than an 
entry level L2 cache. Therefore waiting for an arena to be filled shouldn't 
deteriorate cache locality a lot.

To avoid situations where the GC is never called we could combine that with an 
allocation counter, but with a much higher threshold than currently.

> Or apply this to triggering other generation
> collections but youngest? How would that help the quadratic behavior
> (which really needs to apply a factor somewhere)?

It would not help the quadratic behaviour - and is orthogonal to your proposal -
, but at least avoid calling the GC too often when lots of small objects are 
allocated (as opposed to lots of large objects).





More information about the Python-Dev mailing list