WIN32 native ... lets start?!?

Started by Joerg Hessdoerferalmost 24 years ago159 messageshackers
Jump to latest
#1Joerg Hessdoerfer
Joerg.Hessdoerfer@sea-gmbh.com

Hi all,

I followed the various threads regarding this for some time now. My current
situation is:

I'm working at a company which does industrial automation, and does it's own
custom products. We try to be cross-platform, but it's a windoze world, as
far as most measurement devices or PLCs are concerned. We also employ
databases for various tasks (including simple ones as holding configuration
data, but also hammering production data into it at a rate of several hundred
records/sec.)
Well, we would *love* to use PostgreSQL in most our projects and products,
(and we do already use it in some), because it has proven to be very reliable
and quite fast.

So, I'm faced with using PostgreSQL on windows also (you can't always put a
Linux box besides). We do this using cygwin, but it's a bit painful ;-)
(although it works!).

Thinking about the hreads I read, it seems there are 2 obstacles to native PG
on W:

1.) no fork,
2.) no SYSV IPC

Ok, 1.) is an issue, but there's a fork() in MinGW, so it's 'just' going to
be a bit slow on new connections to the DB, right?? But this could be sorted
out once we *have* a native WIN32 build.

The second one's a bit harder, but... I'm currently trying to find time to do
a minimal implementation of SYSV IPC on WIN32 calls, just enough to get PG up
(doesn't need msg*() for example, right?).
As far as I understand it, we would not need to have IPC items around *after*
all backends and postmaster have gone away, or? Then there's no need for a
'daemon' process like in cygwin.

So, my route would be to get it to run *somehow* without paying attention to
speed and not to change much of the existing code, THEN see how we could get
rid of fork() on windows.

What do you guys think? Anyone up to join efforts? (I'll start the IPC thingy
anyway, as an exercise, and see where I'll end).

Greetings,
Joerg

P.s.: thanks for a great database system!!
--
Leading SW developer - S.E.A GmbH
Mail: joerg.hessdoerfer@sea-gmbh.com
WWW: http://www.sea-gmbh.com

#2The Hermit Hacker
scrappy@hub.org
In reply to: Joerg Hessdoerfer (#1)
Re: WIN32 native ... lets start?!?

Actually, take a look at the thread starting at:

http://archives.postgresql.org/pgsql-hackers/2002-05/msg00665.php

Right now, IMHO, the big show stopper is passing global variables to the
child processes in Windows ... the above thread talks about a method of
pulling together the global variables *cleanly* that Tom seems to feel
wouldn't add much in the way of long term maintenance headaches ... *and*,
as I understand it, would provide us with a means to use threading in
future developments if deemed appropriate ...

From what I read by those 'in the know' about Windows programming, if we
could centralize the global variables somewhat, using CreateProcess in
Windows shouldn't be a big deal, eliminiating the whole fork() headache
...

On Thu, 16 May 2002, Joerg Hessdoerfer wrote:

Show quoted text

Hi all,

I followed the various threads regarding this for some time now. My current
situation is:

I'm working at a company which does industrial automation, and does it's own
custom products. We try to be cross-platform, but it's a windoze world, as
far as most measurement devices or PLCs are concerned. We also employ
databases for various tasks (including simple ones as holding configuration
data, but also hammering production data into it at a rate of several hundred
records/sec.)
Well, we would *love* to use PostgreSQL in most our projects and products,
(and we do already use it in some), because it has proven to be very reliable
and quite fast.

So, I'm faced with using PostgreSQL on windows also (you can't always put a
Linux box besides). We do this using cygwin, but it's a bit painful ;-)
(although it works!).

Thinking about the hreads I read, it seems there are 2 obstacles to native PG
on W:

1.) no fork,
2.) no SYSV IPC

Ok, 1.) is an issue, but there's a fork() in MinGW, so it's 'just' going to
be a bit slow on new connections to the DB, right?? But this could be sorted
out once we *have* a native WIN32 build.

