Re: [HACKERS] Using Threads

2001-02-06 Thread The Hermit Hacker
On Tue, 6 Feb 2001, Karel Zak wrote: > > On Tue, 6 Feb 2001, Myron Scott wrote: > > > There are many many globals I had to work around including all the memory > > management stuff. I basically threw everything into and "environment" > > variable which I stored in a thread specific using thr_set

Re: [HACKERS] Using Threads

2001-02-06 Thread Karel Zak
On Tue, 6 Feb 2001, Myron Scott wrote: > There are many many globals I had to work around including all the memory > management stuff. I basically threw everything into and "environment" > variable which I stored in a thread specific using thr_setspecific. Yes, it's good. I working on multi-t

Re: [HACKERS] Using Threads

2001-02-06 Thread Myron Scott
> > Sorry I haven't time to see and test your experiment, > but I have a question. How you solve memory management? > The current mmgr is based on global variable > CurrentMemoryContext that is very often changed and used. > Use you for this locks? If yes it is probably problematic > point fo

Re: [HACKERS] Using Threads?

2001-02-06 Thread Karel Zak
On Mon, 5 Feb 2001, Myron Scott wrote: > I have put a new version of my multi-threaded > postgresql experiment at > > http://www.sacadia.com/mtpg.html > > This one actually works. I have added a server > based on omniORB, a CORBA 2.3 ORB from ATT. It >is much smaller than TAO and uses the

Re: [HACKERS] Using Threads?

2001-02-05 Thread Myron Scott
I have put a new version of my multi-threaded postgresql experiment at http://www.sacadia.com/mtpg.html This one actually works. I have added a server based on omniORB, a CORBA 2.3 ORB from ATT. It is much smaller than TAO and uses the thread per connection model. I haven't added the java

Re: [HACKERS] Using Threads?

2001-01-02 Thread Alfred Perlstein
* Myron Scott <[EMAIL PROTECTED]> [010102 08:47] wrote: > > > Alfred Perlstein wrote: > > > > > > It's possible what you're seeing is the entire process > > wait for a disk IO to complete. > > > > I'm wondering, how many lwps does your system use? Are all > > the threads bound to a single l

Re: [HACKERS] Using Threads?

2001-01-02 Thread Myron Scott
Alfred Perlstein wrote: > > It's possible what you're seeing is the entire process > wait for a disk IO to complete. > > I'm wondering, how many lwps does your system use? Are all > the threads bound to a single lwp or do you let the threads > manager handle this all for you? > Yeah, I lo

Re: [HACKERS] Using Threads?

2001-01-02 Thread Alfred Perlstein
* Myron Scott <[EMAIL PROTECTED]> [010102 07:45] wrote: > > Karel Zak wrote: > > > On Tue, 2 Jan 2001, Myron Scott wrote: > > > > > >> spinlocks rewritten to mutex_ > >> locktable uses sema_ > >> some cond_ in bufmgr.c > > > > > > Interesting, have you some comperation between IPC Postg

Re: [HACKERS] Using Threads?

2001-01-02 Thread Myron Scott
Karel Zak wrote: > On Tue, 2 Jan 2001, Myron Scott wrote: > > >> spinlocks rewritten to mutex_ >> locktable uses sema_ >> some cond_ in bufmgr.c > > > Interesting, have you some comperation between IPC PostgresSQl anf > your thread based PostgreSQL. > > Karel Yes, I did some compari

Re: [HACKERS] Using Threads?

2001-01-01 Thread Myron Scott
spinlocks rewritten to mutex_ locktable uses sema_ some cond_ in bufmgr.c Myron Karel Zak wrote: > On Mon, 1 Jan 2001, Myron Scott wrote: > > >> For anyone interested, >> >> I have posted my multi-threaded version of PostgreSQL here. >> >> http://www.sacadia.com/mtpg.html > > > How you

Re: [HACKERS] Using Threads?

