Re: [HACKERS] fork/exec for backend

From: Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us>
To: goran(at)bildbasen(dot)se (Goran Thyni)
Cc: tom(at)sdf(dot)com, hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] fork/exec for backend
Date: 1998-01-25 00:21:55
Message-ID: 199801250021.TAA21698@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>
>
> On 24 Jan 1998, Goran Thyni wrote:
>
> > Fork on modern unices (linux and (a think) *BSD) cost
> > almost nothing (in time and memory) thanks to COW (copy-on-write).
> > Exec in expensive as it breaks COW.
>
> Not so. Modern Unixs will share executable address space between
> processes. So if you fork and exec 10 identical programs, they will share
> most address space.
>
> 1. Code is probably not shared between postmaster and postgres
> processes.

I think it is shared. postmaster is a symlink to postgres, so by the
time it gets to the kernel exec routines, both processes are mapped to
the same inode number.

>
> 2. Some inits may be done once (by postmaster) and not repeated
> by every child.

Maybe.

>
> 3. (and most important)
> With no exec COW is in action, meaning:
> data pages in shared until changed.

This would also prevent us from attaching to shared memory because it
would already be in the address space.

>
> COW is the key to how Linux can fork faster than most unices
> starts a new thread. :-)

>
> Again, this only applies to "modern" systems, but FreeBSD definitely has
> this behaviour.
>
> I don't know if *BSD has COW, but if should think so.

All modern Unixes have COW.

--
Bruce Momjian
maillist(at)candle(dot)pha(dot)pa(dot)us

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 1998-01-25 00:24:18 Re: [HACKERS] fork/exec for backend
Previous Message Rick Poleshuck 1998-01-24 23:08:55 Revoke update on Column