[Python-Dev] pyparallel and new memory API discussions...

Trent Nelson trent at snakebite.org
Wed Jun 19 18:00:01 CEST 2013


On Wed, Jun 19, 2013 at 08:45:55AM -0700, Victor Stinner wrote:
> >      1. All memory allocated in a parallel context is localized to a
> >         private heap.
> 
> How do you allocate memory in this "private" heap? Did you add new
> functions to allocate memory?

    Yup:
        _PyHeap_Malloc(): http://hg.python.org/sandbox/trent/file/0e70a0caa1c0/Python/pyparallel.c#l2365.

    All memory operations (PyObject_New/Malloc etc) get intercepted
    during parallel thread execution and redirected to _PyHeap_Malloc(),
    which is a very simple slab allocator.  (No need for convoluted
    buckets because we never free individual objects during parallel
    execution; instead, we just blow everything away at the end.)

        Trent.


More information about the Python-Dev mailing list