Re: How to reduce CPU usage in a cycle? [ag]

From: Date: Thu, 11 Dec 2003 16:42:43 +0000
Subject: Re: How to reduce CPU usage in a cycle? [ag]
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-172489@lists.php.net to get a copy of this message
Personally, I wouldn't worry about it unless it is actually interfering with other processes. The OS will give any process or thread 100% of the CPU if there is nothing else that needs the CPU. What does you context switching numbers look like? If there is a lot of context switching, then your processes or threads are getting kicked off the CPU before they can accomplish much. And that's a problem. The duration of your script is less than a second, so that's not really a long enough time have an affect on other parts of the system. Heck, it may even being completing within just a couple of time slices (the length of time the OS allows a process/thread to use the CPU). You could always adjust the priority level (nice value in Unix) of whatever PHP is running under (i.e. Apache). Although you should understand what you are doing if you are adjusting nice values. On Dec 11, 2003, at 10:03 AM, TauAlex wrote:
Hello! I'm having a problem with my php script on my linux web server. In that script there is a cycle with some math calculations (about ~30 steps), the execution time is less 1 second, but the script loads the server CPU up to 90%... I've optimized script already to the minimum math function, anyway, it still overloads the CPU. How can I reduce the CPU load? It seems that usleep() does not help much, especially in Windows (it's not supported). How can I give system a portion of time in the end of each step (I don't mind if it will increase the job time)? Is there a solution for both Windows and Linux? -- Brent Baisley Systems Architect Landover Associates, Inc. Search & Advisory Services for Advanced Technology Environments p: 212.759.6400/800.759.0577


« previous php.general (#172489) next »