Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #2876

Re: Copy-on-write when forking a python process

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!news2.arglkargh.de!news.wiretrip.org!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <modelnine@modelnine.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'context': 0.04; '(except': 0.05; 'disagree': 0.07; 'semantic': 0.07; 'subject:process': 0.07; 'subject:when': 0.07; 'python': 0.07; "object's": 0.09; 'sysv': 0.09; 'extension': 0.14; 'subject:python': 0.15; '(assuming': 0.16; 'altered': 0.16; 'level,': 0.19; '(which': 0.21; 'header:In- Reply-To:1': 0.22; 'e.g.': 0.22; 'specified': 0.22; '(and': 0.22; 'objects': 0.24; "what's": 0.24; 'memory': 0.24; "didn't": 0.25; 'implementing': 0.25; '(see': 0.26; 'equivalent': 0.26; 'statement': 0.26; 'putting': 0.26; 'object': 0.27; 'shared': 0.29; 'supports': 0.29; 'explicitly': 0.29; 'operating': 0.30; 'implement': 0.30; '---': 0.31; 'parent': 0.31; 'semantics': 0.31; 'child': 0.31; 'to:addr:python-list': 0.32; 'words,': 0.33; 'page': 0.33; 'generally': 0.33; 'thinking': 0.33; 'copying': 0.34; 'reference': 0.34; 'using': 0.34; 'received:192.168.1': 0.34; 'received:192': 0.34; 'there': 0.35; 'returned': 0.35; 'header:User-Agent:1': 0.35; 'copied': 0.35; 'preventing': 0.35; 'space,': 0.35; 'optimization': 0.36; 'received:192.168': 0.37; 'some': 0.37; 'should': 0.37; 'useful': 0.37; 'received:org': 0.38; 'to:addr:python.org': 0.39; 'said': 0.39; 'works': 0.40; 'count': 0.40; 'level.': 0.40; 'allows': 0.40; 'image.': 0.60; 'best': 0.60; 'address': 0.61; 'cow': 0.84; 'schrieb': 0.84; 'subject:write': 0.84; 'that)': 0.84; 'images,': 0.93
DKIM-Signature v=1; a=rsa-sha256; c=simple/simple; d=modelnine.org; s=modelnine1012; t=1302298201; bh=LzWsTSP38IojOzyyMI60BUQh1FfowjxnGsWtfIgMFhY=; h=Message-ID:Date:From:MIME-Version:To:Subject:References: In-Reply-To:Content-Type:Content-Transfer-Encoding; b=hKNGny5dgd5+24NgrX4rpct0tYupxDQKYaM9tSNQx3+yiMBX9dJURCCiGakohnztB nsXE6IA9MQ5XJJqsoFj11iDmp66ZAiApyK8UUrZBndOjkaHdXIllHo2IS1LHSHbeTf 7HX91Tl8ompsz9s7b99m/4w5XtNY3cd1F98EIlNU=
Date Fri, 08 Apr 2011 23:29:55 +0200
From Heiko Wundram <modelnine@modelnine.org>
User-Agent Mozilla/5.0 (Windows; U; Windows NT 6.1; de; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9
MIME-Version 1.0
To python-list@python.org
Subject Re: Copy-on-write when forking a python process
References <BANLkTikxcTsgyK-kDQM6PWFQAScztvFh7w@mail.gmail.com> <mailman.156.1302284140.9059.python-list@python.org> <9c3a5a09-4fdd-4ef1-ab45-713762b86cec@z31g2000vbs.googlegroups.com>
In-Reply-To <9c3a5a09-4fdd-4ef1-ab45-713762b86cec@z31g2000vbs.googlegroups.com>
X-Enigmail-Version 1.1.1
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.163.1302298203.9059.python-list@python.org> (permalink)
Lines 29
NNTP-Posting-Host 82.94.164.166
X-Trace 1302298203 news.xs4all.nl 81479 [::ffff:82.94.164.166]:46835
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:2876

Show key headers only | View raw


Am 08.04.2011 20:34, schrieb jac:
> I disagree with your statement that COW is an optimization for a
> complete clone, it is an optimization that works at the memory page
> level, not at the memory image level.  In other words, if I write to a
> copy-on-write page, only that page is copied into my process' address
> space, not the entire parent image.  To the best of my knowledge by
> preventing the child process from altering an object's reference count
> you can prevent the object from being copied (assuming the object is
> not altered explicitly of course.)

As I said before: COW for "sharing" a processes forked memory is simply
an implementation-detail, and an _optimization_ (and of course a
sensible one at that) for fork; there is no provision in the semantics
of fork that an operating system should use COW memory-pages for
implementing the copying (and early UNIXes didn't do that; they
explicitly copied the complete process image for the child). The only
semantic that is specified for fork is that the parent and the child
have independent process images, that are equivalent copies (except for
some details) immediately after the fork call has returned successfully
(see SUSv4).

What you're thinking of (and what's generally useful in the context
you're describing) is shared memory; Python supports putting objects
into shared memory using e.g. POSH (which is an extension that allows
you to place Python objects in shared memory, using the SysV
IPC-featureset that most UNIXes implement today).

-- 
--- Heiko.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: Copy-on-write when forking a python process Heiko Wundram <modelnine@modelnine.org> - 2011-04-08 19:26 +0200
  Re: Copy-on-write when forking a python process jac <john.theman.connor@gmail.com> - 2011-04-08 11:34 -0700
    Re: Copy-on-write when forking a python process Heiko Wundram <modelnine@modelnine.org> - 2011-04-08 23:29 +0200
      Re: Copy-on-write when forking a python process jac <john.theman.connor@gmail.com> - 2011-04-12 14:13 -0700

csiph-web