Canadian_Chris has asked for the wisdom of the Perl Monks concerning the following question:

Hi all!


BACKGROUND ON PROBLEM / PAST ATTEMPTS:
I've been trying to do some inter process communication with perl on win32 to no avail. This is for a bot that is going to do indexing of web sites for a search engine. The current architecture is for ~805 concurrent processes (23 perl interpreters with 35 forked processes each) per box. This seems to be working without much of a dent to the resources, the only problem is doing the actual IPC. I've tried tcpip with a server process per each process but it isn't fast enough (can't leave the socket open or we over run the io::select limit per process), Win32::Pipe worked great until the HUGE memmory hole was found that filled up the 8GB commit charge cache secretly and brought the box down to it's knees.

CURRENT ATTEMPT / PROBLEM:
Now I'm trying to use perl's native "pipe" function which is supported in win32 perl. I can't seem to get it to fork off more than 2 processes without closing down the pipes, it seems to "block" after 2 processes. Any tips on how to get this to work / a better option?

Thanks for all your help in advance!

-Chris


TEST SCRIPT TO ILLUSTRATE PROBLEM:
# Example of pipe problem # Useage: perl pipetest.pl 2 # $ARV[0] represents how many processes to fork off, run with 2 and it + will # send a line of text from the main process and print it to STDOUT pipe READ1, WRITE1; pipe READ2, WRITE2; pipe READ3, WRITE3; pipe READ4, WRITE4; pipe READ5, WRITE5; for(1..$ARGV[0]) { $forke++; my $pid; if($pid = fork) { # parent $| = 1; $SIG{CHLD} = 'IGNORE'; if ($forke == $ARGV[0]) {&server;} } else { $| = 1; # child die "cannot fork :$!" unless defined $pid; print "Forked $forke\n"; for (;;) { $read_pipe="READ$forke"; while (<$read_pipe>) {print "Child $forke: parent said \"$_\"\n"}; } } } sub server { $t=0; for (1..5) {$t++; $write_pipe="WRITE$t"; select($write_pipe); $|=1; print "TESTING 1 2 3\n"; } }

Replies are listed 'Best First'.
Re: Pipe w/ fork on Win32
by jryan (Vicar) on May 31, 2002 at 05:57 UTC
    Give Net::Shared a look. It was designed to simulate shared memory across a large amount of forked processes by creating a central location to store data, accessable by all children processes. It was actually originally designed for Win32, although it now works on any platform. One warning, though: it still is considered beta quality, meaning that the interface is a bit clunky; however, there are a bunch of examples included in the distribution and the tech support is as simple as contacting the author.
Re: Pipe w/ fork on Win32
by alien_life_form (Pilgrim) on May 31, 2002 at 13:10 UTC
    Greetings,

    A consensus appear to exist on the fact that the current forking emulation under Win32 sort of... how would I put this.. sucks.

    A thread on perlmonks a few days back pointed out that a number of behaviours of fork are not replicated exactly or at all (given that the emulation is using threads, there is a whole lot of things that stay shared and would actually be duplicated in a real fork...)

    That may be the root of your problem. I surely never had any fork() luck on Win32.
    Cheers,
    alf


    You can't have everything: where would you put it?