454 points · by thesephist · 5y ago · 259 comments
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.
[1] https://www.macworld.com/article/3402336/apple-pencil-change...
It's a few years old now so I've no doubt that Alacritty's performance has improved, but I'm suspicious of the idea that Terminal.app is noticeably slow.
Or if Vulkan is more your jam, doable with: https://www.khronos.org/registry/vulkan/specs/1.2-extensions...
And then "no-latency" input events can be done via View#requestUnbufferedDispatch ( https://developer.android.com/reference/android/view/View?hl... )
I'm sure there's then some way to achieve front-buffer rendering in a software rendered pipeline as well to cut out the GPU latency & avoid tile-based artifacts.
I did try requestUnbufferedDispatch though, and it didn't make a noticeable visual difference, but I need to measure it to make sure.
Example of ROG Phone II results:
Kernel module, display running at 60 Hz: 10 ms
Android, 120 Hz display: 32 ms
Flutter, 120 Hz display: 30 ms
They're only this close because Android gets 2x the refresh rate here, but it's still 3x slower.
Running list of latency tests on many different phones: https://docs.google.com/spreadsheets/d/1mahGpTKZLgKpaBDvcNR7...
I also find the responsiveness noticeable when typing. You'll be able to tell that the text appears faster on the screen.
I wouldn't say it's a requirement. But it does make the user experience nicer.
It's wild that the only hidpi 32" monitor is ~$5000, and it was released a few years ago now.
My eyeballs need that sweet crisp text.
Why is this relevant? I'm seriously considering a 1440p 32:9 240hz Samsung G9 so that I can ditch multiple monitors and move to a single display with similar overall screen space just to dodge pesky multi-screen bugs like this. Just docking my laptop and using a massive screen would be SO NICE!
Only thing that's holding me back is I really want 2160p tall in that form factor. Will probably need to wait for DisplayPort2.0
I'm a huge fan of the LG27GN950. 4k 144hz glory.
Or at the size you are looking for.
Samsung 49-Inch CHG90 144Hz
It's a 49 inch, so not the same PPI. Different aspect ration too (32:9, so 5120x1440).
https://www.samsung.com/us/computing/monitors/gaming/49--chg...
Thats a PPI of something like 80, which may be fine for gaming but is not at all comparable to the high PPI monitors discussed here.
If Apple just sold there 27" display for 1500 bucks or something they would make a killing for folks who want a really nice pro display but don't need the overkill of the Pro Display XDR.
A 27" 4000x3000 display would be a dream come true.
[0] https://www.lg.com/us/monitors/lg-38gn950-b-gaming-monitor
Why do you need 120Hz+ for productivity?
2. No one need do anything except die, but shaving a few ms of response time is nice for productivity. No one thing is critical but making sure you have a keyboard, mouse, monitor, refresh rate, and programs that aren't throwing latency out the window makes for an overall nice feeling system.
I bought all of my other high-refresh screens because wow computing feels so much better in the day-to-day desktop because of it! Not joking in the least.
Another factor is that some (many?) 60 Hz displays buffer a whole frame themselves, and often don't have quick response times. If you go from a 10 ms response time IPS screen with a frame buffer to a 120 Hz gaming screen with 2-3 ms response time, you already got a difference of about 25 ms just in the screen itself.
8 ms is hard to notice. 50 ms less so.
The difference is pretty huge, even on systems that are much better tuned than Linux desktops (e.g. Windows 10).
That being said, while it is very nice and feels nice, it's not necessary for development work; I spend most of my days developing on a system over a VNC connection through a VPN, so the basic input lag of that setup is around 200-300 ms. Gnarly yes, but not particularly bad for text input. You get used to just do everything very slowly with the mouse.
What would you suggest, or either Windows 10 or Linux, to get the lowest latency in a terminal?
As per the linked article, the observed delay improvement isn't one frame, more like ~3 frames. It doesn't go up from 1/24 to 1/165, it goes from 2.5/24 to 2.5/165.
Computer software waits a lot more than it did in 1977. That's why 240hz displays feel much more snappier even if it's supposed to be less noticeable -- you're waiting for same 3 frames, but they pass by much faster.
Though in my totally subjective experience it feels better.
Interestingly the person who did this latency test also did a keyboard latency test:
https://danluu.com/keyboard-latency/
Compared to the slowest keyboard measured it's possible to shave 45ms which if you were latency sensitive would be the biggest reduction.
That's disappointing. He isn't measuring latency nearly as much as he's measuring point of actuation.
The same logitech mouse performs much faster through their universal wireless adapter than trhough bluetooth (it has 2 modes), they also have lightspeed adapter, but I haven't noticed much difference.
I recently got a 165 Hz monitor for my decade-old PC (Sandy Bridge era) and with my (now old) G302 mouse, it's like having a new, much faster PC.
> The interface has two main signal lines, Data and Clock. ... To transmit a byte, the device simply outputs a serial frame of data (including 8 bits of data and a parity bit) on the Data line serially as it toggles the Clock line once for each bit.
Increasing the clock rate absolutely does reduce latency on a PS/2 port.
I guess it's because the latencies stack on top of each other?
It helps both slightly with latency directly, but it also gives you more points to sample from for input prediction which then helps with latency even more. Or for things like drawing applications it'll give you smoother curves assuming the drawing app looks at all intermediate touch samples.
Now whether you will notice that can depend what environment you are in. If your editor already has an input latency of 100ms then shaving 8 off probably is not noticeable. But going from 20 to 12 might be.
Generally, from the tests I've seen, input latency is 30-40ms on a wired keyboard on Windows.
"The human eye can't tell the difference past 30 FPS" was literally just a thought-killing cliche repeated by console gamers getting into internet slapfights with PC gamers.
You can see the difference for yourself here on any 60hz monitor: http://www.30vs60fps.com/
In it, they have a segment on frame rate[2], where he mentions that the neurons can only fire about every 13ms, or about 75 FPS. But, the important point, they're not in sync like a computer screen is. This means the effective update rate for a group of neurons can be much less.
Even then, the problem is that eyes don't work like cameras or monitors. Our eyes don't work with "frames". Each receptor updates on its own time. It's easy to see that, if the updates are staggered, multiple sensors could perceive higher frame-rates, even if they can't individually.
However, there's another angle to this. Disregarding input lag, which is a very real phenomenon and is greatly shortened by higher refresh, higher refresh rate monitors are able to show more 'discrete' steps for anything that's in motion. Our eyes (and brains) perceive this as movement 'smoothness', even if they can't quite make out every single frame that's displayed.
You should try that yourself. Do a blind test.
The easiest way to show this is by wiggling your mouse around quickly on a computer screen.
At 30hz - you'll see the mouse teleporting around - hopping from spot to spot, but not moving. For example, if you stare in the middle, and jerk the mouse quickly to the right, you'll see the 4 or 5 spots where it rendered.
With 60hz, you'll see the 9 or 10 spots - and have a stronger illusion of movement.
With 120hz, it might even look as smooth as a real object flying across your screen.
It's as absurd as saying it's impossible to tell the difference between a 55" 720p display compared to a 4k one at a distance of 1 foot away.
Additionally, another thing I've noticed in the last decade is the very badly PWM-frequency-tuned LED headlights on some cars. Those engineers selected the wrong LED brightness and tuned it to terrible frequencies which leave flicker-trails when you look at or away from them.
Get those PWM frequencies above 500Hz please! Especially get above 200Hz with your LED frequencies at the very least.
Lower framerates are less noticeable in low light, which is another reason why films look acceptable.
*Talented animators/cartoonists can get away with lower framerates
I suspect there some very big fancy rendering pipeline occurring, because when I open Windows Terminal I get the nVidia overlay popup which normally only comes up when I launch games, indicating the terminal is using a GPU-based rendering engine. Which I'm sure confers some interesting benefits, but it's a heavy price to pay when, at the end of the day, it's just a terminal.
The cmd need to do a lot of things (font rendering, layout whatever) without help of other services (It need to work even without them, see the recovery mode). So it effectively bypass a lot of interactions with other services a normal program need to do in order to put the text on screen. It is basically the tty? in Windows.
But that also means it need to sacrifice a lot of things because that aren't available in recovery mode. You get no fancy emoji supports or whateve feature you would expect in a modern terminal. And the text rendering looks very bad until recently the remake the conhost.
* deferred vs forward rendering (deferred adds latency)
* multithreaded vs singlethreaded
* vsync (double buffering)
https://www.youtube.com/watch?v=8uYMPszn4Z8 -- check at 6:30 the latency of 60fps vsync on 60hz. It's not even close to 16ms (1/60), it's ~118ms (7.1/60).It's far cry from simplified pure math people think of when they think of fps in games or refresh rate for office and typing. Software is very very lazy lately, and most of the time these issues are being fixed by throwing more hardware at it, not fixing the code.
Some things cannot be 'fixed'. It's always a trade-off. You can't expect to have all the fancy effects that rely on multiple frames and also low latency.
If there was a simple software fix, GPU manufacturers would be all over it and pushing it to all engines. It's in their interests to have the lowest latency possible to attract the more hard-core gamers (which then influence others).
Just look at all the industry cooperation that had to happen to implement adaptive sync. That goes all the way from game developers, engines, GPUs, monitors. Sure that sells more hardware(which brings other benefits), but a software-only approach would also allow companies to sell hardware, by virtue of their "optimized" drivers.
Wah? Deferred just refers to a screen space shading technique but it still happens once every frame.
> * multithreaded vs singlethreaded
Not sure what you're saying here.
And then of course, yes display buffering does have an impact.
In principle, you can push GPU pipelines to very low latencies. Continually uploading input and other state asynchronously and rendering from the most recent snapshot (with some interpolation or extrapolation as needed for smoothing out temporal jitter) can get you down to total application-induced latencies below 10ms. Even less with architectures that decouple shading and projection.
Doing this requires leaving the traditional 'CPU figures out what needs to be drawn and submits a bunch of draw calls' model, though. The GPU needs to have everything it needs to determine what to draw on its own. If using the usual graphics pipeline, that would mean all frustum/occlusion culling and draw command generation happens on the GPU, and the CPU simply submits indirect calls that tell the GPU "go draw whatever is in this other buffer that you put together".
This is something I'm working on at the moment, and the one downside is that other games that don't try to clamp down on latency now cause a subtle but continuous mild frustration.
https://github.com/microsoft/terminal/blob/main/src/renderer...
The first comment in this function (DxEngine::StartPaint), for example:
// If retro terminal effects are on, we must invalidate everything for them to draw correctly.
// Yes, this will further impact the performance of retro terminal effects.
// But we're talking about running the entire display pipeline through a shader for
// cosmetic effect, so performance isn't likely the top concern with this feature.That said, the VR space has a much tighter tolerance on input lag and there's hardware based mitigations. Oculus has a lot of techniques such as "Asynchronous Spacewarp" which will calculate intermediate frames based on head movement(an input) and movement vectors storing the velocity of each pixel. They also have APIs to mark layers as head locked or free motion etc.
I tried it a few years ago but stopped using it for reasons I don’t exactly remember at this point, and I see that it’s still pre-1.0. Wondering what people think of it these days.
The threshold for me (and most people I think) is about 110ms between key strike and something appearing on the screen before something feels non-local and disembodied... which is good because I found I could get down to ~40ms local response time on a decent windows box. My 2015 macbook is about ~120ms for the terminal app.
That leaves 70ms latency budget to play with which can accommodate the the RDP overhead (~50ms) and the network hop (~10ms for me).
This whole journey started with me wondering if I should pay a small fortune for a better network connection, before I realised that most of the latency was in my keyboard and monitor!
I even built a Arduino Leonardo gadget to measure the lag systematically and some pcap software to spot the RDP packets on the wire. The code's pretty shoddy but it does the trick! You can see it and an example result with RDP here:
https://github.com/willmuldrew/lagmeter
Another big factor in the experience is jitter - so it's a good idea to ensure everything is plugged in if you can. Mice, keyboards and ethernet.
In essence, even if you have to RDP/remote into work, potentially you can still make it feel pretty local - don't give up hope!
At least until we arrange for everyone to have company provided dedicated work laptops which we can (mostly) lock down to the satisfaction of our clients and their auditors, but the switch to mostly remote working this year happened at roughly the same time as budgets were squeezed a bit (bet you can guess why!) so that hasn't happened across the board yet.
Allowing RDP from non-secured devices "for the time being" is iffy, but we are getting away with it due to the circumstances.
Latency is not really an issue to be honest. I think ping is about 15ms which is much less than the lag in this article. Right now I'm using the horrible, 2012-era work laptop with just Chrome running and there are delays typing this comment into HN which is a super lean site as it is.
The main downsides are actually
* crap single-threaded performance (don't think Azure has VMs over 3ghz except maybe the highly expensive GPU ones)
* Slow IO
* Video and audio over RDP really doesn't work.. no hardware graphics accel either... reduced ability to work on multimedia, we had one webapp where WebGL wound up behaving differently which we didnt
I'd describe hp and ti as laggy and slick, respectively. The 50g is what I used in university, but now I seldom touch it as the 86/89 are so much more pleasant to use.
Same deal or worse with Teams, the performance of which is goddamn execrable. My laptop is an awful 2012 thing but it shouldn't take 5 seconds to switch between chats.
I haven't used it with slack but it works just fine with discord. You don't get voice noise cancellation with ripcord but you don't need that if you use rtxvoice anyway.
https://mobile.twitter.com/programmer_just/status/1253098759...
I crave some good old fashioned responsive computing, but moreover I want to fill my classroom with these devices and show a new generation that, to borrow a catchphrase from a far more noble cause, it gets better.
Sure, they are less portable and difficult to manufacture/repair. But their combination of refresh rate (without blur), image quality, and color reproduction are still second to none.
Considering the price of an nVidia 3080, which is standard PC gaming equipment, there must be a market for high end screens for gamers.
Not true. A current generation OLED (which will do 120hz) is superior to a CRT.
Even still, on many of those a good LCD has long been better than a good CRT. Color accuracy, for example. CRTs required constant fiddling & calibration to stay good at that, whereas a quality factory calibrated LCD will be much better in an "out of the box" or typical usage. Not really sure what you're calling "image quality" but it's hard to imagine that going any way but solidly in a modern high-end LCDs camp, which are brighter, wider color gamuts, higher resolution, and higher pixel densities than CRTs ever had.
> there must be a market for high end screens for gamers.
There is, which is why we have high resolution, high refresh rate, and adaptive vsync IPS monitors a plenty now. They come in all sorts of shapes & sizes, in resolutions & dimensions CRTs could only dream about.
Color and raster flexibility are the two bright spots for me.
Glowing phosphors in tubes is just a great tech.
It just doesnt feel right, and slowmo video capture confirms it.
I also experience the lag on my windows desktop while dragging windows.
Also V-Sync is off now.
AMD even has an "anti lag" feature which apparently does nothing.
Edit: I have a Ryzen CPU, I've expected the full AMD system to work together better.
Keypress responsiveness when typing is night and day, and given where I'm posting this comment, you can guess who has the advantage.
Platform: GNU(Linux)Mint Xfce
...which is, like the rest of the DOS-based Windows from Windows/386 onwards, itself a sort of hypervisor architecture --- DOS applications effectively run in VMs thanks to V86 mode, giving native performance. The difference is very noticeable if you open something like MS-DOS EDIT on Win9x vs. NT 4/2K/XP --- the latter runs in an emulated environment and the latency is enormous.
The Windows setup is convoluted, awkward, and weird sounding compared to the native app. They are using it for a reason though: it’s much much more responsive than native Linux LibreOffice.
This was posted here few times but it's still an interesting read in this context.
I have a hunch it eliminates some...
The Blackberry q10 runs Blackberry OS 10, which is based on QNX, which has a realtime microkernel.
I suspect it's just that input processing is so cheap on those early architectures, that latency is really dominated by hardware constraints and not by CPU (however slow it might be). Certainly, on the //e, I'm pretty sure the input routine did little more than copy the character to the input buffer and the screen buffer and advance the cursor. The TI's probably was not much more complicated, despite being implemented in bytecode.
Editing with EDT felt quite snappy. Amazing.
I once read that properly written Amiga software achieved around 16ms latency and would like to see that verified or debunked.
Just about every application on Apple 2e relied on keypresses being shown on the screen. Modern devices and operating systems are displaying 'windows', streaming 3d graphics etc. and running a myriad of other services at the same time.
Even in a mostly passive app like a video player, it sucks if the play/pause button has a long-delayed effect. The tendency is to press the button over and over and feel correctly that we have lost control of the app.
Secondly, not every PC in 1999 was capable of even running QIII (let alone at a high frame rate).
During the days of true low-latency gaming, actual game frame rates were in the low 20s and even consoles rarely achieved 50 or 60 fps.
If a game was playable at 20s of fps, I don't think it deserves a title of low-latency gaming.