summaryrefslogtreecommitdiff
path: root/ext/mbstring/php_unicode.c
diff options
context:
space:
mode:
authorEmmanuel Dreyfus <manu@netbsd.org>2017-07-19 04:36:55 +0200
committerNikita Popov <nikita.ppv@gmail.com>2017-07-19 19:54:19 +0200
commitd25049cc1b74ae445d6521997a421a7462f1ad5b (patch)
tree04af1a5b08d8616857946a114e84f30883416d3a /ext/mbstring/php_unicode.c
parent6fcc7134f1d4aaf60e24202ed316c61636c5a95d (diff)
downloadphp-git-d25049cc1b74ae445d6521997a421a7462f1ad5b.tar.gz
Fixed bug #74851: Improve uniqid() performance
uniqid() relies on microsecond-precise system clock to produce an unique identifier. In order to avoid using the same value, the original implementation calls usleep(1) to wait for the next microsecond. Unfortunately, usleep() specification says "The suspension time may be longer than requested due to the scheduling of other activity by the system." Indeed, the pause may as as long as an entire execution slice, causing a uniqid() call to last more than 10 ms. This is fixed by replacing the usleep() call by time polling using gettimeofday() until the microsecond changes. Since the getttimeoday() system call lasts around a microsecond, only a small time is wasted calling multiple gettimeofday. On the benefit side, uniqid() performance in increased 10000 fold without changing its behavior.
Diffstat (limited to 'ext/mbstring/php_unicode.c')
0 files changed, 0 insertions, 0 deletions