Measuring Input Latency on Linux: X11 vs. Wayland, VRR, and DXVK
403 points
• 3 days ago
• Article
Link
为了解决关于 Linux 游戏性能的争论,我们制作了一个定制硬件装置,用于测量端到端系统延迟。该装置用光电二极管检测由模拟鼠标点击引发的屏幕亮度变化,从而在不同配置下进行精确实测。目的是超越"Wayland 感觉不对劲"这类主观印象,找出哪些优化在实际游戏中确实能降低输入延迟。
测试方法集中在 Diabotical 的一个静态场景,比较了显示服务器、可变刷新率(VRR)设置以及延迟优化的 DXVK 分支的影响。所有测试均在搭载 AMD Ryzen 7 5800X3D 和 NVIDIA RTX 4070 SUPER 的系统上进行。每个场景采集了 300 次点击的数据,从而得到清晰的统计图景,展示不同软件栈如何影响从输入到画面响应的时间。
结果显示,X11 始终略优于 Wayland,但差距微乎其微,仅为 0.14 到 0.22 毫秒。相反,XWayland 带来了明显的额外延迟——比原生 Wayland 多约 3.13 毫秒。这表明在 Linux 竞技游戏中避免使用 XWayland 非常重要,因为它的影响远大于测试中的其他任何变量。
启用 VRR 是降低整体延迟并稳定帧传输的最有效手段,可带来最多约 0.45 毫秒的改进,并使延迟分布更平滑。此外,dxvk-low-latency 分支也是一项有价值的优化。在有帧率上限的场景中它的提升有限,但在不设限的情况下,能有效防止渲染队列堆积并改善帧间节奏。
总体而言,数据表明人们对不同显示服务器性能差异的感知在很大程度上被夸大。尽管 X11 、 VRR 和低延迟优化的组合能得到最优结果,但原生 Wayland 的表现也非常具有竞争力。真正的性能瓶颈来自不必要的 XWayland 和渲染节奏控制问题,而不是现代 Wayland 协议本身的缺陷。
To investigate the common debate regarding gaming performance on Linux, a custom hardware device was developed to measure end-to-end system latency. This device uses a photodiode to detect screen brightness changes triggered by simulated mouse clicks, allowing for precise, empirical data collection across various configurations. The goal was to move beyond subjective feelings like "Wayland feels off" and determine which optimizations actually reduce input lag in a practical gaming environment.
The testing methodology focused on a static scene in the game Diabotical, comparing display servers, Variable Refresh Rate (VRR) settings, and the use of a latency-optimized DXVK fork. All tests were conducted on a system featuring an AMD Ryzen 7 5800X3D and an NVIDIA RTX 4070 SUPER. By capturing 300 clicks per scenario, the study produced a clear statistical picture of how different software stacks influence the time between a user's input and the corresponding visual response.
The results reveal that while X11 consistently outperforms Wayland, the difference is negligible, ranging only between 0.14 and 0.22 milliseconds. In contrast, XWayland proved significantly detrimental, adding roughly 3.13 milliseconds of latency compared to native Wayland. This suggests that avoiding XWayland is a critical step for competitive gaming on Linux, as its impact is substantially greater than any other variable tested.
Enabling VRR emerged as the most effective way to reduce overall latency and stabilize frame delivery, providing gains of up to 0.45 milliseconds while simultaneously flattening the latency distribution. Additionally, the `dxvk-low-latency` fork proved to be a valuable tool. While it offers modest improvements in capped scenarios, its primary benefit lies in uncapped gameplay, where it successfully prevents render-queue buildup and smooths out frame pacing.
Ultimately, the data shows that the perceived performance differences between display servers are largely overstated. While a combination of X11, VRR, and low-latency optimizations produces the fastest possible results, native Wayland is extremely competitive. The real performance gaps are found in the unnecessary use of XWayland and the intelligent pacing provided by specialized DXVK configurations, rather than any fundamental flaw in the modern Wayland display protocol.
288 comments • Comments Link
• Linux 提供了一个独特且透明的生态环境,在这里进行性能分析不仅可行,而且能直接推动切实可行的改进,这与 Windows 和 macOS 的闭源特性形成了鲜明对比。
• Bazzite 和类似以游戏为重心的发行版简化了专有驱动和编解码器的安装流程,但采用像 rpm-ostree 这样的不可变文件系统对习惯传统开发环境的人来说可能具有一定的挑战性。
• 关于 Wayland 会引入显著输入延迟的看法,很大程度上源自用于运行传统 X11 应用的 XWayland 带来的开销,而不是 Wayland 协议本身的问题。
• 现代 Wayland 合成器在端到端延迟测试中的表现,尤其在使用原生驱动时,与 X11 不相上下甚至更好,因此对原生 Wayland 性能的担忧在很大程度上已不再适用。
• 在竞技类游戏中,超过显示器刷新率的高帧率能带来明显优势:它确保系统处理的是最新的游戏状态并随时准备将其推送到屏幕,从而降低从输入到显示的有效延迟。
• 合成器的架构会显著影响感知延迟,不同实现(例如 KWin 、 Mutter 、 Gamescope)在处理输入事件、光标渲染和直接扫描输出等方面的效率存在差异,因而体验也不同。
• 硬件配置依然是影响 Linux 桌面体验的主要因素,尤其是 AMD 的开源 Mesa 驱动与 Nvidia 的专有二进制模块之间的差异,后者在 Wayland 兼容性和性能上常面临更多挑战。
• 在闭源操作系统上难以排查第一方应用故障,促使很多用户转向 Linux,因为可以通过查看日志和系统行为来诊断不透明的问题,这对解决故障非常有价值。
• 虽然基准测试表明协议之间的延迟差异非常小,但桌面体验的主观"感觉"往往受其他非协议因素影响,例如鼠标加速曲线、动画设置以及浏览器中使用软件渲染的组件。
• 缺乏标准化测试工具导致大多数比较高度依赖作者的硬件、内核和合成器选择,因此关于 Linux 桌面性能的普遍性结论本质上是不可靠的。
这次讨论凸显了 Linux 桌面领域的重要转变:以游戏为中心的发行版正在成功缩小对专有软件依赖的工作流程与开源可访问性之间的差距。尽管围绕 X11 与 Wayland 的历史争论仍然存在,但证据显示原生性能已达到或接近平价,遗留的延迟问题主要出现在像 XWayland 这样的兼容层上。讨论还强调,Linux 用户的满意度越来越依赖于能够微调系统组件(如调度器和合成器)的能力——这种细粒度的控制在主流闭源操作系统上越来越难以实现。最终,尽管 GPU 厂商等硬件选择仍会影响开箱即用的体验,社区总体上支持向 Wayland 转型,前提是用户避免采用未经优化的配置。 • Linux offers a uniquely transparent ecosystem where performance analysis is not only feasible but drives actionable improvements, contrasting with the closed-source nature of Windows and macOS.
• Bazzite and similar gaming-focused distributions simplify the installation of proprietary drivers and codecs, though the use of immutable filesystems like rpm-ostree can present challenges for developers accustomed to traditional environments.
• The perception that Wayland introduces significant input lag is largely driven by the overhead of XWayland, which is used for legacy X11 applications, rather than the Wayland protocol itself.
• Modern Wayland compositors, particularly when using native drivers, perform on par with or better than X11 in end-to-end latency tests, making concerns about native Wayland performance mostly outdated.
• High frame rates beyond a display's refresh rate provide tangible benefits in competitive gaming by ensuring the most up-to-date game state is processed and ready to be pushed to the screen, reducing effective input-to-display latency.
• Compositor architecture significantly impacts perceived latency, as different implementations (e.g., KWin, Mutter, Gamescope) handle input events, cursor rendering, and direct scan-out with varying levels of efficiency.
• Hardware configurations—specifically the difference between AMD's open-source Mesa drivers and Nvidia's proprietary blobs—remain a major factor in the Linux desktop experience, with Nvidia often facing more friction regarding Wayland compatibility and performance.
• The difficulty in troubleshooting first-party applications on closed-source operating systems drives many users toward Linux, as the ability to inspect logs and system behavior is highly valued for resolving opaque issues.
• While benchmarks show negligible differences in latency between protocols, subjective "feel" in desktop environments is often influenced by non-protocol factors like mouse acceleration curves, animation settings, and software-rendered browser components.
• The lack of standardized testing tools means most comparisons are highly specific to the author's hardware, kernel, and compositor choices, making broad generalizations about Linux desktop performance inherently unreliable.
The conversation underscores a significant shift in the Linux desktop landscape, where gaming-centric distributions are successfully bridging the gap between proprietary-dependent workflows and open-source accessibility. While historical debates regarding X11 versus Wayland remain polarized, empirical evidence suggests that native performance parity has been achieved, with lingering latency issues largely isolated to compatibility layers like XWayland. The discussion also highlights that user satisfaction on Linux is increasingly tied to the ability to tune system components—such as schedulers and compositors—a level of granular control that is increasingly difficult to replicate on mainstream proprietary operating systems. Ultimately, while hardware choices like GPU vendor continue to influence the "out-of-the-box" experience, the community consensus favors a move toward Wayland, provided users avoid unoptimized configurations.