Difference between revisions of "Wayland latency tuning"

From Looking Glass
Jump to navigation Jump to search
(Created page with "On Wayland, frame latency can be reduced by making the compositor render as late as possible before a vblank. This allows the compositor to show the latest frame available, ju...")
 
Line 1: Line 1:
On Wayland, frame latency can be reduced by making the compositor render as late as possible before a vblank. This allows the compositor to show the latest frame available, just in time for the screen refresh. This guide describes how to configure this for certain compositors.
+
On Wayland, frame latency can be reduced by making the compositor render as late as possible before a vblank. This allows the compositor to show the latest frame available, just in time for the screen refresh. This guide describes how to configure this for certain compositors. This will improve your experience for all applications, not just Looking Glass.
  
 
Looking Glass can also be made to render right before the compositor renders, further reducing latency. This is what the <code>win:jitRender</code> setting does on Wayland. The timing of this is also controlled by the compositor, and thus the configuration is compositor-specific.
 
Looking Glass can also be made to render right before the compositor renders, further reducing latency. This is what the <code>win:jitRender</code> setting does on Wayland. The timing of this is also controlled by the compositor, and thus the configuration is compositor-specific.
Line 6: Line 6:
  
 
On Sway, this is controlled by the <code>max_render_time</code> setting. The <code>max_render_time</code> setting on the output controls how many millisecond the compositor renders before the vblank. Setting <code>max_render_time</code> on the window controls how many milliseconds the compositor tells windows to render.
 
On Sway, this is controlled by the <code>max_render_time</code> setting. The <code>max_render_time</code> setting on the output controls how many millisecond the compositor renders before the vblank. Setting <code>max_render_time</code> on the window controls how many milliseconds the compositor tells windows to render.
 +
 +
=== Screen latency tuning ===
 +
 +
The goal is to set the smallest value for <code>max_render_time</code> that does not result in frame dropping. For this test, you must be able to tell if a frame is dropping. If you cannot tell this visually, you can open [https://testufo.com/ UFO test] in a browser running on native Wayland. The frame rate reported by this test will be lower than the screen refresh rate if there is frame dropping.
 +
 +
We will assume your display is called <code>DP-1</code>. You should change the name if it is different. If you have multiple monitors, this process must be repeated for every monitor.
 +
 +
We start by running <code>swaymsg output DP-1 max_render_time 1</code>. If there is frame dropping, increase the value of <code>max_render_time</code> by 1 and try again until frame dropping stops. This is the optimal setting for <code>max_render_time</code>. Once you find this value, open up your sway config file (usually <code>~/.config/sway/config</code>), and add the line <code>output DP-1 max_render_time t</code>, with <code>t</code> replaced by the optimal value obtained previously.

Revision as of 20:13, 30 August 2021

On Wayland, frame latency can be reduced by making the compositor render as late as possible before a vblank. This allows the compositor to show the latest frame available, just in time for the screen refresh. This guide describes how to configure this for certain compositors. This will improve your experience for all applications, not just Looking Glass.

Looking Glass can also be made to render right before the compositor renders, further reducing latency. This is what the win:jitRender setting does on Wayland. The timing of this is also controlled by the compositor, and thus the configuration is compositor-specific.

Sway

On Sway, this is controlled by the max_render_time setting. The max_render_time setting on the output controls how many millisecond the compositor renders before the vblank. Setting max_render_time on the window controls how many milliseconds the compositor tells windows to render.

Screen latency tuning

The goal is to set the smallest value for max_render_time that does not result in frame dropping. For this test, you must be able to tell if a frame is dropping. If you cannot tell this visually, you can open UFO test in a browser running on native Wayland. The frame rate reported by this test will be lower than the screen refresh rate if there is frame dropping.

We will assume your display is called DP-1. You should change the name if it is different. If you have multiple monitors, this process must be repeated for every monitor.

We start by running swaymsg output DP-1 max_render_time 1. If there is frame dropping, increase the value of max_render_time by 1 and try again until frame dropping stops. This is the optimal setting for max_render_time. Once you find this value, open up your sway config file (usually ~/.config/sway/config), and add the line output DP-1 max_render_time t, with t replaced by the optimal value obtained previously.