Bug #70130 [NEW]: usleep(1) CPU usage
From: saniafd93 at gmail dot com
Operating system: Ubuntu 14.04
PHP version: 5.5.27
Package: SPL related
Bug Type: Bug
Bug description:usleep(1) CPU usage
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 bug report at https://bugs.php.net/bug.php?id=70130&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=70130&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=70130&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=70130&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=70130&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=70130&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=70130&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=70130&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=70130&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=70130&r=support
Expected behavior: https://bugs.php.net/fix.php?id=70130&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=70130&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=70130&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=70130&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70130&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=70130&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=70130&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=70130&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=70130&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=70130&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=70130&r=mysqlcfg
Thread (13 messages)
- saniafd93 at gmail dot com
- saniafd93 at gmail dot comBug #70130 [Opn]: usleep(1) CPU usage
- cmb@php.netBug #70130 [Opn]: usleep(1) CPU usage
- cmb@php.netBug #70130 [Asn->Fbk]: usleep(1) CPU usage
- saniafd93 at gmail dot comBug #70130 [Asn]: usleep(1) CPU usage
- saniafd93 at gmail dot comBug #70130 [Fbk->Asn]: usleep(1) CPU usage
- cmb@php.netBug #70130 [Asn]: usleep(1) CPU usage
- yohgaki@php.netBug #70130 [Opn->Fbk]: usleep(1) CPU usage
- php-bugs at lists dot php dot netBug #70130 [Fbk->NoF]: usleep(1) CPU usage
- saniafd93 at gmail dot comBug #70130 [Com]: usleep(1) CPU usage
- requinix@php.netBug #70130 [NoF->ReO]: usleep(1) CPU usage
- cyril at grazetech dot comBug #70130 [Com]: usleep(1) CPU usage
- gerdchristian dot kunze at googlemail dot comBug #70130 [Com]: usleep(1) CPU usage