9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Uriel <uriel99@gmail.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] threads vs forks
Date: Tue,  3 Mar 2009 16:32:32 +0100	[thread overview]
Message-ID: <5d375e920903030732i12f95d0ft8c3ddf579fbeed9f@mail.gmail.com> (raw)
In-Reply-To: <3e1162e60903030719v141b41e9ma5fd98c73d8b0e7c@mail.gmail.com>

Python 'threads' are the same pthreads turds all other lunix junk
uses. The only difference is that the interpreter itself is not
threadsafe, so they have a global lock which means threads suck even
more than usual.

Forking a python interpreter is a *bad* idea, because python's start
up takes billions of years. This has nothing to do with the merits of
fork, and all with how much python sucks.

There is Stackless Python, which has proper CSP threads/procs and
channels, very similar to limbo.

http://www.stackless.com/

But that is too sane for the mainline python folks obviously, so they
stick to the pthrereads turds, ...

My advice: unless you can use Stackless, stay as far away as you can
from any concurrent python stuff. (And don't get me started on twisted
and their event based hacks).

Oh, and as I mentioned in another thread, in my experience if you are
going to fork, make sure you compile statically, dynamic linking is
almost as evil as pthreads. But this is lunix, so what do you expect?

uriel

On Tue, Mar 3, 2009 at 4:19 PM, David Leimbach <leimy2k@gmail.com> wrote:
>
>
> On Tue, Mar 3, 2009 at 3:52 AM, hugo rivera <uair00@gmail.com> wrote:
>>
>> Hi,
>> this is not really a plan 9 question, but since you are the wisest
>> guys I know I am hoping that you can help me.
>> You see, I have to launch many tasks running in parallel (~5000) in a
>> cluster running linux. Each of the task performs some astronomical
>> calculations and I am not pretty sure if using fork is the best answer
>> here.
>> First of all, all the programming is done in python and c, and since
>> we are using os.fork() python facility I think that it is somehow
>> related to the underlying c fork (well, I really do not know much of
>> forks in linux, the few things I do know about forks and threads I got
>> them from Francisco Ballesteros' "Introduction to operating system
>> abstractions").
>
> My knowledge on this subject is about 8 or 9 years old, so check with your local Python guru....
> The last I'd heard about Python's threading is that it was cooperative only,
> and that you couldn't get real parallelism out of it.  It serves as a means
> to organize your program in a concurrent manner.
> In other words no two threads run at the same time in Python, even if you're
> on a multi-core system, due to something they call a "Global Interpreter
> Lock".
>
>>
>> The point here is if I should use forks or threads to deal with the job at
>> hand?
>> I heard that there are some problems if you fork too many processes (I
>> am not sure how many are too many) so I am thinking to use threads.
>> I know some basic differences between threads and forks, but I am not
>> aware of the details of the implementation (probably I will never be).
>> Finally, if this is a question that does not belong to the plan 9
>> mailing list, please let me know and I'll shut up.
>> Saludos
>
> I think you need to understand the system limits, which is something you can
> look up for yourself.  Also you should understand what kind of runtime model
> threads in the language you're using actually implements.
> Those rules basically apply to any system.
>
>>
>> --
>> Hugo
>>
>
>



  reply	other threads:[~2009-03-03 15:32 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-03 11:52 hugo rivera
2009-03-03 15:19 ` David Leimbach
2009-03-03 15:32   ` Uriel [this message]
2009-03-03 16:15     ` hugo rivera
2009-03-03 15:33   ` hugo rivera
2009-03-03 18:11   ` Roman V. Shaposhnik
2009-03-03 18:38     ` Bakul Shah
2009-03-06 18:47       ` Roman V Shaposhnik
2009-03-06 20:38         ` David Leimbach
2009-03-07  8:00           ` Bakul Shah
2009-03-07  0:21         ` Bakul Shah
2009-03-07  2:20           ` Brian L. Stuart
2009-03-03 23:08     ` J.R. Mauro
2009-03-03 23:15       ` Uriel
2009-03-03 23:23         ` J.R. Mauro
2009-03-03 23:54           ` Devon H. O'Dell
2009-03-04  0:33             ` J.R. Mauro
2009-03-04  0:54               ` erik quanstrom
2009-03-04  1:54                 ` J.R. Mauro
2009-03-04  3:18                   ` James Tomaschke
2009-03-04  3:30                     ` erik quanstrom
2009-03-04  4:44                       ` James Tomaschke
2009-03-04  5:05                         ` J.R. Mauro
2009-03-04  5:50                           ` erik quanstrom
2009-03-04  6:08                             ` andrey mirtchovski
2009-03-04 16:52                             ` J.R. Mauro
2009-03-04 17:14                               ` ron minnich
2009-03-04 17:27                                 ` William Josephson
2009-03-04 18:15                                 ` erik quanstrom
2009-03-05  3:32                                 ` J.R. Mauro
2009-03-05  3:39                                   ` erik quanstrom
2009-03-05  3:55                                   ` William K. Josephson
2009-03-05  4:00                                     ` erik quanstrom
2009-03-05  4:16                                       ` William K. Josephson
2009-03-07  3:01                                         ` William Josephson
2009-03-07  3:31                                           ` erik quanstrom
2009-03-07  6:00                                             ` William Josephson
2009-03-07 13:58                                               ` erik quanstrom
2009-03-07 14:37                                                 ` William Josephson
2009-03-07 15:05                                                   ` erik quanstrom
2009-03-07 15:28                                                     ` William K. Josephson
2009-03-07  5:00                                           ` lucio
2009-03-07  5:08                                             ` William Josephson
2009-03-07  5:19                                               ` erik quanstrom
2009-03-07  5:45                                                 ` [9fans] Flash William K. Josephson
2009-03-07 14:42                                                   ` erik quanstrom
2009-03-07 14:56                                                     ` William Josephson
2009-03-07 15:39                                                     ` Russ Cox
2009-03-07 16:34                                                       ` erik quanstrom
2009-03-07  5:24                                               ` [9fans] threads vs forks lucio
2009-03-04  5:19                   ` David Leimbach
2009-03-04  2:47                 ` John Barham
2009-03-04  5:24                 ` blstuart
2009-03-04  5:37                   ` erik quanstrom
2009-03-04 16:29                   ` Roman V Shaposhnik
2009-03-04 16:56                   ` john
2009-03-06  9:39             ` maht
2009-03-04  5:07     ` David Leimbach
2009-03-04  5:35     ` John Barham
2009-03-03 16:00 ` ron minnich
2009-03-03 16:28   ` hugo rivera
2009-03-03 17:31     ` ron minnich
2009-03-03 16:47 ` John Barham
2009-03-04  9:37   ` Vincent Schut
2009-03-04  9:58     ` hugo rivera
2009-03-04 10:30       ` Vincent Schut
2009-03-04 10:45         ` hugo rivera
2009-03-04 11:15           ` Vincent Schut
2009-03-04 11:33             ` hugo rivera
2009-03-04 13:23               ` Uriel
2009-03-04 14:57         ` ron minnich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5d375e920903030732i12f95d0ft8c3ddf579fbeed9f@mail.gmail.com \
    --to=uriel99@gmail.com \
    --cc=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).