Req #68029 [Com]: PHP and monotonic date time
| From: | k1316820 at mvrht dot com | Date: | Wed, 04 Jan 2017 12:41:09 +0000 |
| Subject: | Req #68029 [Com]: PHP and monotonic date time | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-206295@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=68029&edit=1
ID: 68029
Comment by: k1316820 at mvrht dot com
Reported by: roberto at spadim dot com dot br
Summary: PHP and monotonic date time
Status: Closed
Type: Feature/Change Request
Package: Date/time related
Operating System: any
PHP Version: 5.6.1RC1
Assigned To: ab
Block user comment: N
Private report: N
New Comment:
Here's an example what problems you might encounter when language of your choice doesn't
have monotonic time functions. https://blog.cloudflare.com/how-and-why-the-leap-second-affected-cloudflare-dns/
Previous Comments:
------------------------------------------------------------------------
[2017-01-02 21:19:55] me at kelunik dot com
Running a stream-select loop in production is actually pretty fine, as long as you don't have
thousands of concurrent streams.
I'll post to internals soon.
------------------------------------------------------------------------
[2017-01-02 20:31:45] ab@php.net
What you link is a compatibility shim. It's unlikely one would want to run a pure PHP
implementation in production, and for development it doesn't matter much. Nevertheless, some
monotonic timer implementation in the core could be pursued. To workout the best course of action
the topic should be to discussed on internals.
Thanks.
------------------------------------------------------------------------
[2017-01-02 19:32:43] me at kelunik dot com
I can't reopen it, as I don't have a php.net account.
> I can also add, that every library you base your loop on, usually provides its own timer APIs.
> [...] Except you implement the event loop in pure PHP ofc, which is likely not the case.
Right, those provide their own APIs, but PHP does not. Implementing an event loop in pure PHP
isn't that uncommon:
- https://github.com/amphp/loop/blob/master/lib/NativeLoop.php
- https://github.com/reactphp/event-loop/blob/master/src/StreamSelectLoop.php
------------------------------------------------------------------------
[2017-01-02 18:42:13] ab@php.net
Of course, feel free to reopen this and discuss on internals. Portable parts of the hrtime ext can
be reused for the implementation in the core, or hrtime could be taken in. Otherwise, the ticket is
closed, because there's actually no functionality in the core, that would require monotonic
time.
I can also add, that every library you base your loop on, usually provides its own timer APIs. Take
libuv or libevent as a ref, best way should be to rely on their routines. The core time functions
use gettimeofday() or reimplement it, it is a known fact. It doesn't hurt to have monotonic
time in the core, though preferable are probably the timers provided by the base libs. Except you
implement the event loop in pure PHP ofc, which is likely not the case.
Thanks.
------------------------------------------------------------------------
[2017-01-01 15:03:13] me at kelunik dot com
I don't think an extension solves this feature request. We need a monotonic time function in
core, otherwise NTP and leap seconds will be a problem for event loops and others that rely on the
elapsed time.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=68029
--
Edit this bug report at https://bugs.php.net/bug.php?id=68029&edit=1