Live data from Hacker News

Keyboard latency

danluu.com

201–210 of 274 posts

Re: Keyboard latency

#201
post #120

I have something interesting about USB input latency to share. In 2014 I built a new computer with a i5-4590 CPU, ASUS Z97-A motherboard and 8GB of Kingston DDR3-1866 memory. One thing I instantly noticed was that my mouse (Logitech G400) would feel "delayed" compared to my older computer from 2010 (i3-550, Intel DH55HC motherboard). I could have the same OS (tested Win7 and Ubuntu), GPU and monitor between both comp…

Are you implying it was the RAM?

Yup. I still have both motherboards, the "broken" RAM and the good RAM actually.

I didn't believe it at first, but just being able to move the mouse around and play audio over USB and not having it lag was enough proof.

Re: Keyboard latency

#202
It would be cool to look at Linux vs the BSDs on this. BSDs (dragonfly and openbsd) do feel like they react faster to keyboard input, but I've always wondered whether it's actually faster or just imagined.

Re: Keyboard latency

#204
post #198

I'm surprised the "humans don't notice 100 ms" argument is even made. That's trivially debunkable with a simple blind A/B test at the command line using `sleep 0.1` with and without `sleep` aliased to `true`. To my eyes, the delay is obvious at 100 ms, noticeable at 50 ms, barely perceptible at 20 ms, and unnoticeable at 10 ms. Not to mention that 100 ms is musically a 16th note at 150 bpm. Being off by a 16th note e…

>On the other hand, if you told me to strike a key less than 100 ms after some visual stimuli If it was audio cue, I'd point you to "Love Live School Idol Festival", a rhythm game which "perfect" judgement window is some 32ms. Decent players will get perfect most of the time.

Rhythm games allow for anticipation which is not reaction

Re: Keyboard latency

#205
post #2

IMO, a better measure would be from activation of the switch, as opposed to the beginning of key travel. I don't start waiting for the character to appear on my screen from the moment I begin to press down. My anticipation begins when I feel the tactile feedback of the switch activating (or the switch bottoming out on switches that don't offer tactile feedback). On a keyboard with good tactile feedback, I might not m…

I immediately switched to skeptic mode when I saw no actuation points or normalization for travel distance. All this is showing is that to move further it takes longer. Duh. Why even bother pointing out the polling rate? That's like setting up runners at random places on the racetrack to measure who's faster. The guy/gal that starts closest to the finish line isn't necessarily faster. I'm using Cherry MX Speed switch…

Your criticism is harsh by pointing out a (debatable) point, key travel, using a certain amount of rationale and suddenly concluding ‘every step’ has flaws. Point out those flaws!

Furthermore, the OP is the first one doing real measurements on keyboard latency, so perhaps you should trust the article to hint towards a previous unnoticed problem.

Anyways, your comment is totally missing the point and makes generalizations based on one debatable measurement error.

Re: Keyboard latency

#206

I've been experimenting with alternative protocols to HID. I'm not satisfied with fixed-interval input polling out of sync with vsync; it takes way too many samples to reach the desired latency (and especially jitter!) numbers. As for keyboards, there's no real excuse not to just have a Bigass™ shift register (or a couple) and address every keyswitch with a trace and an interrupt crossbar. There's a limit to how chea…

Super interesting post, thanks. Do you have any more details on your HID alternative to share? You’ll need a custom USB driver for that, right?

Re: Keyboard latency

#207

PS/2 keyboards are used by serious gamers because the scan rate is higher than USB. See https://superuser.com/questions/16893/do-usb-or-ps-2-keyboar...

do serious gamers avoid v-sync ? even at 120Hz they get at least ~8ms * 2(double buffer) latency right ?

Pro gamers in highly competitive, reaction-based games (such as most first-person shooters) usually disable it, yeah.

And I'm not an expert in this either, but I'm pretty sure double buffering is the norm, whether you use V-Sync or not.

One buffer in which your graphics card works on frames (I'll call this "graphics card buffer") and then a buffer into which finished frames are moved, so that your screen can read them out in peace (I'll call this "pre-screen buffer").

There's also "triple buffering", which introduces another one of those graphics card buffers, so that when a finished frame is being transferred from that first graphics card buffer to the pre-screen buffer, then your graphics card doesn't have to wait for that transfer to finish and can instead start working in the second graphics card buffer right away. (And then it transfers frames from those graphics card buffers in alternating fashion.)

