in reply to Re^5: Libxml parser cosuming 100% cpu
in thread Libxml parser cosuming 100% cpu

I want to know the reason why cpu usage is 100%. how to make a execution more fast without consuming 100% cpu. or maybe i have doing something wrong that can i avoided have you u seen my sudo code ?

Replies are listed 'Best First'.
Re^7: Libxml parser cosuming 100% cpu
by haukex (Archbishop) on Aug 11, 2018 at 13:46 UTC
    I want to know the reason why cpu usage is 100%. how to make a execution more fast without consuming 100% cpu. or maybe i have doing something wrong that can i avoided have you u seen my sudo code ?

    Since you haven't shown the actual code you're running (or any input data), or at least a representative sample (SSCCE), we unfortunately can't tell you why your code is running "slow" (Update: there might not even be a way to significantly speed it up without different hardware). For now, we can just tell you how to measure it yourself (e.g. Devel::NYTProf). There could be things you're doing in code that you haven't shown here that are slowing it down (for example, you didn't show the code you use to split the @lines array into chunks, except that you might be using string concatenation, and you haven't explained why you've got a @lines array in the first place, instead of a while(<$filehandle>) loop).

Re^7: Libxml parser cosuming 100% cpu
by ikegami (Patriarch) on Aug 11, 2018 at 13:23 UTC

    It's running at 100% because it doesn't waste time waiting for the disk, waiting for packets, etc.

    Again, making it use less CPU will necessarily make it slower

    And yes, I saw your pseudocode. It says you are parsing and extracting data from 100,000 XML documents in 2.5 minutes, which is one every 0.015 seconds, which I think is quite fast.

    If you really want to reduce the time needed, you should rethink how you store your data in order to avoid parsing 100,000 XML documents. Alternately, parallelize the program and throw more CPUs at it. (For example, Having 10 cores do 10,000 XML docs each could reduce the time from 2.5 minutes to as little as 15 seconds.)