in reply to Is 100% CPU utilisation during a procees is aproblem?
Is 100% CPU utilisation during a procees is aproblem?
I don't know, is it? Is your server overheating? Is the process hindering your server from working properly?
You haven't shown any code, so we don't know whether the run time or CPU utilization is normal for the tasks your script is performing or it could be optimized. You might want to try profiling your code with something like Devel::NYTProf to see if there are spots in the code worth optimizing.
Lastly, try
use less 'CPU';
(just kidding)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Is 100% CPU utilisation during a procees is aproblem?
by Ankur_kuls (Sexton) on Nov 25, 2014 at 08:04 UTC | |
Hi All, thanks for reply. Below is the first part of my code where script is creating a sqlite database, manipulating the data of 3gb file and then storing it into the database..as I start running script CPU usage reaches 99-100%.. so this part has the problem..
here AH is my 3 gb file.. script manipulates it line by line and forms a hash which stores the values to be filled into the database...<\p> | [reply] [d/l] |
by BrowserUk (Patriarch) on Nov 25, 2014 at 17:47 UTC | |
By far the greatest amount of time is being spent evaling the data structure into existence:
There's not a lot you can do about that. Writing your own parser would be complicated, error prone and almost certainly eons slower. The second largest amount of time is being spent building and executing those two complicated SQL statements:
Now that you can do something about. By pre-preparing the statement using placeholders:
and then binding the vars when executing the statement:
Not only will you give the DB engine the best chance of performing the inserts optimally; you can also make your code look a lot cleaner and simpler to maintain. It won't reduce your cpu usage; but it should result in your program finishing more quickly. I hope you'll agree this is much nicer to look at and understand:
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.
| [reply] [d/l] [select] |
by Ankur_kuls (Sexton) on Nov 26, 2014 at 05:30 UTC | |
Thanks a lot for your efforts I will apply these changes and let you know the outcomes. meanwhile I ran the same script on my sunSO server and surprising there it was taking only 4 to 5% of cpu..on the other hand on my Linux server it was taking 99 to 100%.. why there is such a large difference... and it also shows that there is not much wrong with our script.. also please fiind my server details. Linux server where I am supposed to run the script and its causing issues...
details of solaris server where script is running fine
| [reply] [d/l] [select] |
by Corion (Patriarch) on Nov 26, 2014 at 07:42 UTC | |
by Ankur_kuls (Sexton) on Nov 26, 2014 at 09:59 UTC | |
Hi All, I am not able to reply on Corion's answer.. so please help me getting this clarification....as per his reply, it means that CPU usage on my linux machine is only around 25%. There is no problem with my script and I can go ahead with this? | [reply] |
by BrowserUk (Patriarch) on Nov 26, 2014 at 12:51 UTC | |
by Anonymous Monk on Nov 26, 2014 at 10:48 UTC | |
by Anonymous Monk on Nov 26, 2014 at 10:53 UTC | |
by poj (Abbot) on Nov 25, 2014 at 09:29 UTC | |
| [reply] |
by Ankur_kuls (Sexton) on Nov 25, 2014 at 09:33 UTC | |
below are the sample of two rows from the 3gb input file.
| [reply] [d/l] |