系统与基础设施danluu.com
计算机输入延迟:1977-2017
Computer latency: 1977-2017
2017 — 2022,它一次次回到首页
黑点是上首页(≥ 50 分)的那次投稿,空心点是没冲上去的投稿,点越大分数越高。
导读
Dan Luu 测量并比较了 1977 至 2017 年间多台计算机的端到端输入延迟,即从按键或触摸到屏幕出现响应的时间。文章显示一些老机器的延迟并不比现代设备差,甚至更好,并拆解了键盘、显示、操作系统和渲染等环节对延迟的影响。
为什么经久不衰:它用具体测量打破“新硬件必然更跟手”的直觉,说明端到端延迟是系统工程问题,今天仍是理解交互性能的经典参考。
HN 评论精选
实测显示选好部件可达约 19ms,键盘延迟意外地大,低延迟键盘有市场。
我正在为 xi-editor 开发快速文本渲染器,也同样很关心端到端延迟。我也用高速摄像机做过实验,但主要测试装置是一块 Arduino:它注入 USB HID 事件,然后测量屏幕发出的光。我预计很快公布结果。与 Dan 的结果有一处不同:它没有把键盘延迟算进去,因为键盘事件是合成的。好消息是,只要精心挑选各个部件,我们可以得到比 Apple II 更好的结果。这还不是最终结果,但我在一台连接 144Hz 显示器的 2017 款 13 英寸 MacBook Pro 上,看到从 USB 到屏幕发光约 19ms。鉴于键盘的贡献大得出乎意料,我认为经实测验证的真正低延迟键盘存在巨大的商业机会。游戏玩家会抢着买,但我会立刻买一个用来写代码。
raphlinus查看英文原文
I'm working on a fast text renderer for xi-editor, and am similarly quite concerned about end-to-end latency. I've also experimented with the high speed camera, but my main testing rig is an Arduino that injects USB HID events and then measures light from the screen. I expect to publish results soon. One difference from Dan's results is that it doesn't take the keyboard's latency into account, as that's synthesized. The good news is that we can get to even better results than Apple 2 by choosing pieces carefully. This is not my final result, but I'm seeing about 19ms from USB to light on a 2017 Macbook Pro 13" connected to a 144Hz monitor. Given the unexpectedly large contribution of the keyboard, I think there is a _tremendous_ business opportunity in empirically validated actual low latency keyboards. Gamers will eat these up, but I would buy one in an instant for coding.
文本编辑器可通过绕过渲染层实现零延迟模式,IntelliJ 因此很快。
JetBrains 的一位工程师写过一篇关于文本编辑器延迟的好博文:https://pavelfatin.com/typing-with-pleasure/ 他实现了一个零延迟模式,绕过渲染栈中的许多层,显然让 IntelliJ 成为最快的文本编辑器之一。
lima查看英文原文
There's a cool blog post by the JetBrains guy about text editor latency: https://pavelfatin.com/typing-with-pleasure/ He implemented a zero latency mode which bypasses many layers in the rendering stack, which apparently makes IntelliJ one of the fastest text editors.
延迟感知会随习惯改变,玩家能分辨 60ms 与 120ms。
显然,通过打破习惯,人能把原本察觉不到的延迟差异感受得很清楚。几年前我对网络游戏毫无经验,朋友带我玩一款热门游戏。在入门对局中,400ms 延迟对我来说感觉很即时,而他却觉得很烦,建议我换 ISP。几个月后我换了 ISP 并经常玩,就能本能地感觉到 60ms 和 120ms 连接的差异。
titanix88查看英文原文
Apparently imperceptible differences in latency can be felt vividly through break of habit. A couple of years back, I didn't have any experience with online games and was introduced to a popular one by one of my friends. As we were playing some introductory matches, 400ms latency connection felt very instantaneous to me, while he felt super annoyed and advised me to change my ISP. Some months after changing my ISP and regularly playing the game, I could instinctively feel the difference between a 60ms connection and a 120ms connection.
手机软件可做到约 10ms 触摸延迟,低延迟对直接触摸交互尤其重要。
值得注意的是,即使现代硬件、甚至某种程度上现代软件,在有触摸屏输入滤波的情况下,仍有可能实现低延迟。现代 GPU 渲染栈做不到,但我能在不放弃 Linux 内核、IRQ 或输入栈的软件实现中做到。我的实验在 60Hz 手机、触摸屏以 240Hz 扫描时,平均点击延迟降到约 10ms(附推文和源码链接)。我得说,延迟这么低时在手机上写字确实感觉更具交互性、更自然。我个人不觉得这些延迟范围在输入是间接的台式机上有多大关系,但在手指直接操作的手机上意义大得多。
kdrag0n查看英文原文
It's worth noting that it's still possible to achieve low latency with modern hardware and even software to some extent, even with all the input filtering on touchscreens. The modern GPU rendering stack won't be able to do it, but I was able to do it in software without giving up the Linux kernel, IRQs, or the input stack. My experiment got down to ~10 ms average tap latency on a 60 Hz phone with a touchscreen scanning at 240 Hz: https://twitter.com/kdrag0n/status/1291213993219039232 Source code: https://github.com/kdrag0n/touchpaint I have to say that writing on phones really feels much more interactive and natural when the latency is so low. I don't personally feel like these ranges of latency are that big of a deal on desktop computers where input is indirect, but it feels much more significant on phones where your interactions are right underneath your finger.
历次讨论
同类还值得读
TTY 揭秘(2008)
The TTY demystified (2008)
经典文章深入剖析了 Unix/Linux 中 TTY 子系统的工作原理,包括线路规程、终端驱动、信号与控制字符等机制。
系统与基础设施上首页 11 次 · 2009–2025linusakesson.net编辑精选为什么 GNU grep 这么快
Why GNU grep is Fast
FreeBSD 邮件列表上一篇广为流传的帖子,解释 GNU grep 为什么快:核心在于 Boyer-Moore 字符串搜索算法配合精心优化的内部循环和 I/O,让程序在搜索时“…
系统与基础设施上首页 9 次 · 2010–2022lists.freebsd.orgXplain:为普通人讲解 X11
Xplain – Explaining X11 for the rest of us
《Xplain》是作者(HN 用户 Jasper_)写的一系列 X11 长文,用他在浏览器中重建的 X11 绘图模型做交互演示,讲解 X11 的绘图模型与窗口系统设计。
系统与基础设施上首页 6 次 · 2013–2020magcius.github.io编辑精选旋风教程:为 Linux 创建极小 ELF 可执行文件(1999)
A Whirlwind Tutorial on Creating Really Teensy ELF Executables for Linux (1999)
breadbox 写于 1999 年的经典教程,主题是如何为 Linux 手工构造并裁剪出体积极小的 ELF 可执行文件。
系统与基础设施上首页 6 次 · 2007–2025muppetlabs.comPostgreSQL 内部原理
The internals of PostgreSQL
《The Internals of PostgreSQL》是一本免费在线书籍,系统讲解 PostgreSQL 的内部实现,包括查询处理、并发控制、WAL、缓冲区管理等核心机制。
系统与基础设施上首页 5 次 · 2017–2025interdb.jp编辑精选