So, the delay that V-Sync introduces is not that. What V-Sync does, is that instead of transferring finished frames from the graphics card buffer(s) into the pre-screen buffer as soon as the frame is finished, it waits with the transfer until your screen has finished with reading out the previous frame.

If you don't wait (have V-Sync disabled), your screen will read out some part of the previous frame and then read out the rest from the new frame. On the screen, you'll see this break between previous and new frame as screen tearing.

So, assuming your screen can display 120 frames per second and your graphics card happens to finish 120 frames in a second, then V-Sync will not introduce a delay. It'll wait once with transferring the first frame, but then they'll be in sync and no further delay should occur.

However, if your graphics card is able to calculate 240 frames per second (and your screen still does 120 frames per second), then with V-Sync, the graphics card buffer will be transferred into the pre-screen buffer only 120 times per second, making the graphics card slow down to 120 frames per second as well.

Without V-Sync, the graphics card buffer will be transferred 240 times per second, regardless of how often your screen can read it out from the pre-screen buffer. This means a frame will get loaded into the pre-screen buffer as your screen is reading it out. As a result, you'll get screen tearing and one half of your screen will be from the new frame, with a 1/240 s = 4.167 ms delay, the other half is still from the previous frame with a 2/240 s = 1/120 s = 8.33 ms delay.

So, a few numbers:

120 FPS with 120 Hz screen = 8.33 ms delay.

240 FPS with 240 Hz screen = 4.167 ms delay.

240 FPS with 120 Hz screen = ½8.33 ms + ½4.167 ms = 6.25 ms delay on average.

480 FPS with 120 Hz screen = ¼(1/480) + ¼(1/360) + ¼(1/240) + ¼(1/120) = 4.34 ms delay on average.

960 FPS with 120 Hz screen = 2.83 ms delay on average.

960 FPS with 240 Hz screen = 2.17 ms delay on average.

Re: Keyboard latency

#208
The issue not mentioned in the article is number of lines on the keyboard matrix used to detect keypresses. Cheaper non-gaming keyboards can only detect up to 4 simultaneous keystrokes. Gaming keyboards can detect up to 6. That may not sound like a significant difference, but if you're moving diagonally (eg. W and D), running (Shift), holding an item (or use) (E) and jumping (space), that is 5 keys which need to be processed. Moving from my older Gaming keyboard to a generic Logitec keyboard, and I was no longer able to run diagonally in FIFA games while doing trick moves. So the non gaming keyboard made me stop playing that game.

Re: Keyboard latency

#209

Earlier quoted context omitted.

I don't think it's a matter of achieving a faster reaction time by bypassing higher brain functions. It's about looking several steps ahead and planning out multiple steps before you need to do them, and then anticipating when each action needs to happen. One game that really demonstrated this to me was Crypt of the Necrodancer. It's a rougelike where each turn is the beat of a song, and the tempo of the song for eac…

This sounds kind of like how stenographers’ keyboards work. You plan and type words with key combos. Much faster than typing since you react to whole words and think in phrases (so I was told).

Stenotype, like court stenographers?

Re: Keyboard latency

#210

"It all started because I had this feeling that some old computers feel much more responsive than modern machines." s/modern/recent/ "For example, an iMac G4 running macOS 9 or an Apple 2 both feel quicker than my 4.2 GHz Kaby Lake system." Kaby Lake system running OSX? I have one of the last G4 that came with OS9. Based on intuition it would make audio applications "feel" slower, when OSX came out I did not "upgrade…

I suspect the culprit is not the hardware, but the software. Back in the day there were very little between the keyboard and the screen, and most of it were either in rom or in ram. Never mind that unless one were dealing with a big iron or similar, multi-tasking was a big nope. These days most OSs have 10s to 100s of processes going right after a first boot on a clean install. And all those can trip something at "ra…

Just the other day I replied to a Reddit thread, and told a gamer who experienced periodic frame drops in CS:GO to check the other system processes. He protested that he had nothing else running, but elsewhere in the thread a Task Manager screenshot revealed that Windows 10 Smartscreen Filter was chewing through files and bottlenecking the HDD(a problem I've also experienced).

Basically, desktop Windows has crossed the threshold of "needs SSD" to perform adequately. And in theory that shouldn't impact the performance of an older game, but it does, because what happens next is that the scheduler misallocates process time and throws off everything.

Post reply on HN