[RFC PATCH 0/2] util/qemu-timer: Honor sub-ms poll timeouts on Darwin

Philippe Mathieu-Daudé posted 2 patches 3 days, 4 hours ago
tests/bench/macos-pollbench.c | 290 ++++++++++++++++++++++++++++++++++
util/qemu-timer.c             |  27 ++++
tests/bench/meson.build       |   6 +
3 files changed, 323 insertions(+)
create mode 100644 tests/bench/macos-pollbench.c
[RFC PATCH 0/2] util/qemu-timer: Honor sub-ms poll timeouts on Darwin
Posted by Philippe Mathieu-Daudé 3 days, 4 hours ago
This series corrects a long-standing platform limitation:
qemu_poll_ns() promises nanosecond timeouts, but Darwin’s
g_poll() fallback rounds up to milliseconds, making sub-ms
virtual timers fire late. Fixes the observable behavior.

Add a Darwin-only microbenchmark used to compare wait
primitives and justify the chosen approach.

During the final sub-ms sleep, descriptors are not polled,
so fd readiness can be delayed by up to <1 ms. This is still
much better than whole-ms timer overshoot and avoids busy-waiting.

Philippe Mathieu-Daudé (2):
  tests/bench: Add macos-pollbench
  util/qemu-timer: Honor sub-ms poll timeouts on Darwin

 tests/bench/macos-pollbench.c | 290 ++++++++++++++++++++++++++++++++++
 util/qemu-timer.c             |  27 ++++
 tests/bench/meson.build       |   6 +
 3 files changed, 323 insertions(+)
 create mode 100644 tests/bench/macos-pollbench.c

-- 
2.55.0


Re: [RFC PATCH 0/2] util/qemu-timer: Honor sub-ms poll timeouts on Darwin
Posted by Philippe Mathieu-Daudé 2 days, 22 hours ago
(forgot to Cc Akihiko)

On 20/11/26 00:34, Philippe Mathieu-Daudé wrote:
> This series corrects a long-standing platform limitation:
> qemu_poll_ns() promises nanosecond timeouts, but Darwin’s
> g_poll() fallback rounds up to milliseconds, making sub-ms
> virtual timers fire late. Fixes the observable behavior.
> 
> Add a Darwin-only microbenchmark used to compare wait
> primitives and justify the chosen approach.
> 
> During the final sub-ms sleep, descriptors are not polled,
> so fd readiness can be delayed by up to <1 ms. This is still
> much better than whole-ms timer overshoot and avoids busy-waiting.
> 
> Philippe Mathieu-Daudé (2):
>    tests/bench: Add macos-pollbench
>    util/qemu-timer: Honor sub-ms poll timeouts on Darwin
> 
>   tests/bench/macos-pollbench.c | 290 ++++++++++++++++++++++++++++++++++
>   util/qemu-timer.c             |  27 ++++
>   tests/bench/meson.build       |   6 +
>   3 files changed, 323 insertions(+)
>   create mode 100644 tests/bench/macos-pollbench.c
>