A 'Python like' language
Greg Ewing (using news.cis.dfn.de)
ieyf4fu02 at sneakemail.com
Tue Mar 30 04:32:31 CEST 2004
Mark Hahn wrote:
>>But I wonder what effect the lack of reference counting has
>>on cache-friendliness of the memory management system.
> I don't see how the lack of something could hurt the cache. Do you mean the
> garbage colector?
A running Python program creates and discards certain kinds
of objects (e.g. integers, tuples, stack frames) at a very
high rate. Due to reference counting, the fact that these
objects have been discarded is discovered very quickly, and
their memory released. Subsequent allocations are likely to
re-use the same memory, which is likely to be in cache.
A pure mark-and-sweep system, on the other hand, tends to
keep on allocating fresh memory and letting the garbage
objects pile up until there is no more fresh memory, only
then pausing to reclaim the garbage. This is a very bad
access pattern for cache purposes.
Back when the addition of a mark-and-sweep collector to
Python was being debated, this argument was put forward as
a reason why replacing reference counting with mark-and-sweep
wouldn't obviously be an improvement, and could make things
Python currently has both reference counting *and* mark
and sweep, which sounds redundant, but the combination seems
to work very well.
> The interpreter supports C code calling Prothon code and vice versa.
I don't doubt that it's possible, I was just wondering how
easy it is. Stackless-type systems tend to make this rather
more convoluted than just making a C function call. I'll take
a look at the code some time and find out.
Greg Ewing, Computer Science Dept,
University of Canterbury,
Christchurch, New Zealand
More information about the Python-list