On Thu, Sep 7, 2017 at 5:15 PM Nathaniel Smith <n...@pobox.com> wrote:

> On Thu, Sep 7, 2017 at 4:23 PM, Nick Coghlan <ncogh...@gmail.com> wrote:
> > The gist of the idea is that with subinterpreters, your starting point
> > is multiprocessing-style isolation (i.e. you have to use pickle to
> > transfer data between subinterpreters), but you're actually running in
> > a shared-memory threading context from the operating system's
> > perspective, so you don't need to rely on mmap to share memory over a
> > non-streaming interface.
>
> The challenge is that streaming bytes between processes is actually
> really fast -- you don't really need mmap for that. (Maybe this was
> important for X11 back in the 1980s, but a lot has changed since then
> :-).) And if you want to use pickle and multiprocessing to send, say,
> a single big numpy array between processes, that's also really fast,
> because it's basically just a few memcpy's. The slow case is passing
> complicated objects between processes, and it's slow because pickle
> has to walk the object graph to serialize it, and walking the object
> graph is slow. Copying object graphs between subinterpreters has the
> same problem.
>

This doesn't match up with my (somewhat limited) experience. For example,
in this table of bandwidth estimates from Matthew Rocklin (CCed), IPC is
about 10x slower than a memory copy:
http://matthewrocklin.com/blog/work/2015/12/29/data-bandwidth

This makes a considerable difference when building a system do to parallel
data analytics in Python (e.g., on NumPy arrays), which is exactly what
Matthew has been working on for the past few years.

I'm sure there are other ways to avoid this expensive IPC without using
sub-interpreters, e.g., by using a tool like Plasma (
http://arrow.apache.org/blog/2017/08/08/plasma-in-memory-object-store/).
But I'm skeptical of your assessment that the current multiprocessing
approach is fast enough.
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to