Thread discussion

Started by Bruce Momjianover 23 years ago3 messages
#1Bruce Momjian
pgman@candle.pha.pa.us

There was an interesting thread/process discussion in the gproff
Slashdot discussion:

http://slashdot.org/article.pl?sid=02/07/05/1457231&mode=nested&tid=106

This guy had interesting comments:

http://slashdot.org/~pthisis/

Especially this comment:

http://slashdot.org/comments.pl?sid=35441&cid=3829377

-- 
  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
#2Dann Corbit
DCorbit@connx.com
In reply to: Bruce Momjian (#1)
Re: Thread discussion

-----Original Message-----
From: Bruce Momjian [mailto:pgman@candle.pha.pa.us]
Sent: Friday, July 05, 2002 7:59 PM
To: PostgreSQL-development
Subject: [HACKERS] Thread discussion

There was an interesting thread/process discussion in the gproff
Slashdot discussion:

http://slashdot.org/article.pl?sid=02/07/05/1457231&mode=neste

d&tid=106

This guy had interesting comments:

http://slashdot.org/~pthisis/

Especially this comment:

http://slashdot.org/comments.pl?sid=35441&cid=3829377

==================================================================
Which is pretty much pointless MS bashing and incorrect.

From the news:comp.programming.threads FAQ:

Q147: Thread create timings

Matthew Houseman writes:

Thought I'd throw this into the pyre. :) I ran the thread/process
create
stuff on a 166MHz Pentium (no pro, no mmx) under NT4 and Solaris x86
2.6:

NT spawn 240s 24.0 ms/spawn
Solaris spawn (fork) 123s 12.3 ms/spawn (incl. exec)
Solaris spawn (vfork) 95s 9.5 ms/spawn (incl. exec)

Solaris fork 47s 4.7 ms/fork
Solaris vfork 0.37 ms/vfork (37s/100000)

NT thread create 12s 1.2 ms/create
Solaris thread create 0.11 ms/create (11s/100000)

As you can see, I tried both fork() and vfork(). When doing an immediate
exec(), you'd normally use vfork(); when just forking, fork() is usually
what you want to use (or have to use).

Note that I had to turn the number of creates up to 100000 for vfork
and thread create to get better precision in the timings.

To remind you, here are greg's figures (on a Pentium MMX 200MHz):

NT Spawner (spawnl): 120 Seconds (12.0 millisecond/spawn)
Linux Spawner (fork+exec): 57 Seconds ( 6.0 millisecond/spawn)

Linux Process Create (fork): 10 Seconds ( 1.0 millisecond/proc)

NT Thread Create 9 Seconds ( 0.9 millisecond/thread)
Linux Thread Create 3 Seconds ( 0.3 millisecond/thread)

Just for fun, I tried the same thing on a 2 CPU 170MHz Ultrasparc.
I leave it to someone else to figure out how much of this is due to
the two CPUs... :)

Solaris spawn (fork) 84s 8.4 ms/spawn (incl. exec)
Solaris spawn (vfork) 69s 6.9 ms/spawn (incl. exec)

Solaris fork 21s 2.1 ms/fork
Solaris vfork 0.17 ms/vfork (17s/100000)

Solaris thread create 0.06 ms/create (6s/100000)

=================================TOP=============
Q148: Timing Multithreaded Programs (Solaris)

From: sullivan@aisg20a.erim.org (Richard Sullivan)

I'm trying to time my multithreaded programs on Solaris with multiple
processors. I want the real world running time as opposed to the total

execution time of the programming because I want to measure speedup

versus

sequential algorithms and home much faster the parallel program is for

the user.

Bradly,

Here is what I wrote to solve this problem (for Solaris anyway). To
use it just call iobench_start() after any setup that you don't want
to measure. When you are done measuring call iobench_end(). When you
want to see the statistics call iobench_report(). The output to
stderr will look like this:

Process info:
elapsed time 249.995
CPU time 164.446
user time 152.095
system time 12.3507
trap time 0.661235
wait time 68.6506
pfs major/minor 3379/ 0
blocks input/output 0/ 0

65.8% CPU usage

The iobench code is included in the program sources on: index.html.
=================================TOP=============

My opinion is that PostgreSQL does not have to exclusively fork() or
exclusively thread.
As Spike Lee said:
"Always do the right thing."

#3Bruce Momjian
pgman@candle.pha.pa.us
In reply to: Dann Corbit (#2)
Re: Thread discussion

Dann Corbit wrote:

Especially this comment:

http://slashdot.org/comments.pl?sid=35441&cid=3829377

==================================================================
Which is pretty much pointless MS bashing and incorrect.

Is there such a thing. ;-)

Anyway, the analysis of Solaris is meaningless. It is in the same camp
as NT as far as process creation bloat. I have always said threads help
on NT _and_ Solaris.

On Solaris, the thread popularity is there _because_ the OS is so slow
at process creation (SVr$ bloat), not necessarily because people really
want threads on Solaris.

NT Spawner (spawnl): 120 Seconds (12.0 millisecond/spawn)
Linux Spawner (fork+exec): 57 Seconds ( 6.0 millisecond/spawn)

Linux Process Create (fork): 10 Seconds ( 1.0 millisecond/proc)

NT Thread Create 9 Seconds ( 0.9 millisecond/thread)
Linux Thread Create 3 Seconds ( 0.3 millisecond/thread)

The Linux case is more interesting. The same guy had timings for thread
vs. process of 6usecs vs. 4usecs, but states that it really isn't even a
blip on the performance radar, and the coding required to do the stuff
in a threaded manner is a headache:

http://slashdot.org/article.pl?sid=02/07/05/1457231&tid=106

-- 
  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