2001-01-01 Thread Karel Zak
On Mon, 1 Jan 2001, Myron Scott wrote: > For anyone interested, > > I have posted my multi-threaded version of PostgreSQL here. > > http://www.sacadia.com/mtpg.html How you solve locks? Via original IPC or you rewrite it to mutex (etc). Karel

Re: [HACKERS] Using Threads?

2001-01-01 Thread Myron Scott
For anyone interested, I have posted my multi-threaded version of PostgreSQL here. http://www.sacadia.com/mtpg.html It is based on 7.0.2 and the TAO CORBA ORB which is here. http://www.cs.wustl.edu/~schmidt/TAO.html Myron Scott [EMAIL PROTECTED]

AW: [HACKERS] Using Threads?

2000-12-11 Thread Zeugswetter Andreas SB
> > The cons side of processes model is not the startup time. It is about > > kernel resource and context-switch cost. Processes consume much more > > kernel resource than threads, and have a much higher cost for context > > switch. The scalability of threads model is much better than that of > >

AW: [HACKERS] Using Threads?

2000-12-11 Thread Zeugswetter Andreas SB
> This brings up a good point. Threads are mostly useful when you have > multiple processes that need to share lots of data, and the interprocess > overhead is excessive. Because we already have that shared memory area, > this benefit of threads doesn't buy us much. We sort of already have >

Re: [HACKERS] Using Threads?

2000-12-09 Thread Bruce Momjian
> Bruce Momjian <[EMAIL PROTECTED]> writes: > >> There is no difference. If anything bad happens with the current > >> multi-process server, all the postgres backends shutdown because the > >> shared memory may be corrupted. > > > Yes. Are we adding reliability with per-process backends. > > Y

Re: [HACKERS] Using Threads?

2000-12-08 Thread Bruce Momjian
-- Start of PGP signed section. > On Mon, Nov 27, 2000 at 11:42:24PM -0600, Junfeng Zhang wrote: > > I am new to postgreSQL. When I read the documents, I find out the Postmaster > > daemon actual spawns a new backend server process to serve a new client > > request. Why not use threads instead? Is

Re: [HACKERS] Using Threads?

2000-12-08 Thread Tom Lane
Bruce Momjian <[EMAIL PROTECTED]> writes: >> There is no difference. If anything bad happens with the current >> multi-process server, all the postgres backends shutdown because the >> shared memory may be corrupted. > Yes. Are we adding reliability with per-process backends. Yes, we are: the

Re: [HACKERS] Using Threads?

2000-12-08 Thread Bruce Momjian
> All the major operating systems should have POSIX threads implemented. > Actually this can be configurable--multithreads or one thread. > > Thread-only server is unsafe, I agree. Maybe the following model can be a > little better. Several servers, each is multi-threaded. Every server can > supp

Re: [HACKERS] Using Threads?

2000-12-08 Thread Bruce Momjian
> Bruce Guenter <[EMAIL PROTECTED]> writes: > > [ some very interesting datapoints ] > > > > So, forking a process with lots of data is expensive. However, most of > > the PostgreSQL data is in a SysV IPC shared memory segment, which > > shouldn't affect the fork numbers. > > I believe (but don'

Re: [HACKERS] Using Threads?

2000-12-08 Thread Bruce Momjian
> Adam Haberlach writes: > > Typically (on a well-written OS, at least), the spawning of a thread > > is much cheaper then the creation of a new process (via fork()). > > This would be well worth testing on some representative sample > systems. > > Within the past year and a half at one of my gi

Re: [HACKERS] Using Threads?

2000-12-08 Thread Bruce Momjian
> > On Mon, 4 Dec 2000, Junfeng Zhang wrote: > > > All the major operating systems should have POSIX threads implemented. > > Actually this can be configurable--multithreads or one thread. > > I don't understand this. The OS can be configured for one thread? How > would that be any of use?

Re: [HACKERS] Using Threads?

2000-12-05 Thread Bruce Guenter
On Tue, Dec 05, 2000 at 02:52:48PM -0500, Tom Lane wrote: > There aren't going to be all that many data pages needing the COW > treatment, because the postmaster uses very little data space of its > own. I think this would become an issue if we tried to have the > postmaster pre-cache catalog inf

