Dear Monks,

I'm designing a cross-platform application that will be able to fork processes but I don't want it to be a big CPU eater. Anybody have a good way to do so reliably?

CPAN says Sys::Load fails on Windows quite a bit, though there might be something accessible by Win32::API. Now I'm thinking of checking how long it takes to execute a command as processes are added but I'm not sure this will reflect actual niceness wrt other apps. Any experience here?

One option I suppose would be to give up and just specify a maximum number of processes, like apache does in its config file. Or some kind of concurrent scheduler for which you can dial the relative niceness. But I'd rather have as little configuration and as much intelligence as possible. Pure perl would also be a plus.

The end result would automatically keep it down to a small number of processes on a slow machine (or maybe at a time when cpu load is high for some reason) but would not blink at launching many processes if resources are available. Thanks for your help.

Matt


In reply to Checking system cpu load when forking? by mattr

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.