Reduce input latency with double buffering#19757
Conversation
- Reduce swap chain buffer count from 3 to 2 - Disable vsync (sync interval 0) in Present calls This reduces measured input latency from ~33ms (2 frames) to ~15.5ms, as measured with typometer. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
For what it is worth, 3 buffers were chosen for a reason which is documented exactly above the lines of code you have changed. Do you have a solution that will solve the new purported issue and the original issue that drove us to use triple buffering? |
thanks for this insight! |
|
I think we can close this PR. I found that the current main branch has lower latency already anyway. Seems like between preview version and canary build ( 1.25.10161.0 ) you improved it? |
#19330 if anything. Aside from that there haven't been any rendering changes in 1.5 years. I re-reviewed that PR and it is functionally identical to before. Perhaps we made improvements in the VT processing, but I don't think there are any changes in the rendering code.
That's not how buffering works. The number of buffers you specify in 3D rendering controls only that: How many buffers you got. Whether that affects your latency depends on your coding. So, there are signals from the GPU to detect when it presents a buffer on the screen. If you use that signal, you could have 1000-ary buffering and you would still have the same latency as if you only used double-buffering. As someone who uses LLMs quite a bit, I hope LLM providers can fix their AIs zealously jumping to conclusions in the near term. Because I tried asking Claude about this as well and it made the exact same mistake it did in your PR. Asking it about |
|
@lhecker I spent some time using claude code and codex on improving latency and rendering smoothness in wezterm and also here, but I have to agree, they were not really up to the task. And thanks for the explanation with the buffering, it was not clear to me. |
Summary
Motivation
Triple buffering with vsync causes ~33ms (2 frames at 60Hz) of input latency. By switching to double buffering and disabling vsync, measured input latency drops to ~15.5ms (SD 4.2ms) as measured with typometer.
Test plan
🤖 Generated with Claude Code