[Python-ideas] Extending language syntax
Chris Angelico
rosuav at gmail.com
Tue Nov 12 23:52:36 CET 2013
On Wed, Nov 13, 2013 at 9:42 AM, Charles-François Natali
<cf.natali at gmail.com> wrote:
> That would probably work. The only remaining question is whether it'll
> actually yield a performance gain: as soon as you have more than one
> thread in the interpreter (even if it's idle), you'll end up doing
> atomic incref/decref all over the place, which will just kill
> performance (and will likely degrade with the number of threads
> because of increased contention to e.g. lock the memory bus).
> Atomic refcount just doesn't scale...
There was a proposal put together in Pike involving multiple arenas,
some of which were thread-local and some global. If you have one arena
for each thread, which handles refcounted objects without
thread-safety, and another pool of frozen objects that don't need to
be refcounted at all (at the cost of not ever removing them from
memory), then the only objects that need atomic incref/decref are the
ones that are actually (potentially) shared. There just needs to be
some mechanism for moving an object from the thread-local arena to the
shared one, which would be a relatively uncommon operation.
ChrisA
More information about the Python-ideas
mailing list