Skip to content

clutter/frame-clock: Use timerfd for clock timing

Christian Hergert requested to merge wip/chergert/frame-clock-jitter into main

Currently, ClutterFrameClock uses g_source_set_ready_time() to determine the usec timing of the next frame. That translates into a poll() with a millisecond timeout if no trigger occurs to break the poll() out early.

To avoid spinning the CPU, GLib always rounds up to the next millisecond value unless a timeout of 0 was provided by a GSource.

This means that timeouts for the ClutterFrameClock can easily skew beyond their expected time as the precision is too coarse.

This applies the same concept as glib!3949 (closed) but just for the ClutterFrameClock. That may be more ideal than adding a timerfd for every GMainContext, but we'll see if that lands upstream. I wanted to provide this here because it could easily be cherry-picked in the mean time if this is found to be useful.

From a timer stability perspective, this improves things from erratically jumping between 100s and 1000s off of the expected awake time to single or low double digits.

frame-clock-jitter

Edited by Christian Hergert

Merge request reports