Measuring keyboard-to-photon latency with a light sensor
thume.ca
thume.ca
Alacritty is still claiming that it is the fastest terminal around, even though that claim has been proven false several times.
Latency makes much more difference in how fast a terminal feels. This is where kitty does a fantastic job, even letting me trade some CPU cycles for really low latency with its options. I can strongly recommend it to anyone who values low latency.
Christian Duerr and friends are doing a great job, please continue to work on it.
Last time I checked it also had the best unicode handling too, in terms of reliably falling back to some other font for missing codepoints and getting the display of oversized characters right.
The right hand one is sharper but I have my freetype tuned to look like the left one, which looks the same as every other application on my PC. kitty is doing something completely different and incorrect.
EDIT: Actually, I use a Bluetooth keyboard, so it's probably moot.
This is obviously subjective to some degree. But I used to frequently get annoyed at various terminals until two or so years ago, and have just forgotten about the issue since.
[1] there's no date, had to check Internet Archive, and they refer to 3 years old OSes
edit: I mean, so much has changed that the performance could easily be way better or way worse, I don't think it's representative anymore (usuful for future benchmarks, sure, but relevant not so much)
And typing was..noticeably more "immediate". It was bewildering, sort of like wearing prescription glasses for the first time.
I like all the extra stuff editors and the OS do these days and don't wish to turn the time back, and I doubt it's realistic to achieve both. But maybe someone like Apple, being fully integrated, should take a shot at it. It'd be the sort of polish that makes using a computer enjoyable.
Unfortunately Apple shows no interest in getting rid of that delay, while Microsoft is moving towards sometimes using hardware overlays to avoid that (see raphlinus's comment about DirectFlip), and Linux lets you disable it at the cost of tons of artifacts. Apple only recently tried to add compositor bypass for fullscreen Metal apps but the way they did it is super opaque and I have never succeeded at getting it to trigger and they have no example program that they say definitely does it.
https://stackoverflow.com/questions/12345730/how-to-disable-...
Using Instruments’s Metal and Display instruments you can see the drawables and the vsync they present on. Bring up the app switcher with cmd-tab to trigger the compositor and you can see the difference in Instruments.
One weird thing is, you can configure a 2 or 3 drawables swapchain on the Metal layer. Using 2 doesn’t work for me when the compositor bypass enables - it always locks to 30Hz, even when doing nothing but drawing a solid color. When the compositor is enabled, the 2 buffer swapchain runs at full speed, presumably because it’s effectively triple buffered. But, in the 3 buffer case, in fullscreen, you can see that you will just use 2 buffers provided you can render fast enough, so it seems like there’s no latency cost to the 3 drawable config in the ideal case.
If typical gamers reaction time is O(300ms) and a keyboard, change can save 40ms, or a screen can add 80ms (extreme cases) seems like they'd be wise to be testing and verifying things.
Anyone links to details of how esports teams are doing things here?
I'm curious about the light-detection - do screens have a very tight synchronisation between different colours. Could the sensor be matched in some way with the specifics of the screen?
I’m curious what impact hardware acceleration and gsync would have on this. I would guess Electron is using a hardware accelerated surface in my scenario, but I don’t imagine gsync is doing much on the desktop since it is synchronized to the entire OS and not a specific application.
Hardware acceleration or not probably doesn't play into it as much as how abstract are the layers i.e. are there 4 layers of hardware abstraction library to make the app work everywhere which use it's own buffering to stay smooth regardless of the underlaying system and then hands that to the OS which then buffers it as part of the compositor to be displayed or does something just blit "n" to the display framebuffer as the latter is likely to have less delay/jitter.
That's the sensor. It's not a wonderful match for this job.
The linked[1] light sensor module looks like a CdS photoresistor. In its Amazon Q&A, the seller claims "The response time: Rise 30ms Decline 30ms", under unspecified conditions.
Better to use a phototransistor like [2], with a rise time of microseconds. 4 orders of magnitude faster. It's easy - one resistor, and an analog input on the Teensy.
Deja vu. For 3D UI prototyping on my laptop, I diy'ed LCD shutter glasses driven by an arduino with a photosensor reading a white/black square rendered flashing in a screen corner. IIRC, I actually tried a photoresistor first, but the plotted screen response curve times weren't plausible. Only then did I look for a datasheet, and had an "okaaay, that's not the right thing" moment. :/
[1] https://www.amazon.com/gp/product/B01N1FKS4L/ [2] https://www.adafruit.com/product/2831
I participated in writing 2 papers. In the first one, we used an optical mouse on a screen displaying a special texture to measure the end-to-end latency. In the second one, we used an external Arduino (quite similar to what the author did here) connected to a photodiode.
For what I remember, the main factor on the latency is the screen, use a gamer screen to improve the delay (CRT screens are told to be quite fast also, but we hadn't access to one to test :'( ).
http://lednique.com/opto-isolators-2/light-dependent-resisto... https://www.adafruit.com/product/2831
100-133ms for my keyboard to display USB hub, to laptop, and back to display.
66-83ms for my laptops own keyboard and display.
Something about my computer has always felt a bit off. For a long time I thought it was a commonly reported vim + tmux bug but it never felt like it sped up very much.
Now I just want a 386 in VGA mode again. I’m sure things were better in the good old days (said with some sense of irony.)
(Measured with 5 samples on each.)
I'd optimize lots of other things like trying to avoid the compositor, higher refresh rate monitors and lower travel keys before I'd look at USB3.
It would definitely be interesting to have more software and hardware tested, I would imagine there is lot more variance out there.
There's some good info here on minimal USB latency, it's less than 1ms and I don't think mine is an issue although the macOS event processing stack might introduce some latency: https://michael.stapelberg.ch/posts/2018-04-17-kinx-latency-...