The second one's a bit harder, but... I'm currently trying to find time to do
a minimal implementation of SYSV IPC on WIN32 calls, just enough to get PG up
(doesn't need msg*() for example, right?).
As far as I understand it, we would not need to have IPC items around *after*
all backends and postmaster have gone away, or? Then there's no need for a
'daemon' process like in cygwin.

So, my route would be to get it to run *somehow* without paying attention to
speed and not to change much of the existing code, THEN see how we could get
rid of fork() on windows.

What do you guys think? Anyone up to join efforts? (I'll start the IPC thingy
anyway, as an exercise, and see where I'll end).

Greetings,
Joerg

P.s.: thanks for a great database system!!
--
Leading SW developer - S.E.A GmbH
Mail: joerg.hessdoerfer@sea-gmbh.com
WWW: http://www.sea-gmbh.com

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo@postgresql.org)

#3Hannu Krosing
hannu@tm.ee
In reply to: Joerg Hessdoerfer (#1)
Re: WIN32 native ... lets start?!?

On Thu, 2002-05-16 at 13:47, Joerg Hessdoerfer wrote:

So, my route would be to get it to run *somehow* without paying attention to
speed and not to change much of the existing code, THEN see how we could get
rid of fork() on windows.

Getting it to compile and then "somehow" run on MinGW seems a good first
step on road to full native Win32 PG.

----------
Hannu

In reply to: Joerg Hessdoerfer (#1)
Re: WIN32 native ... lets start?!?

On Thu, 2002-05-16 at 13:47, Joerg Hessdoerfer wrote:

So, my route would be to get it to run *somehow* without paying
attention to speed and not to change much of the existing code,
THEN see how we could get rid of fork() on windows.

What is the biggest problem here?
The Shmem/IPC stuff, or the fork() stuff?
I'm think that we could do a fork() implementation in usermode by copying the memory allocations.
How fast that would be regarding the context switches, i don't know, but i'm willing to experiment some to see how feesible this is...

Anyone tried this before?

Magnus

#5Joerg Hessdoerfer
Joerg.Hessdoerfer@sea-gmbh.com
In reply to: Magnus Naeslund(f) (#4)
Re: WIN32 native ... lets start?!?

On Thursday 16 May 2002 22:10, you wrote:
[...]

What is the biggest problem here?
The Shmem/IPC stuff, or the fork() stuff?
I'm think that we could do a fork() implementation in usermode by copying
the memory allocations. How fast that would be regarding the context
switches, i don't know, but i'm willing to experiment some to see how
feesible this is...

Anyone tried this before?

Magnus

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

The problem is not the fork() call itself, this has been done (MinGW and
cygwin I know of, possibly others) but the speed of fork() on windows, it's
creepingly slow (due to usermode copy, I assume ;-).

IPC needs to be done, I'm just about to start...

Greetings,
Joerg
--
Leading SW developer - S.E.A GmbH
Mail: joerg.hessdoerfer@sea-gmbh.com
WWW: http://www.sea-gmbh.com

In reply to: Joerg Hessdoerfer (#1)
Re: WIN32 native ... lets start?!?

Joerg Hessdoerfer <Joerg.Hessdoerfer@sea-gmbh.com> wrote:
[snip]

The problem is not the fork() call itself, this has been done (MinGW
and cygwin I know of, possibly others) but the speed of fork() on
windows, it's creepingly slow (due to usermode copy, I assume ;-).

IPC needs to be done, I'm just about to start...

I'm not so familiar with the win32 kernel mode stuff.
But i've seen programs using .vxd (kernelmode, ring X ?) helpers for getting more privileges, maybe cross process ones.
Well, i'll look into this sometime if it's possible to reduce the context switches by going vxd.
There must be some way to read protection of the pages and map them as COW or RO in the new process to get rid of much of the copy, but then again, we're talking microsoft here :)
I once did a .exe loader that used the MapViewOfFile (win32 mmap) of the .exe itself to accomplish shared loadable modules that worked on x86 linux and win32 without recompile (might be something like the XFree86 binary gfx card drivers).

Good luck on the IPC work!

Magnus

--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Programmer/Networker [|] Magnus Naeslund
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

#7Christopher Kings-Lynne
chriskl@familyhealth.com.au
In reply to: Joerg Hessdoerfer (#5)
Re: WIN32 native ... lets start?!?

Maybe Vince could set up a Win32 porting project page, and since we now seem
to have a few interested parties willing to code on a native Win32 version,
they should have their own project page. This could make communication
easier for them and make sure the project doesn't die...

Chris

Show quoted text

-----Original Message-----
From: pgsql-hackers-owner@postgresql.org
[mailto:pgsql-hackers-owner@postgresql.org]On Behalf Of Joerg
Hessdoerfer
Sent: Friday, 17 May 2002 4:36 AM
To: Magnus Naeslund(f)
Cc: pgsql-hackers@postgresql.org
Subject: Re: [HACKERS] WIN32 native ... lets start?!?

On Thursday 16 May 2002 22:10, you wrote:
[...]

What is the biggest problem here?
The Shmem/IPC stuff, or the fork() stuff?
I'm think that we could do a fork() implementation in usermode

by copying

the memory allocations. How fast that would be regarding the context
switches, i don't know, but i'm willing to experiment some to see how
feesible this is...

Anyone tried this before?

Magnus

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

The problem is not the fork() call itself, this has been done (MinGW and
cygwin I know of, possibly others) but the speed of fork() on
windows, it's
creepingly slow (due to usermode copy, I assume ;-).

IPC needs to be done, I'm just about to start...

Greetings,
Joerg
--
Leading SW developer - S.E.A GmbH
Mail: joerg.hessdoerfer@sea-gmbh.com
WWW: http://www.sea-gmbh.com

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org

#8The Hermit Hacker
scrappy@hub.org
In reply to: Christopher Kings-Lynne (#7)
Re: WIN32 native ... lets start?!?

On Fri, 17 May 2002, Christopher Kings-Lynne wrote:

Maybe Vince could set up a Win32 porting project page, and since we now seem
to have a few interested parties willing to code on a native Win32 version,
they should have their own project page. This could make communication
easier for them and make sure the project doesn't die...

Might be an idea to create a pgsql-hackers-win32 list also? Or just
pgsql-win32?

Show quoted text

Chris

-----Original Message-----
From: pgsql-hackers-owner@postgresql.org
[mailto:pgsql-hackers-owner@postgresql.org]On Behalf Of Joerg
Hessdoerfer
Sent: Friday, 17 May 2002 4:36 AM
To: Magnus Naeslund(f)
Cc: pgsql-hackers@postgresql.org
Subject: Re: [HACKERS] WIN32 native ... lets start?!?

On Thursday 16 May 2002 22:10, you wrote:
[...]

What is the biggest problem here?
The Shmem/IPC stuff, or the fork() stuff?
I'm think that we could do a fork() implementation in usermode

by copying

the memory allocations. How fast that would be regarding the context
switches, i don't know, but i'm willing to experiment some to see how
feesible this is...

Anyone tried this before?

Magnus

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

The problem is not the fork() call itself, this has been done (MinGW and
cygwin I know of, possibly others) but the speed of fork() on
windows, it's
creepingly slow (due to usermode copy, I assume ;-).

IPC needs to be done, I'm just about to start...

Greetings,
Joerg
--
Leading SW developer - S.E.A GmbH
Mail: joerg.hessdoerfer@sea-gmbh.com
WWW: http://www.sea-gmbh.com

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

#9Tom Lane
tgl@sss.pgh.pa.us
In reply to: The Hermit Hacker (#8)
Re: WIN32 native ... lets start?!?

"Marc G. Fournier" <scrappy@hub.org> writes:

Might be an idea to create a pgsql-hackers-win32 list also? Or just
pgsql-win32?

Actually, I think that'd be a bad idea. The very last thing we need is
for these discussions to get fragmented. The issues affect the whole
backend AFAICS.

regards, tom lane

#10Joerg Hessdoerfer
Joerg.Hessdoerfer@sea-gmbh.com
In reply to: Tom Lane (#9)
Re: WIN32 native ... lets start?!?

On Friday 17 May 2002 22:16, you wrote:

"Marc G. Fournier" <scrappy@hub.org> writes:

Might be an idea to create a pgsql-hackers-win32 list also? Or just
pgsql-win32?

Actually, I think that'd be a bad idea. The very last thing we need is
for these discussions to get fragmented. The issues affect the whole
backend AFAICS.

regards, tom lane

Yes, indeed. I would also like to discuss matters on this list, as one get's
a 'heads up' from people in the know much easier.

BTW, I'm in the process of doing the 'really only what is necessary for pg'
ipc-stuff, and was wondering if anybody already did some configuration of the
source tree towards MinGW?? How should we go about that? I would rather like
not using cygwin's sh for that ;-), and we have no 'ln' !!

Greetings,
Joerg
--
Leading SW developer - S.E.A GmbH
Mail: joerg.hessdoerfer@sea-gmbh.com
WWW: http://www.sea-gmbh.com

#11Bruce Momjian
bruce@momjian.us
In reply to: The Hermit Hacker (#2)
Roadmap for a Win32 port

OK, I think I am now caught up on the Win32/cygwin discussion, and would
like to make some remarks.

First, are we doing enough to support the Win32 platform? I think the
answer is clearly "no". There are 3-5 groups/companies working on Win32
ports of PostgreSQL. We always said there would not be PostgreSQL forks
if we were doing our job to meet user needs. Well, obviously, a number
of groups see a need for a better Win32 port and we aren't meeting that
need, so they are. I believe this is one of the few cases where groups
are going out on their own because we are falling behind.

So, there is no question in my mind we need to do more to encourage
Win32 ports. Now, on to the details.

INSTALLER
---------

We clearly need an installer that is zero-hassle for users. We need to
decide on a direction for this.

GUI
---

We need a slick GUI. pgadmin2 seems to be everyone's favorite, with
pgaccess on Win32 also an option. What else do we need here?

BINARY
------

This is the big daddy. It is broken down into several sections:

FORK()

How do we handle fork()? Do we use the cygwin method that copies the
whole data segment, or put the global data in shared memory and copy
that small part manually after we create a new process?

THREADING

Related to fork(), do we implement an optionally threaded postmaster,
which eliminates CreateProcess() entirely? I don't think we will have
superior performance on Win32 without it. (This would greatly help
Solaris as well.)

IPC

We can use Cygwin, MinGW, Apache, or our own code for this. Are there
other options?

ENVIRONMENT

Lots of our code requires a unix shell and utilities. Will we continue
using cygwin for this?

---------------------------------------------------------------------------

As a roadmap, it would be good to get consensus on as many of these
items as possible so people can start working in these areas. We can
keep a web page of decisions we have made to help rally developers to
the project.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
#12Dann Corbit
DCorbit@connx.com
In reply to: Bruce Momjian (#11)
Re: Roadmap for a Win32 port

-----Original Message-----
From: Bruce Momjian [mailto:pgman@candle.pha.pa.us]
Sent: Tuesday, June 04, 2002 9:34 PM
To: PostgreSQL-development
Subject: [HACKERS] Roadmap for a Win32 port

OK, I think I am now caught up on the Win32/cygwin
discussion, and would
like to make some remarks.

First, are we doing enough to support the Win32 platform? I think the
answer is clearly "no". There are 3-5 groups/companies
working on Win32
ports of PostgreSQL. We always said there would not be
PostgreSQL forks
if we were doing our job to meet user needs. Well,
obviously, a number
of groups see a need for a better Win32 port and we aren't
meeting that
need, so they are. I believe this is one of the few cases
where groups
are going out on their own because we are falling behind.

So, there is no question in my mind we need to do more to encourage
Win32 ports. Now, on to the details.

INSTALLER
---------

We clearly need an installer that is zero-hassle for users.
We need to
decide on a direction for this.

GUI
---

We need a slick GUI. pgadmin2 seems to be everyone's favorite, with
pgaccess on Win32 also an option. What else do we need here?

Nothing else. It is better than any commercial tools in current use.
An excellent piece of work.

BINARY
------

This is the big daddy. It is broken down into several sections:

FORK()

How do we handle fork()? Do we use the cygwin method that copies the
whole data segment, or put the global data in shared memory and copy
that small part manually after we create a new process?

Do not try to do a fork() on Win32. The one at PW32 is better, but
still awful. Win32 just does not have fascilities for fork().

If you use Cygwin, it will kill the project for commercial use (at least
for many institutions). That's fine, but it will become an academic
exercise instead of a viable commercial tool. If they are comfortable
in that [Cygwin] environment, it makes no sense to use Cygwin instead of
Redhat. The Redhat version will fork() 100 times faster. After all, if
they are going to use unix tools in a unix interface with Unix scripts
you might as well use UNIX. And Cygwin requires a license for
commercial use.
http://cygwin.com/licensing.html

THREADING

Related to fork(), do we implement an optionally threaded postmaster,
which eliminates CreateProcess() entirely? I don't think we will have
superior performance on Win32 without it. (This would greatly help
Solaris as well.)

CreateProcess() works well for Win32. That is the approach that we used
and also the approach used by the Japanese team.
It is very simple. Simply do a create process call and then perform the
same operations that were done up to that point. It isn't difficult.
Threading is another possibility. I think create process is better,
because you can clone the rights of the one who attaches for the spawned
server (if you want to do that).

IPC

We can use Cygwin, MinGW, Apache, or our own code for this. Are there
other options?

We wrote our own from scratch. Cygwin will kill it. If there is a
MinGW version it might be OK, but if MinGW is GPL, that will kill it.
Have a look at ACE:
http://www.cs.wustl.edu/~schmidt/ACE.html
Their license is on the same level as a BSD license. Now, they use C++,
but you can always write:
extern "C" {
}
wrappers for stuff and keep PostgreSQL itself in pure, vanilla C. GCC
does come with a C++ compiler, so it isn't going to cut anyone off.

ENVIRONMENT

Lots of our code requires a Unix shell and utilities. Will
we continue
using cygwin for this?

We wrote our own utilities from scratch (e.g. initdb). The Japanese
group that did the port did the same thing.

--------------------------------------------------------------
-------------

As a roadmap, it would be good to get consensus on as many of these
items as possible so people can start working in these areas. We can
keep a web page of decisions we have made to help rally developers to
the project.

If you want a roadmap, the Japanese group laid it out for you. They
did the exact same steps as we did. Now, I don't know if we will be
able to contribute or not (it is very much up in the air). And we had
to do a lot of hacking of the source, so you might not want it if we
volunteered.

Suggestion:
Ask the Japanese group if they would like to post their changes back or
expose them so that the programming team can get ideas form it.

I actually like what they did better than what we did (A giant DLL and
all the binaries are microscopic -- it was how I suggested to do it here
but it was vetoed).

Anyway, here is a roadmap laid out for you exactly. Just do what it
says and you will be fine:
http://hp.vector.co.jp/authors/VA023283/PostgreSQLe.html

Look at where it says "Gists for patch" and do that.

#13Mark Kirkwood
mark.kirkwood@catalyst.net.nz
In reply to: Bruce Momjian (#11)
Re: Roadmap for a Win32 port

On Wed, 2002-06-05 at 16:33, Bruce Momjian wrote:

OK, I think I am now caught up on the Win32/cygwin discussion, and would
like to make some remarks.

First, are we doing enough to support the Win32 platform? I think the
answer is clearly "no". There are 3-5 groups/companies working on Win32
ports of PostgreSQL. We always said there would not be PostgreSQL forks
if we were doing our job to meet user needs. Well, obviously, a number
of groups see a need for a better Win32 port and we aren't meeting that
need, so they are. I believe this is one of the few cases where groups
are going out on their own because we are falling behind.

So, there is no question in my mind we need to do more to encourage
Win32 ports. Now, on to the details.

INSTALLER
---------

We clearly need an installer that is zero-hassle for users. We need to
decide on a direction for this.

GUI
---

We need a slick GUI. pgadmin2 seems to be everyone's favorite, with
pgaccess on Win32 also an option. What else do we need here?

BINARY
------

This is the big daddy. It is broken down into several sections:

FORK()

How do we handle fork()? Do we use the cygwin method that copies the
whole data segment, or put the global data in shared memory and copy
that small part manually after we create a new process?

THREADING

Related to fork(), do we implement an optionally threaded postmaster,
which eliminates CreateProcess() entirely? I don't think we will have
superior performance on Win32 without it. (This would greatly help
Solaris as well.)

IPC

We can use Cygwin, MinGW, Apache, or our own code for this. Are there
other options?

ENVIRONMENT

Lots of our code requires a unix shell and utilities. Will we continue
using cygwin for this?

---------------------------------------------------------------------------

As a roadmap, it would be good to get consensus on as many of these
items as possible so people can start working in these areas. We can
keep a web page of decisions we have made to help rally developers to
the project.

-- 
Bruce Momjian                        |  http://candle.pha.pa.us
pgman@candle.pha.pa.us               |  (610) 853-3000
+  If your life is a hard drive,     |  830 Blythe Avenue
+  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html

Is it worth looking at how the mysql crowd did their win32 port -
(or is that intrinsically a _bad_thing_ to do..) ?

(I am guessing that is why their sources requires c++ ....)

regards

Mark

#14Jason Tishler
jason@tishler.net
In reply to: Dann Corbit (#12)
Re: Roadmap for a Win32 port

Dan,

The following is to help keep the archives accurate and should not be
construed as an argument against the native Win32 port.

On Tue, Jun 04, 2002 at 10:02:14PM -0700, Dann Corbit wrote:

And Cygwin requires a license for commercial use.
http://cygwin.com/licensing.html

The above is not necessarily true:

Red Hat sells a special Cygwin License for customers who are unable
to provide their application in open source code form.

Note that the above only comes into play if your application links
with the Cygwin DLL. This is easily avoidable by using JDBC, ODBC,
Win32 libpq, etc. Hence, most people will not be required to purchase
this license from Red Hat.

Jason

#15Bruce Momjian
bruce@momjian.us
In reply to: Jason Tishler (#14)
Re: Roadmap for a Win32 port

Jason Tishler wrote:

Dan,

The following is to help keep the archives accurate and should not be
construed as an argument against the native Win32 port.

On Tue, Jun 04, 2002 at 10:02:14PM -0700, Dann Corbit wrote:

And Cygwin requires a license for commercial use.
http://cygwin.com/licensing.html

The above is not necessarily true:

Red Hat sells a special Cygwin License for customers who are unable
to provide their application in open source code form.

Note that the above only comes into play if your application links
with the Cygwin DLL. This is easily avoidable by using JDBC, ODBC,
Win32 libpq, etc. Hence, most people will not be required to purchase
this license from Red Hat.

So apps written using client libraries are BSD, while server-side
changes would have to release source. Makes sense, though we have never
had this distinction before. I assume plpgsql stored procedures would
have be open source, but of course those are stored in plaintext on the
server so that isn't a problem. If companies created custom C stored
procedures, those would have to be open source if using cygwin.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
#16Bruce Momjian
bruce@momjian.us
In reply to: Mark Kirkwood (#13)
Re: Roadmap for a Win32 port

Mark kirkwood wrote:

Is it worth looking at how the mysql crowd did their win32 port -
(or is that intrinsically a _bad_thing_ to do..) ?

(I am guessing that is why their sources requires c++ ....)

Absolutely worth seeing how MySQL does it. They use cygwin, and I
assume they aren't seeing the fork() issue because they are threaded,
and perhaps they don't use SysV IPC like we do.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
#17Igor Kovalenko
Igor.Kovalenko@motorola.com
In reply to: Bruce Momjian (#11)
Re: Roadmap for a Win32 port

I might be naive here, but would not proper threading model remove the need
for fork() altogether? On both Unix and Win32? Should not be too hard to
come up with abstraction which encapsulates POSIX, BeOS and Win32 threads...
I am not sure how universal POSIX threads are by now. Any important Unix
platforms which don't support them yet?

This has downside of letting any bug to kill the whole thing. On the bright
side, performance should be better on some platforms (note however, Apache
group still can't come up with implementation of threaded model which would
provide better performance than forked or other models). The need to deal
with possibility of 'alien' postmaster running along with orphaned backends
would also be removed since there would be only one process.

Issue of thread safety of code will come up undoubtedly and some things will
probably have to be revamped. But in long term this is probably best way if
you want to have efficient and uniform Unix AND Win32 implementations.

I am not too familiar with Win32. Speaking about POSIX threads, it would be
something like a thread pool with low & high watermarks. Main thread would
handle thread pool and hand over requests to worker threads (blocked on
condvar). How does that sound?

-- igor

----- Original Message -----
From: "Bruce Momjian" <pgman@candle.pha.pa.us>
To: "PostgreSQL-development" <pgsql-hackers@postgresql.org>
Sent: Tuesday, June 04, 2002 11:33 PM
Subject: [HACKERS] Roadmap for a Win32 port

OK, I think I am now caught up on the Win32/cygwin discussion, and would
like to make some remarks.

First, are we doing enough to support the Win32 platform? I think the
answer is clearly "no". There are 3-5 groups/companies working on Win32
ports of PostgreSQL. We always said there would not be PostgreSQL forks
if we were doing our job to meet user needs. Well, obviously, a number
of groups see a need for a better Win32 port and we aren't meeting that
need, so they are. I believe this is one of the few cases where groups
are going out on their own because we are falling behind.

So, there is no question in my mind we need to do more to encourage
Win32 ports. Now, on to the details.

INSTALLER
---------

We clearly need an installer that is zero-hassle for users. We need to
decide on a direction for this.

GUI
---

We need a slick GUI. pgadmin2 seems to be everyone's favorite, with
pgaccess on Win32 also an option. What else do we need here?

BINARY
------

This is the big daddy. It is broken down into several sections:

FORK()

How do we handle fork()? Do we use the cygwin method that copies the
whole data segment, or put the global data in shared memory and copy
that small part manually after we create a new process?

THREADING

Related to fork(), do we implement an optionally threaded postmaster,
which eliminates CreateProcess() entirely? I don't think we will have
superior performance on Win32 without it. (This would greatly help
Solaris as well.)

IPC

We can use Cygwin, MinGW, Apache, or our own code for this. Are there
other options?

ENVIRONMENT

Lots of our code requires a unix shell and utilities. Will we continue
using cygwin for this?

--------------------------------------------------------------------------

-

Show quoted text

As a roadmap, it would be good to get consensus on as many of these
items as possible so people can start working in these areas. We can
keep a web page of decisions we have made to help rally developers to
the project.

--
Bruce Momjian                        |  http://candle.pha.pa.us
pgman@candle.pha.pa.us               |  (610) 853-3000
+  If your life is a hard drive,     |  830 Blythe Avenue
+  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html

#18Bruce Momjian
bruce@momjian.us
In reply to: Igor Kovalenko (#17)
Re: Roadmap for a Win32 port

Igor Kovalenko wrote:

I might be naive here, but would not proper threading model remove the need
for fork() altogether? On both Unix and Win32? Should not be too hard to
come up with abstraction which encapsulates POSIX, BeOS and Win32 threads...
I am not sure how universal POSIX threads are by now. Any important Unix
platforms which don't support them yet?

This has downside of letting any bug to kill the whole thing. On the bright
side, performance should be better on some platforms (note however, Apache
group still can't come up with implementation of threaded model which would
provide better performance than forked or other models). The need to deal
with possibility of 'alien' postmaster running along with orphaned backends
would also be removed since there would be only one process.

Issue of thread safety of code will come up undoubtedly and some things will
probably have to be revamped. But in long term this is probably best way if
you want to have efficient and uniform Unix AND Win32 implementations.

I am not too familiar with Win32. Speaking about POSIX threads, it would be
something like a thread pool with low & high watermarks. Main thread would
handle thread pool and hand over requests to worker threads (blocked on
condvar). How does that sound?

Good summary. I think we would support both threaded and fork()
operation, and users can control which they prefer. For a web backend
where many sessions are a single query, people may want to give up the
stability of fork() and go with threads, even on Unix.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
#19Thomas Lockhart
thomas@fourpalms.org
In reply to: Bruce Momjian (#18)
Re: Roadmap for a Win32 port

...

Good summary. I think we would support both threaded and fork()
operation, and users can control which they prefer. For a web backend
where many sessions are a single query, people may want to give up the
stability of fork() and go with threads, even on Unix.

I would think that we would build on our strengths of having a fork/exec
model for separate clients. A threaded model *could* benefit individual
clients who are doing queries on multiprocessor servers, and I would be
supportive of efforts to enable that.

But the requirements for that may be less severe than for managing
multiple clients within the same process, and imho there is not strong
requirement to enable the latter for our current crop of well supported
targets. If it came for free then great, but if it came with a high cost
then the choice is not as obvious. It is also not a *requirement* if we
were instead able to do the multiple threads for a single client
scenerio first.

- Thomas

#20Dann Corbit
DCorbit@connx.com
In reply to: Thomas Lockhart (#19)
Re: Roadmap for a Win32 port

-----Original Message-----
From: Thomas Lockhart [mailto:thomas@fourpalms.org]
Sent: Wednesday, June 05, 2002 3:03 PM
To: Bruce Momjian
Cc: Igor Kovalenko; PostgreSQL-development
Subject: Re: [HACKERS] Roadmap for a Win32 port

...

Good summary. I think we would support both threaded and fork()
operation, and users can control which they prefer. For a

web backend

where many sessions are a single query, people may want to

give up the

stability of fork() and go with threads, even on Unix.

I would think that we would build on our strengths of having
a fork/exec
model for separate clients. A threaded model *could* benefit
individual
clients who are doing queries on multiprocessor servers, and
I would be
supportive of efforts to enable that.

But the requirements for that may be less severe than for managing
multiple clients within the same process, and imho there is not strong
requirement to enable the latter for our current crop of well
supported
targets. If it came for free then great, but if it came with
a high cost
then the choice is not as obvious. It is also not a
*requirement* if we
were instead able to do the multiple threads for a single client
scenerio first.

Notion:
Have one version do both. Your server can fork(), and your sever can
thread. It can fork() and thread, it can fork() or thread.

That gives the best of all worlds. One client who has his attachments
to a database all setup might want to do a bunch of similar queries.
Hence a threaded model is nice.

A server may be set up to clone the rights of the attaching process for
security reasons. Then you launch a new server with fork().

#21Thomas Lockhart
thomas@fourpalms.org
In reply to: Dann Corbit (#20)
#22Jon Franz
coventry@one.net
In reply to: Bruce Momjian (#18)
#23Neil Conway
neilc@samurai.com
In reply to: Jon Franz (#22)
#24Nicolas Bazin
nbazin@ingenico.com.au
In reply to: Bruce Momjian (#18)
#25Bruce Momjian
bruce@momjian.us
In reply to: Neil Conway (#23)
#26Steve Howe
howe@carcass.dhs.org
In reply to: Thomas Lockhart (#19)
#27Nicolas Bazin
nbazin@ingenico.com.au
In reply to: Bruce Momjian (#18)
#28Steve Howe
howe@carcass.dhs.org
In reply to: Bruce Momjian (#11)
#29Igor Kovalenko
Igor.Kovalenko@motorola.com
In reply to: Bruce Momjian (#18)
#30Bruce Momjian
bruce@momjian.us
In reply to: Bruce Momjian (#11)
#31Bruce Momjian
bruce@momjian.us
In reply to: Igor Kovalenko (#29)
#32Robert Schrem
robert.schrem@WiredMinds.de
In reply to: Bruce Momjian (#30)
#33Jan Wieck
JanWieck@Yahoo.com
In reply to: Bruce Momjian (#31)
#34Bruce Momjian
bruce@momjian.us
In reply to: Robert Schrem (#32)
#35Bruce Momjian
bruce@momjian.us
In reply to: Jan Wieck (#33)
#36Peter Eisentraut
peter_e@gmx.net
In reply to: Bruce Momjian (#11)
#37Bruce Momjian
bruce@momjian.us
In reply to: Peter Eisentraut (#36)
#38Dave Page
dpage@pgadmin.org
In reply to: Bruce Momjian (#37)
#39Peter Eisentraut
peter_e@gmx.net
In reply to: Bruce Momjian (#30)
#40Scott Shattuck
ss@technicalpursuit.com
In reply to: Peter Eisentraut (#39)
#41Peter Eisentraut
peter_e@gmx.net
In reply to: Bruce Momjian (#37)
#42Tom Lane
tgl@sss.pgh.pa.us
In reply to: Peter Eisentraut (#41)
#43Bruce Momjian
bruce@momjian.us
In reply to: Tom Lane (#42)
#44Tom Lane
tgl@sss.pgh.pa.us
In reply to: Bruce Momjian (#43)
#45Bruce Momjian
bruce@momjian.us
In reply to: Peter Eisentraut (#41)
#46Dave Page
dpage@pgadmin.org
In reply to: Bruce Momjian (#45)
#47Dave Cramer
pg@fastcrypt.com
In reply to: Scott Shattuck (#40)
#48Peter Eisentraut
peter_e@gmx.net
In reply to: Bruce Momjian (#45)
#49Bruce Momjian
bruce@momjian.us
In reply to: Peter Eisentraut (#48)
#50Bruce Momjian
bruce@momjian.us
In reply to: Bruce Momjian (#49)
#51Jan Wieck
JanWieck@Yahoo.com
In reply to: Bruce Momjian (#49)
#52Dann Corbit
DCorbit@connx.com
In reply to: Jan Wieck (#51)
#53Bruce Momjian
bruce@momjian.us
In reply to: Dann Corbit (#52)
#54Dann Corbit
DCorbit@connx.com
In reply to: Bruce Momjian (#53)
#55Bruce Momjian
bruce@momjian.us
In reply to: Dann Corbit (#54)
#56Jan Wieck
JanWieck@Yahoo.com
In reply to: Dann Corbit (#54)
#57Tom Lane
tgl@sss.pgh.pa.us
In reply to: Peter Eisentraut (#48)
#58Greg Copeland
greg@CopelandConsulting.Net
In reply to: Jan Wieck (#56)
#59Serge Adda
sAdda@infovista.com
In reply to: Greg Copeland (#58)
#60Marek Mosiewicz
marekmosiewicz@poczta.onet.pl
In reply to: Serge Adda (#59)
#61Peter Eisentraut
peter_e@gmx.net
In reply to: Tom Lane (#57)
#62Tom Lane
tgl@sss.pgh.pa.us
In reply to: Peter Eisentraut (#61)
#63Jean-Michel POURE
jm.poure@freesurf.fr
In reply to: Serge Adda (#59)
#64Karel Zak
zakkr@zf.jcu.cz
In reply to: Jean-Michel POURE (#63)
#65Jean-Michel POURE
jm.poure@freesurf.fr
In reply to: Karel Zak (#64)
#66Karel Zak
zakkr@zf.jcu.cz
In reply to: Jean-Michel POURE (#65)
#67Jan Wieck
JanWieck@Yahoo.com
In reply to: Serge Adda (#59)
#68Gavin Sherry
swm@linuxworld.com.au
In reply to: Jean-Michel POURE (#65)
#69Tom Lane
tgl@sss.pgh.pa.us
In reply to: Jean-Michel POURE (#65)
#70Jean-Michel POURE
jm.poure@freesurf.fr
In reply to: Tom Lane (#69)
#71Hannu Krosing
hannu@tm.ee
In reply to: Jean-Michel POURE (#65)
#72Bruce Momjian
bruce@momjian.us
In reply to: Jean-Michel POURE (#63)
#73Thomas Lockhart
lockhart@fourpalms.org
In reply to: Bruce Momjian (#72)
#74Bruce Momjian
bruce@momjian.us
In reply to: Jan Wieck (#67)
#75The Hermit Hacker
scrappy@hub.org
In reply to: Jean-Michel POURE (#65)
#76The Hermit Hacker
scrappy@hub.org
In reply to: Bruce Momjian (#74)
#77The Hermit Hacker
scrappy@hub.org
In reply to: Jean-Michel POURE (#70)
#78The Hermit Hacker
scrappy@hub.org
In reply to: Hannu Krosing (#71)
#79Neil Conway
neilc@samurai.com
In reply to: Bruce Momjian (#72)
#80Jan Wieck
JanWieck@Yahoo.com
In reply to: The Hermit Hacker (#76)
#81Bruce Momjian
bruce@momjian.us
In reply to: Jan Wieck (#80)
#82Lamar Owen
lamar.owen@wgcr.org
In reply to: Jan Wieck (#80)
#83Mike Mascari
mascarm@mascari.com
In reply to: The Hermit Hacker (#76)
#84Stephan Szabo
sszabo@megazone23.bigpanda.com
In reply to: Jan Wieck (#80)
#85Jan Wieck
JanWieck@Yahoo.com
In reply to: Stephan Szabo (#84)
#86Jon Franz
coventry@one.net
In reply to: Bruce Momjian (#81)
#87Bruce Momjian
bruce@momjian.us
In reply to: Jon Franz (#86)
#88The Hermit Hacker
scrappy@hub.org
In reply to: Bruce Momjian (#87)
#89Josh Berkus
josh@agliodbs.com
In reply to: Jean-Michel POURE (#70)
#90Tom Lane
tgl@sss.pgh.pa.us
In reply to: Josh Berkus (#89)
#91The Hermit Hacker
scrappy@hub.org
In reply to: Tom Lane (#90)
#92Tycho Fruru
tycho@fruru.com
In reply to: Tom Lane (#90)
#93Dave Cramer
pg@fastcrypt.com
In reply to: Tom Lane (#90)
#94Andrew Sullivan
andrew@libertyrms.info
In reply to: Tycho Fruru (#92)
#95Rod Taylor
rbt@rbt.ca
In reply to: Andrew Sullivan (#94)
#96Josh Berkus
josh@agliodbs.com
In reply to: Tom Lane (#90)
#97James Hubbard
jhubbard@mcs.uvawise.edu
In reply to: Josh Berkus (#89)
#98Bruce Momjian
bruce@momjian.us
In reply to: James Hubbard (#97)
#99Rod Taylor
rbt@rbt.ca
In reply to: Bruce Momjian (#98)
#100Bruce Momjian
bruce@momjian.us
In reply to: Tom Lane (#90)
#101Bruce Momjian
bruce@momjian.us
In reply to: Josh Berkus (#96)
#102Bruce Momjian
bruce@momjian.us
In reply to: Tom Lane (#90)
#103Jeff MacDonald
jeff@tsunamicreek.com
In reply to: Bruce Momjian (#98)
#104James Hubbard
jhubbard@mcs.uvawise.edu
In reply to: Bruce Momjian (#98)
#105scott.marlowe
scott.marlowe@ihs.com
In reply to: James Hubbard (#97)
#106Matthew T. O'Connor
matthew@zeut.net
In reply to: Bruce Momjian (#101)
In reply to: Bruce Momjian (#101)
#108Josh Berkus
josh@agliodbs.com
In reply to: James Hubbard (#97)
#109Josh Berkus
josh@agliodbs.com
In reply to: Bruce Momjian (#101)
#110Dann Corbit
DCorbit@connx.com
In reply to: Josh Berkus (#109)
#111The Hermit Hacker
scrappy@hub.org
In reply to: Bruce Momjian (#102)
#112Chris Browne
cbbrowne@acm.org
In reply to: Josh Berkus (#96)
#113Josh Berkus
josh@agliodbs.com
In reply to: The Hermit Hacker (#111)
#114Neil Conway
neilc@samurai.com
In reply to: Chris Browne (#112)
#115Josh Berkus
josh@agliodbs.com
In reply to: Rod Taylor (#95)
In reply to: Hannu Krosing (#107)
#117Justin Clift
justin@postgresql.org
In reply to: Bruce Momjian (#98)
#118Curt Sampson
cjs@cynic.net
In reply to: Josh Berkus (#109)
#119Matthew T. O'Connor
matthew@zeut.net
In reply to: Josh Berkus (#115)
#120Bruce Momjian
bruce@momjian.us
In reply to: Josh Berkus (#115)
#121Bruce Momjian
bruce@momjian.us
In reply to: The Hermit Hacker (#111)
#122Jonah H. Harris
jharris@nightstarcorporation.com
In reply to: Curt Sampson (#118)
#123Justin Clift
justin@postgresql.org
In reply to: Jonah H. Harris (#122)
#124Christopher Kings-Lynne
chriskl@familyhealth.com.au
In reply to: Bruce Momjian (#100)
#125Christopher Kings-Lynne
chriskl@familyhealth.com.au
In reply to: Bruce Momjian (#98)
#126Christopher Kings-Lynne
chriskl@familyhealth.com.au
In reply to: Curt Sampson (#118)
#127Christopher Kings-Lynne
chriskl@familyhealth.com.au
In reply to: Curt Sampson (#118)
#128Kaare Rasmussen
kar@kakidata.dk
In reply to: Christopher Kings-Lynne (#125)
#129Dave Cramer
pg@fastcrypt.com
In reply to: Christopher Kings-Lynne (#125)
#130Dave Cramer
pg@fastcrypt.com
In reply to: Christopher Kings-Lynne (#125)
#131Matthew T. O'Connor
matthew@zeut.net
In reply to: Christopher Kings-Lynne (#125)
#132The Hermit Hacker
scrappy@hub.org
In reply to: Dave Cramer (#130)
#133Dave Page
dpage@pgadmin.org
In reply to: The Hermit Hacker (#132)
#134Josh Berkus
josh@agliodbs.com
In reply to: Curt Sampson (#118)
#135Jeff MacDonald
jeff@tsunamicreek.com
In reply to: The Hermit Hacker (#132)
#136Bruce Momjian
bruce@momjian.us
In reply to: Justin Clift (#123)
#137Dave Cramer
pg@fastcrypt.com
In reply to: The Hermit Hacker (#132)
#138The Hermit Hacker
scrappy@hub.org
In reply to: Dave Cramer (#137)
#139Dann Corbit
DCorbit@connx.com
In reply to: Josh Berkus (#134)
#140Josh Berkus
josh@agliodbs.com
In reply to: Dann Corbit (#139)
#141Peter Eisentraut
peter_e@gmx.net
In reply to: The Hermit Hacker (#111)
#142Dave Page
dpage@pgadmin.org
In reply to: Peter Eisentraut (#141)
#143Andrew Sullivan
andrew@libertyrms.info
In reply to: Dann Corbit (#139)
#144Curt Sampson
cjs@cynic.net
In reply to: Josh Berkus (#134)
#145Jonah H. Harris
jharris@nightstarcorporation.com
In reply to: Bruce Momjian (#136)
#146Christopher Kings-Lynne
chriskl@familyhealth.com.au
In reply to: Bruce Momjian (#98)
#147Justin Clift
justin@postgresql.org
In reply to: Bruce Momjian (#136)
#148Curt Sampson
cjs@cynic.net
In reply to: Dann Corbit (#139)
#149Curt Sampson
cjs@cynic.net
In reply to: Josh Berkus (#140)
#150Tim Hart
tjhart@mac.com
In reply to: Andrew Sullivan (#143)
#151Tim Hart
timjhart@shaw.ca
In reply to: Tim Hart (#150)
#152Christopher Kings-Lynne
chriskl@familyhealth.com.au
In reply to: Tim Hart (#150)
#153Dave Page
dpage@pgadmin.org
In reply to: Christopher Kings-Lynne (#152)
#154Rod Taylor
rbt@rbt.ca
In reply to: Tim Hart (#151)
#155Andrew Sullivan
andrew@libertyrms.info
In reply to: Tim Hart (#150)
#156Tim Hart
tjhart@mac.com
In reply to: Andrew Sullivan (#155)
#157Josh Berkus
josh@agliodbs.com
In reply to: Tim Hart (#150)
#158Tim Hart
tjhart@mac.com
In reply to: Josh Berkus (#157)
#159The Hermit Hacker
scrappy@hub.org
In reply to: Tim Hart (#156)