Re: [HACKERS] Using Threads?

2000-12-05 Thread Tom Lane
[EMAIL PROTECTED] writes: > The process vs threads benchmark which showed 160us vs 120us, only did > the process creation, not the delayed hit of the "copy on write" pages > in the new process. Just forking is not as simple as forking, once the > forked process starts to work, memory that is not e

Re: [HACKERS] Using Threads?

2000-12-05 Thread markw
I have been watching this thread vs non-threaded discussion and am completely with the process-only crew for a couple reasons, but lets look at a few things: The process vs threads benchmark which showed 160us vs 120us, only did the process creation, not the delayed hit of the "copy on write" pag

Re: [HACKERS] Using Threads?

2000-12-05 Thread Bruce Guenter
On Mon, Dec 04, 2000 at 08:43:24PM -0800, Tom Samplonius wrote: > Some OSes (Linux is the main one) implement threads as pseudo processes. > Linux threads are processes with a shared address space and file > descriptor table. > > Context switch cost for threads can be lower if you are switchi

Re: [HACKERS] Using Threads?

2000-12-05 Thread Bruce Guenter
On Tue, Dec 05, 2000 at 10:07:37AM +0100, Zeugswetter Andreas SB wrote: > > And using the following program for timing thread creation > > and cleanup: > > > > #include > > > > threadfn() { pthread_exit(0); } > > I think you would mainly need to test how the system behaves, if > the threads

AW: [HACKERS] Using Threads?

2000-12-05 Thread Zeugswetter Andreas SB
> And using the following program for timing thread creation > and cleanup: > > #include > > threadfn() { pthread_exit(0); } I think you would mainly need to test how the system behaves, if the threads and processes actually do some work in parallel, like: threadfn() {int i; for (i=0; i<10

Re: [HACKERS] Using Threads?

2000-12-04 Thread Tom Samplonius
On Mon, 4 Dec 2000, Junfeng Zhang wrote: > All the major operating systems should have POSIX threads implemented. > Actually this can be configurable--multithreads or one thread. I don't understand this. The OS can be configured for one thread? How would that be any of use? > Thread-only s

Re: [HACKERS] Using Threads?

2000-12-04 Thread Tom Lane
Bruce Guenter <[EMAIL PROTECTED]> writes: > [ some very interesting datapoints ] > > So, forking a process with lots of data is expensive. However, most of > the PostgreSQL data is in a SysV IPC shared memory segment, which > shouldn't affect the fork numbers. I believe (but don't have numbers t

Re: [HACKERS] Using Threads?

2000-12-04 Thread Myron Scott
I would love to distribute this code to anybody who wants it. Any suggestions for a good place? However, calling the work a code redesign is a bit generous. This was more like a brute force hack. I just moved all the connection related global variables to a thread local "environment variable"

Re: [HACKERS] Using Threads?

2000-12-04 Thread Lamar Owen
Matthew wrote: > The primary advantage that I see is that a single postgres process > can benefit from multiple processors. I see little advantage to using thread > for client connections. Multiprocessors best benefit multiple backends. And the current forked model lends itself admirably

Re: [HACKERS] Using Threads?

2000-12-04 Thread Bruce Guenter
On Mon, Dec 04, 2000 at 02:30:31PM -0800, Dan Lyke wrote: > Adam Haberlach writes: > > Typically (on a well-written OS, at least), the spawning of a thread > > is much cheaper then the creation of a new process (via fork()). > This would be well worth testing on some representative sample > system

RE: [HACKERS] Using Threads?

2000-12-04 Thread Matthew
*snip* > > > > Once all the questions regarding "why not" have been answered, it would > > be good to also ask "why use threads?" Do they simplify the code? Do > > they offer significant performance or efficiency gains? What do they > > give, other than being buzzword compliant? >

Re: [HACKERS] Using Threads?

