Subject: CVS commit: pkgsrc/lang/php71
From: Emmanuel Dreyfus
Date: 2017-07-17 16:10:08
Message id: 20170717141008.45870FACD@cvs.NetBSD.org

Log Message:
Performance fix for uniqid()

PHP uniqid() relies on microsecond-precise system clock to produce an
unique identifier. In order to avoid  using the same value, it first
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 microscecond change. 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.

Submitted upstream as https://bugs.php.net/bug.php?id=74851

Files:
RevisionActionfile
1.24modifypkgsrc/lang/php71/distinfo
1.1addpkgsrc/lang/php71/patches/patch-ext_standard_uniqid.c