If you’re like me, you’ll drink Coke and disrupt your sleeping cycle on a regular basis. You’ll also be frustrated that Metacity’s compositing is horribly jerky. Well, as I found out from chatting on IRC one day, Metacity’s compositor is hard-coded to run at 50fps.
Normally, your monitor’s refresh rate will be something around 75hz, so 50fps, which is less than your monitor’s refresh rate, is hardly optimal. Fortunately, you can fix it with this simple patch:
diff -ur metacity-2.22.0.orig/src/core/compositor.c metacity-2.22.0/src/core/compositor.c
--- metacity-2.22.0.orig/src/core/compositor.c 2008-03-10 08:49:15.000000000 +1100
+++ metacity-2.22.0/src/core/compositor.c 2008-10-25 11:30:13.000000000 +1100
@@ -1290,16 +1290,18 @@
if (compositor->repaint_id > 0)
return;
-#if 0
- compositor->repaint_id = g_idle_add_full (G_PRIORITY_HIGH_IDLE,
- compositor_idle_cb, compositor,
- NULL);
-#else
/* Limit it to 50fps */
+ /*
compositor->repaint_id = g_timeout_add_full (G_PRIORITY_HIGH, 20,
compositor_idle_cb, compositor,
NULL);
-#endif
+ */
+
+ /* Nah, let's do 75fps */
+ compositor->repaint_id = g_timeout_add_full (G_PRIORITY_HIGH, 13,
+ compositor_idle_cb, compositor,
+ NULL);
+
}
#endif
The timeout is changed from updating every 20 milliseconds (1000msec ÷ 50fps = 20msec), to every 13 milliseconds (1000msec ÷ 75fps ≈ 13msec), which makes it much smoother.


Or, for metacity 2.24:
Ah, thanks for that.
[...] Jeremy Visser tells us how to improve the refresh rate of Metacity’s compositor. (Is it worth making this part of Metacity? Iain? anyone?) [...]
strange. IANAD, but running metacity composite 2.24 with this patch did not seem to change anything perceived-performance-wise on my side, with an i915 and a regular LCD panel (which gnome says runs at 58 hz or something).
ideally it wouldn’t be hard-coded but off-course in sync with your monitor’s refresh rate,
Jeff, I would say the fact that you’re running at 58 hz is the problem. No matter how fast the compositor updates, if the display is only running at 58 hz (only 8 hz faster than the old slow compositing rate), you’re not going to notice any difference.
Best to run at 75 hz.
Baptiste, indeed that is the case, and would be necessary for utilising vertical sync, which Metacity doesn’t support (it suffers from tearing). However, I’m not a coder — I just change little values in code, and if I’m lucky, it even compiles!
tried again with various values with gnome-display-properties; 58hz, 70hz, 85hz. No matter the refresh rate, and no matter if I run my “stock” metacity or the patched version, I can’t perceive the difference
are you certain this is not a placebo effect? maybe I’d need slow motion to see a difference.
I do notice that windows seem to tear when you move them fast, but your latest comment seems to indicate this is a different issue (vertical sync?).
I’d say that this I can confirm that this is definitely not a placebo, but that wouldn’t make sense.
Perhaps you are encountering a bottleneck elsewhere, or your video card physically cannot cope with compositing that fast.
I’m an NVIDIA user here, so I have plenty of GPU cycles to burn.