in reply to Libxml parser cosuming 100% cpu

So you're saying it takes 2.5 minutes to parse and extract information from 10,000 XML documents. That's only 15 milliseconds per document! I'm thinking "Holy shit that's fast!"

Replies are listed 'Best First'.
Re^2: Libxml parser cosuming 100% cpu
by geek2882 (Initiate) on Aug 11, 2018 at 13:05 UTC
    actually i have xml files of 10 lakhs tags. my script take 2.5 min to complete their job.simply i store the files lines into a array and run loop.i give 100 lines to libxml parser so each time parser process 100lines string this job continue untill the loop finish.Now problem is cpu usage which 100% till the job finish.my point is how can i reduce it without sleep command

      You bring up 100% CPU as if it's a bad thing again, but 100% CPU is a good thing. It means no time is being wasted waiting for I/O.

      Think of it this way: Would you rather have an employee that works at 100% of the time they are at work, or 50%?

        Actually there are other task which are getting slower or terminate because of not available of cpu. do you think this is right to be 100% cpu usagre now ?
      From your code so far, you read 1 million lines and then use a very inefficient method (lot of CPU and lot of memory) to make a string variable of those lines.

      I don't understand exactly what you mean by 100% CPU? My Windows machine has 4 cores which essentially means 4 CPU's that share a common big memory space.

      Unix is a time sharing O/S. Other processes will get CPU time even if one process is completely compute bound.

      I am not sure about these various XML Perl libs, but every time that your program runs an I/O operation, the O/S scheduler will run. Maybe use something that takes less memory and does more I/O? Every time you do an I/O operation, the O/S scheduler will run.