Bug #70130 [Opn]: usleep(1) CPU usage

From: Date: Tue, 28 Jul 2015 23:46:35 +0000
Subject: Bug #70130 [Opn]: usleep(1) CPU usage
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-194795@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
 Updated by:         cmb@php.net
 Reported by:        saniafd93 at gmail dot com
 Summary:            usleep(1) CPU usage
 Status:             Open
 Type:               Bug
 Package:            SPL related
 Operating System:   Ubuntu 14.04
 PHP Version:        5.5.27
-Assigned To:        
+Assigned To:        cmb
 Block user comment: N
 Private report:     N

 New Comment:

> 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.


Previous Comments:
------------------------------------------------------------------------
[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


Thread (13 messages)

« previous php.bugs (#194795) next »