Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

getting more resource from perl

by jesuashok (Curate)
on Nov 09, 2005 at 15:26 UTC ( [id://507093]=perlquestion: print w/replies, xml ) Need Help??

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

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: getting more resource from perl
by ikegami (Patriarch) on Nov 09, 2005 at 16:14 UTC

    You may want to search for "priority" and "nice". Those are both related terms. I cam accross these two solutions:

    For some/many unixes, Proc::ProcessTable::Process provides the method priority.

    For Windows,

    use Win32::Process; my $obj; Win32::Process::Open($obj, $$, 0); $obj->SetPriorityClass(HIGH_PRIORITY_CLASS);

    By the way, trying to get *more* CPU is not likely to make your script execute faster on a desktop system (if that's what you have). Desktop systems tend to be idle almost all the time, so there's no CPU time to steal from other applications. Needing more CPU is usually a sign of inefficient code and/or of a need of better hardware. All too often the former.

    Update: Searched and found a unix and Windows module. Updated the node accordingly.

Re: getting more resource from perl
by marto (Cardinal) on Nov 09, 2005 at 15:40 UTC
    I believe that jesuashok wants to get the script to use more CPU resource so that it will execute faster.
    This topic has been touched on in the past, a Super Search for something like 'increase cpu' would return the results of the previous questions.

    Hope this helps.

    Martin
    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: getting more resource from perl
by jeffa (Bishop) on Nov 09, 2005 at 16:18 UTC

    I have used BSD::Resource in the past to do the opposite of what you want -- to limit the amount of CPU a process can hog. Usually, if i need more CPU resources ... i buy more RAM and/or a faster CPU.

    Questions: What is the real problem? Are you really sure that you need more CPU resources? Are you sure that your problem can't be solved by optimizing your code instead? Can you show us the code you are working with?

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)
    
Re: getting more resource from perl
by Fletch (Bishop) on Nov 09, 2005 at 15:31 UTC

    Erm . . . /boggle

    Congratulations, this is so obscure and poorly woorded I can't even come up with a starting point to make a sarcastic comment to that effect.

Re: getting more resource from perl
by QM (Parson) on Nov 09, 2005 at 22:53 UTC
    You may be asking the wrong question.

    Why do you need more CPU time? Is your process not getting all available time? Is it competing with other processes? (If so, why can't those other processes use less time?)

    Is the process IO bound? If so, getting more CPU time won't help. One way to check this is to simulate all IO by generating fake data for the process to chew on, but don't read or write from disk or other resources outside of the CPU/memory group. If the process suddenly speeds up by an order of magnitude, you need faster IO, not more CPU time. On the other hand, if simulating IO doesn't change the behavior, then either the process is swapping memory to disk, or it's CPU bound.

    If it's CPU bound, do you know why? What part of the process is taking the most time? Have you profiled it with one of the Devel profiling modules? (My favorite is Devel::SmallProf, though there are others with different strengths.])

    You might also look at How (Not) To Ask A Question.

    -QM
    --
    Quantum Mechanics: The dreams stuff is made of

Re: getting more resource from perl
by duff (Parson) on Nov 09, 2005 at 15:58 UTC

    You want your program to get access to more resources by issuing some non-OS-command in your program? No, you can't do this.

      In unix terminology, "command" means executable. You're thinking of system calls. Basically, the OP wants a function or module that does the same as nice. It would have been nice if had specified the OS on which this script will run.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://507093]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2024-03-28 15:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found