http://www.perlmonks.org?node_id=995803


in reply to Re: dynamic number of threads based on CPU utilization
in thread dynamic number of threads based on CPU utilization

Remember, the work being done here is I/O-bound, not CPU bound.

Why are you doing this?

For 90%+ of the runtime of the OPs program, IT IS CPU BOUND NOT IO BOUND.

So do just stop regurgitating your useless, pointless, irrelevant, and gratuitously incorrect home-spun wisdoms.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

RIP Neil Armstrong

Replies are listed 'Best First'.
Re^3: dynamic number of threads based on CPU utilization
by mabossert (Scribe) on Sep 26, 2012 at 16:38 UTC

    my apologies...I thought that since the procXml sub worked just fine, it would not be relevant to the discussion or potential solution. Within the procXml sub, I simply slurp the file into a hash, then operate on the hash.

    I was under the impression that because I was operating on the file contents in memory (i.e. the hash), it was a mostly CPU-bound process (minus slurping the input file and printing to the output file.

      .I thought that since the procXml sub worked just fine, it would not be relevant to the discussion or potential solution.

      You were mostly right. The only relevance it has is that nowhere in that code do I see any sign of locking (the keyword 'lock' does not appear), which means that multiple threads are writing to a shared hash and there is nothing to prevent them from corrupting data through collisions.

      You may 'get away with it', but I wouldn't want to be responsible for when things go wrong.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

      RIP Neil Armstrong

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