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

Hello, I am new to using activeperl for my perl compiler as we just moved some services to a win2003 machine. I have a few scripts that are doing massive amounts of looping and comparing and sorting various data. This is a very CPU intensive activity, and Perl does a wonderful job at it, except on the win2003 machine.

The issue is that once this script is running and cranking the data, it is only using 25% of the CPU. The CPU is an Intel core2 Quad and when I look at the resource meter, it is only using 1 of the 4 available "CPUs". I am suspecting that is why it is taking much longer to run these scripts on the windows machine as compared to our Linux boxes.

How can I tell activeperl to use all the "CPUs" or all the CPU capacity of the machine. I have searched this and found no real answers about it. I am looking at the monks for help.

Windows Server 2003 32bit, 4GB ram, ActivePerl 5.10.

Thanks.
(this was also posted at perl guru without any response, please forgive the "cross post")
  • Comment on Windows Sloooow. Not using full CPU, why?

Replies are listed 'Best First'.
Re: Windows Sloooow. Not using full CPU, why?
by moritz (Cardinal) on Jul 29, 2008 at 16:55 UTC
    Perl can't automatically make execution of builtins run parallel on multiple processors.

    So your best bet is to use threads to parallelize it manually. But beware that it might not very easy, depending on what your program actually does.

    But it makes me wonder - why does it work fast on the linux boxes? I'm pretty sure it works on just one CPU there as well.

    Or maybe your bottleneck is somewhere else, like slow external resources? Try to profile your program (and look at the wallclock seconds, not just at the CPU seconds).

Re: Windows Sloooow. Not using full CPU, why?
by MidLifeXis (Monsignor) on Jul 29, 2008 at 16:53 UTC

    Question - are your Linux boxes multicore as well? Are the perl programs using all of the cores on the Linux machines, or just bouncing from one to another?

    Unless you have broken your data or code into parts that can be run in separate pieces, and then tell the OS / Perl to do that, it will not be done automatically. Most code, as written, will be compiled and run sequentially. It can be a black art to try to have the computer determine what can be paralellized.

    --MidLifeXis

Re: Windows Sloooow. Not using full CPU, why?
by runrig (Abbot) on Jul 29, 2008 at 16:53 UTC
    It's only using 1 CPU? Maybe because you're only running 1 process? Is there anything that can run in parallel? E.g., can you run more than one copy of the program?
Re: Windows Sloooow. Not using full CPU, why?
by Bloodnok (Vicar) on Jul 29, 2008 at 16:52 UTC
    I suppose the fact that Linux is an OS (c/w Windoze) isn't going to be much help, but I suspect that's what it comes down to.

    AFAIR, there's nothing AS can do to change the maneer in which the load is distributed across multi-processors.

    At last, a user level that overstates my experience :-))
Re: Windows Sloooow. Not using full CPU, why?
by BrowserUk (Patriarch) on Jul 29, 2008 at 18:20 UTC

    Closed: User problem.