Bug #70130 [Fbk->Asn]: usleep(1) CPU usage
| From: | saniafd93 at gmail dot com | Date: | Wed, 29 Jul 2015 05:28:41 +0000 |
| Subject: | Bug #70130 [Fbk->Asn]: usleep(1) CPU usage | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-194813@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=70130&edit=1
ID: 70130
User updated by: saniafd93 at gmail dot com
Reported by: saniafd93 at gmail dot com
Summary: usleep(1) CPU usage
-Status: Feedback
+Status: Assigned
Type: Bug
Package: SPL related
Operating System: Ubuntu 14.04
PHP Version: 5.5.27
Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
I didn't update to a new version, because the latest PHP version on production environment
(Ubuntu 14.04) was PHP 5.5.19 all the time. I was badly surprised by this bug in a LTS version.
Anyway, this is a strange behavior, because as I wrote, untill March all worked fine. CPU usage on
production Ubuntu 14.04 was ~1% with usleep(1); Same behavior now requires at least usleep(10000);
Previous Comments:
------------------------------------------------------------------------
[2015-07-28 23:46:34] cmb@php.net
> All worked nice untill March 2015, [...]
What do you mean by that? Did you update to a newer PHP version?
If so, which version did you use before, and which version do you
use now.
------------------------------------------------------------------------
[2015-07-24 17:11:09] saniafd93 at gmail dot com
I was wrong about number of cores. Here is new summary with processor models:
- 2core Windows 8.1 (Intel Pentium P6100 2.0 GHz)
usleep(1); // CPU usage: 0%-1.5%
usleep(10000); // CPU usage: 0%-1%
- 4core Windows 8.1 (Intel Core i3 4130 3.4 GHz)
usleep(1); // CPU usage: 0%-1%
usleep(10000); // CPU usage: 0%-1%
- 4core Ubuntu 14.04 (Intel Celeron J1900 2.0-2.42GHz)
usleep(1); // CPU usage: ~25%
usleep(10000); // CPU usage: ~5%
- 8core Ubuntu 14.04 (Intel Xeon E5506 2.13GHz)
usleep(1); // CPU usage: ~48%
usleep(10000); // CPU usage: ~1%
------------------------------------------------------------------------
[2015-07-24 16:37:25] saniafd93 at gmail dot com
Description:
------------
*PHP version 5.5.19
Short time ago I wrote an app, that uses usleep(1) for reducing CPU usage. I wrote it on my Windows
8.1 machine, and it's worked as suspected: CPU usage was reduced to 0%-1%. After that, I runned
it on Ubuntu 14.04, and there was same behavior: 0%-1.5% CPU usage.
All worked nice untill March 2015, when on Ubuntu CPU usage was increased up to 48% (2-core server).
I tested that app again, and found that on Windows CPU usage was still 0%-1%.
I tested it in several environments: 2core Windows 8.1, 4core Windows 8.1, 2core Ubuntu 14.04, 4core
Ubuntu 14.04.
Test script:
---------------
<?php
// usage below is right for Ubuntu 14.04 machines
// Windows 8.1 machines all the time have 0%-1.5%
while (true) {
usleep(1); // CPU usage: ~48% 2core machine, ~25% 4core machine
usleep(10000); // CPU usage: ~5% 2core machine, ~1% 4core machine
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=70130&edit=1