From: | Andres Freund <andres(at)anarazel(dot)de> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Cc: | Robert Haas <robertmhaas(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, HeikkiLinnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com> |
Subject: | Re: profiling connection overhead |
Date: | 2010-11-24 21:28:43 |
Message-ID: | 201011242228.44011.andres@anarazel.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Wednesday 24 November 2010 22:18:08 Robert Haas wrote:
> On Nov 24, 2010, at 4:05 PM, Andres Freund <andres(at)anarazel(dot)de> wrote:
> >>> Won't this just cause loads of additional pagefaults after fork() when
> >>> those pages are used the first time and then a second time when first
> >>> written to (to copy it)?
> >>
> >> Aren't we incurring those page faults anyway, for whatever memory
> >> palloc is handing out? The heap is no different from bss; we just
> >> move the pointer with sbrk().
> >
> > Yes, but only once. Also scrubbing a page is faster than copying it...
> > (and there were patches floating around to do that in advance, not sure
> > if they got integrated into mainline linux)
> I'm not following - can you elaborate?
When forking the memory mapping of the process is copied - the actual pages
are not. When a page is first accessed the page fault handler will setup a
mapping to the "old" page and mark it as shared. When now written to it will
fault again and copy the page.
In contrast if you access a page the first time after an sbrk (or mmap, doesn't
matter) a new page will get scrubbed and and a mapping will get setup.
Andres
From | Date | Subject | |
---|---|---|---|
Next Message | Andres Freund | 2010-11-24 21:30:07 | Re: profiling connection overhead |
Previous Message | Tom Lane | 2010-11-24 21:25:45 | Re: profiling connection overhead |