No such thing as a small change | |
PerlMonks |
Re: Threading vs perlby ph713 (Pilgrim) |
on Jun 24, 2005 at 21:06 UTC ( [id://469825]=note: print w/replies, xml ) | Need Help?? |
I have recently been through the process of coding two rather large private perl projects where I really, really, *wanted* to use threads from perl, because a threaded model mapped very well to my problem space. So let me tell you what I found out during those projects, and what I wish for:
1) Perl ithreads are only just starting to stabilize. If you expect your installed base to include Bob's Old Redhat Box with perl 5.8.0 (or worse, 5.6.x on it), just forget about threads right now and save yourself a lot of greif. 2) perldoc perlthrtut has a section that concludes with a very important statement: "Perl Threads Are Different.". All I really wanted was POSIX-style threads. I was prepared to properly deal with locking and mutexes and the whole nine yards. My Operating System supports POSIX-style threads in C, but perl's threading is a completely different beast. I'm sure it was done this way in some hope of having nearly-identical threading behavior across a wide array of underlying threads implementations, but I have to conclude that it sucks. At many times during the 2nd project, I seriously considered just starting over in C and building up some libraries and macros to make the code nearly as compact as perl, and using some standard regex library to make up for that part. In the end the compromise I ended up making (in both cases) was to use a multi-process model and "share" data via freeze/thaw over the top of various IPC mechanisms (sysv shm, semaphores, disk files w/ locks - at one point I even invented my own perl message queueing module to handle inter-process message-passing with disk-persistence). The whole thing left a bad taste in my mouth. My projects are considerably less efficient at what they do than they would have been if ithreads had turned out to be what I hoped it was - a mirror of the underlying posix threads layers. What do I want out of perl threading? I want all data to be shared by default when a thread spawns from another. I want to be forced to explicitly declare thread-local storage. If you're going to force me to explicitly share data, I want shared data to be transparent and completely functional. Doing share($x), and finding that $x->{foo}->{bar}->[3]->{zip} is not in fact shared, sucks. I want POSIX threading, exposed through perl, to operate basically just like it does in C. Is it so much to ask for?
In Section
Meditations
|
|