[php-src] PR #23790: zend_hrtime: use CLOCK_MONOTONIC instead of CLOCK_MONOTONIC_RAW

From: Date: Sun, 20 Sep 2026 14:41:01 +0000
Subject: [php-src] PR #23790: zend_hrtime: use CLOCK_MONOTONIC instead of CLOCK_MONOTONIC_RAW
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-38627@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/23790 Author: nicolas-grekas This should fix the hrtime.phpt failure reported in GH-22508. CLOCK_MONOTONIC_RAW is not disciplined by NTP, so it ticks with the raw frequency error of the underlying oscillator. Under WSL2 here, that is 4% fast, measured over a 1s sleep: ``` microtime delta hrtime delta 8.5 1.000083 s 1.000086 s 8.6 1.000072 s 1.038898 s 8.6 + this 1.000158 s 1.000163 s ``` The relative uncertainty that ext/standard/tests/hrtime/hrtime.phpt computes goes from 0.038 back to 0.0002 with this, against the 0.05 the test allows. @mbeccati measured 0.0501 on Ubuntu 26.04 while packaging 8.6.0alpha1 and suggested raising that limit - I think the limit is fine and it is the clock that moved, but a confirmation on that box would be welcome. The adjtime/NTP slew that GH-19221 wanted to avoid is bounded to 500ppm by the kernel, and it is precisely what makes CLOCK_MONOTONIC track elapsed real time, which is the contract that test asserts. CLOCK_MONOTONIC_RAW is also served by the vDSO only since Linux 5.3, so on eg. RHEL 8 it costs a syscall per call. I kept the check-the-clock-once part of GH-19221, only the _RAW preference goes.

« previous php.git-pulls (#38627) next »