2000-12-04 Thread Bruce Guenter
On Mon, Dec 04, 2000 at 03:17:00PM -0800, Adam Haberlach wrote: > Typically (on a well-written OS, at least), the spawning of a thread > is much cheaper then the creation of a new process (via fork()). Unless I'm mistaken, the back-end is only forked when starting a new connection, in which

Re: [HACKERS] Using Threads?

2000-12-04 Thread Dan Lyke
Adam Haberlach writes: > Typically (on a well-written OS, at least), the spawning of a thread > is much cheaper then the creation of a new process (via fork()). This would be well worth testing on some representative sample systems. Within the past year and a half at one of my gigs some coworker

Re: [HACKERS] Using Threads?

2000-12-04 Thread Adam Haberlach
On Mon, Dec 04, 2000 at 02:28:10PM -0600, Bruce Guenter wrote: > On Mon, Nov 27, 2000 at 11:42:24PM -0600, Junfeng Zhang wrote: > > I am new to postgreSQL. When I read the documents, I find out the Postmaster > > daemon actual spawns a new backend server process to serve a new client > > request.

Re: [HACKERS] Using Threads?

2000-12-04 Thread Junfeng Zhang
All the major operating systems should have POSIX threads implemented. Actually this can be configurable--multithreads or one thread. Thread-only server is unsafe, I agree. Maybe the following model can be a little better. Several servers, each is multi-threaded. Every server can support a maximu

Re: [HACKERS] Using Threads?

2000-12-04 Thread Bruce Guenter
On Mon, Nov 27, 2000 at 11:42:24PM -0600, Junfeng Zhang wrote: > I am new to postgreSQL. When I read the documents, I find out the Postmaster > daemon actual spawns a new backend server process to serve a new client > request. Why not use threads instead? Is that just for a historical reason, > or

Re: [HACKERS] Using Threads?

2000-12-04 Thread Tom Lane
The Hermit Hacker <[EMAIL PROTECTED]> writes: >> Why not use threads instead? Is that just for a >> historical reason, or some performance/implementation concern? > Several reasons, 'historical' probably being the strongest right now > ... since PostgreSQL was never designed for threading, its ab

Re: [HACKERS] Using Threads?

2000-12-04 Thread The Hermit Hacker
if we were to do this in steps, I beliee that one of the major problems irght now is that we have global variables up the wazoo ... my 'thread-awareness' is limited, as I've yet to use them, so excuse my ignorance ... if we got patches that cleaned up the code in stages, moving towards a cleaner

Re: [HACKERS] Using Threads?

2000-12-04 Thread Ross J. Reedstrom
Myron - Putting aside the fork/threads discussion for a moment (the reasons, both historical and other, such as inter-backend protection, are well covered in the archives), the work you did sounds like an interesting experiment in code redesign. Would you be willing to release the hacked code som

Re: [HACKERS] Using Threads?

2000-12-04 Thread The Hermit Hacker
On Mon, 27 Nov 2000, Junfeng Zhang wrote: > Hello all, > > I am new to postgreSQL. When I read the documents, I find out the > Postmaster daemon actual spawns a new backend server process to serve > a new client request. Why not use threads instead? Is that just for a > historical reason, or som

Re: [HACKERS] Using Threads?

2000-12-04 Thread Myron Scott
I maybe wrong but I think that PGSQL is not threaded mostly due to historical reasons. It looks to me like the source has developed over time where much of the source is not reentrant with many global variables throughout. In addition, the parser is generated by flex which can be made to generat

Re: [HACKERS] Using Threads?

2000-12-04 Thread Karel Zak
On Mon, 27 Nov 2000, Junfeng Zhang wrote: > Hello all, > > I am new to postgreSQL. When I read the documents, I find out the Postmaster > daemon actual spawns a new backend server process to serve a new client > request. Why not use threads instead? Is that just for a historical reason, > or som

[HACKERS] Using Threads?

2000-12-03 Thread Junfeng Zhang
Hello all, I am new to postgreSQL. When I read the documents, I find out the Postmaster daemon actual spawns a new backend server process to serve a new client request. Why not use threads instead? Is that just for a historical reason, or some performance/implementation concern? Thank you very m