Re: Reasoning behind process instead of thread based

From: Neil Conway <neilc(at)samurai(dot)com>
To: Martijn van Oosterhout <kleptog(at)svana(dot)org>
Cc: Marco Colombo <marco(at)esi(dot)it>, Richard_D_Levine(at)raytheon(dot)com, pgsql-general(at)postgresql(dot)org
Subject: Re: Reasoning behind process instead of thread based
Date: 2004-11-01 15:16:24
Message-ID: 41865348.7070100@samurai.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I don't see the big difference between what Marco is suggesting and user
threads -- or to be more precise, I think user threads and event-based
programming are just two sides of the same coin. A user thread just
represents the state of a computation -- say, a register context and
some stack. It is exactly that *state* that is passed to a callback
function in the event-based model. The only difference is that with user
threads the system manages context for you, whereas the event-based
model lets the programmer manage it. Which model is better is difficult
to say.

Martijn van Oosterhout wrote:
> 1. non-blocking is nice, but lots of OSes (eg POSIX) don't support it
> on disk I/O unless you use a completely different interface.

We could implement I/O via something like POSIX AIO or a pool of worker
threads that do the actual I/O in a synchronous fashion. But yeah,
either way it's a major change.

> 2. If one of your 'processes' decides to do work for half an hour (say,
> a really big merge sort), you're stuck.

It would be relatively easy to insert yield points into the code to
prevent this from occurring. However, preemptive scheduling would come
in handy when running "foreign" code (e.g. user-defined functions in C).

> I honestly don't think you could really do a much better job of
> scheduling than the kernel.

I think we could do better than the kernel by taking advantage of
domain-specific knowledge, I'm just not sure we could beat the kernel by
enough to make this worth doing.

BTW, I think this thread is really interesting -- certainly more
informative than a rehash of the usual "processes vs. threads" debate.

-Neil

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Richard Huxton 2004-11-01 15:49:36 Re: spreading the DB?
Previous Message Joolz 2004-11-01 15:13:43 unique problem