8 ms·
Latency matters
- mjevans 9y agoThis guy must have not noticed after adding a thousand papercuts to each terminal prompt. Premature optimization is one thing, but sometimes it is a good idea to compare against a baseline.
- majewsky 9y agoIt's not like I'm the only one adding papercuts to the stack. ;) From the top of my head, each keypress goes at least through the keyboard driver, X11, possibly the window manager, the terminal, the line discipline, the terminal again, font rendering, compositing, and then display. It only takes one of these steps to mess up for latency to go up.
- mjevans 9y agoThe latency was in constructing the 'prompt' string (via his custom program). The actual input latency in the stack is both 'constant' and rather difficult for an end user to directly affect. Thankfully the millions of human-hours put in to the hardware and software stack have made that quite efficient.
- majewsky 9y ago> The actual input latency in the stack is both 'constant' and rather difficult for an end user to directly affect. The article starts with a link to https://danluu.com/term-latency/ https://danluu.com/term-latency/, which disproves both assertions.
- jstimpfle 9y agoLatency is one of the reasons why I still use xterm and bitmap fonts. The other being font crispness on standard ~100dpi displays.
- kristianp 9y agoThe crisp shape of the text often makes me nostalgic for systems pre cleartype on windows and pre-gnome 3 on linux.
- Cieplak 9y agoWith an arduino and an LED, it's simple to test the limits of one's perception. Copy one of the hello world LED blinking programs (basically a square wave to a GPIO pin) and modify the frequency of the blink. I see a rapidly blinking light around 15ms period, and a solid light around 10ms period. To me that implies that my human sample rate is about 12ms, although there could be other factors at play, such as capacitance in the circuit. Edit: s/frequency/period/
- dboreham 9y agoms is a unit of time so your numbers denote "period" not "frequency" (unit : Hertz).
- deleted 9y ago[deleted]
- zokier 9y agoThat test does not really measure the ability to notice latency. The simplest latency test I can imagine would be a system where you press a button and LED lights up (or a sound is played). Do that in pairs where randomly either the first or second trial has some latency added in. Then ask the subject which one seemed to respond faster. Rinse and repeat about gazillion times with different amounts of added latency. The problem with such setup is that it relies on conscious notice of latency. It is very likely that the boundary where latency begins to impair performance is far lower than where you actually notice it. A more sophisticated test would be to measure e.g. typing speed vs latency. You'd probably need some customized hardware to get low baseline latency so that you can then add latency in a controlled way. Even then I imagine that quite many trials would be needed to make any conclusions.
- Moru 9y agoAnother way would be moving the mouse and seeing the cursor lag behind. Old wireless mices could have some real bad lag. It feels somehow like holding a garden hose and trying to hit different spots on the lawn with the water. There was people that just didn't notice anything but everyone playing Quake halfway good had bad problems with those. Some went so far as to only use wired mices with ball, not even optical sensor.
- pasbesoin 9y ago300 baud --> 1200 baud. Now there was a noticeable difference. And yet, many years later, I had an impossible time explaining to a the more pointy-haired end of a large development division, why IBM Rational products might not work so well when accessed from halfway around the world. (They are/were very "chatty" between client and server, and the cumulative latency of all those round-trips simply killed you.) Latency's still a sticking point, and a lot of people don't understand/believe it until they see it for themselves. P.S. It may sound like I'm talking about something else -- apples and oranges. But no. What I mean is, in many domains, people don't get latency until they experience it. I suppose that decades ago, that typewriter was just fine. Until you got fast enough. Then, as the stuck key mashes and/or other physical limits started to cap and impact your performance, you realized what people meant about "better" mechanisms. I wonder whether in some cases, people like musicians have a better natural perspective on it. Domains where it's more readily apparent and dealt with. Sorry, my mind's a bit all over the place, today...
- majewsky 9y ago> What I mean is, in many domains, people don't get latency until they experience it. Exactly. That's also precisely what I was going for in the article.
- aidenn0 9y agoUgh; one site I visited had the requirement that all developers work from clear-case dynamic views. The server (yes, singular server) was in a different building. The developers had turned build-parallelism up to 99 simultaneous jobs to try to keep the CPU busy while waiting for the network, but a build was still only using about 10% of a single CPU. An incremental build would take over a minute for dependency checking, and a full rebuild would take hours.
- richdougherty 9y agoI can't help but think that since he's measuring his own perception at the ms level - for a new program he's written himself - that it would be easy for unconscious bias to creep in. To really know the truth about whether latency matters in this case, a better experiment is probably needed. Not that I think he should bother doing this, I'm just being the fun police. :)
- majewsky 9y agoI don't really know how to eliminate my own biases here, but a quick test shows that the new prompt feels very much like the old one if I add a little latency manually: PROMPT="\$(prettyprompt \$?)" PROMPT="\$(sleep 0.04; prettyprompt \$?)" With the second one, I can always see a frame or two where the cursor is already on the next line where the prompt will go, before the prompt actually shows up.
- darawk 9y agoPresumably the test would be whether he can, in a blind experiment, reliably discriminate between them.
- alecbenzer 9y agoYeah -- seems like it'd be a bit tricky to set up, but would be super interesting to see the results. edit: Tried something out: https://github.com/AlecBenzer/terminal-latency https://github.com/AlecBenzer/terminal-latency Had 92% accuracy differentiating 10ms from 100ms out of 28 tries
- richdougherty 9y agoNice!
- tomxor 9y agoNo, you can easily measure this stuff with "time". It was 75ms vs 3ms for python vs go... this is for some custom prompt he wrote, so this is the time it takes to get the new prompt every time he was pressing return. I don't think it's that big a deal, if it was navigation keys in a text editor then it's a big deal, but when you hit return you are usually executing something much longer than ~50ms anyway so it's not an overhead that's going to multiply that much.
- emerongi 9y agoLatency is the reason I just can not use some editors, most notably Atom. You get used to it after a while, but it's not fun. I remember when I used IntelliJ's product line for a good while and then opened up Vim. I was dumbfounded that I somehow had not noticed that IntelliJ was slow. It's fast enough - not Atom - but Vim was amazing next to it.
- majewsky 9y agoThat reminds me of another thing that I noticed. My vim gets really sluggish (as in, 1 fps and worse) when I have a Firefox window on the other screen showing a Concourse pipeline [1]. If I change to a different tab, vim is suddenly fast again. [1] https://concourse.ci https://concourse.ci
- aidenn0 9y agoHaving used vi over low-speed serial links means that I can handle latency just fine. Also hjkl were noticably faster because they sent fewer characters over the lines compared to arrow keys which used escape codes...
- watchdogtimer 9y agoFunny, I've noticed just the opposite using vim on a desktop or laptop--and its always driven me nuts. If I'm editing a file and type several repeating j or l commands (e.g., 'jjjjj' in command mode), there is noticeable latency between the last movement command and the last cursor movement. I get no latency, however, when performing the same commands using the right or down arrow keys. The 'h' or 'k' commands have no latency, either, just 'j' and 'l'. I've been using vim for years and still find it frustrating. I haven't noticed the same problem with other vi clones (e.g., nvi or elvis).
- aoeusnth1 9y agoI don't notice any difference with Spacemacs' evil-mode (a vim mode)
- valarauca1 9y agoThe reason they sell monitors at 144FPS and now 256FPs is because people can see and react that fast. Sure those are generally for video games. But pretending <Xms is the end-all-be-all of human perception is arrogant.
- stanlarroque 9y agoI'm working on an AR headset and we made some experiments with the human eye. I barely can notice the difference for motion above 120 fps. But my associate is a retired fighter pilot and he can react to motion at ~280 fps.
- emj 9y agoHow do you test that; can you measure how you react to motion at 120fps vs 280fps, or is it just a feeling?
- stanlarroque 9y agoIt's not a feeling, we do the measures. It's like measuring your reaction time, few experiments are on screen and some are analogs. At the end you have a measure in a unit of time, and you deduce the fps from that
- valarauca1 9y agoIn FPS there are people called "stat junkies" the name expresses its hobby well. You try to play for the best stats. Head shot ratio (how often you get head shots), KDR (kill death ratio). You could likely data mine from stat sites before before/after purchasing very high refresh rate monitors. OFC there maybe some bias to try harder once you drop >$400 on a hobby. In my own subjective experience 60 -> 144FPS was night and day. Roughtly ended up being a 50% pref improvement.
- mattkrause 9y agoThere's got to be something else going on there. 280 frames/sec is about 3.5 ms/frame. Signals don't even leave the retina that fast, let alone propagate to brain areas linked to perception and action. Perhaps the higher frame rate makes the motion smoother, which allows the pilot to estimate and extrapolate an objects' motion more accurately, or something like that.
- Animats 9y agoAlan Kay once said something like "There should no more be a delay between pressing a key and something happening on a computer than on a piano."
- hvidgaard 9y agoThat I can get behind, even if it is just a busy icon showing.
- edejong 9y agoBeautiful back-on-the-envelope exposition on the latency of playing the piano: http://northernsounds.com/forum/showthread.php/37769-Acoustic-piano-latency?s=da097aee6ac23ded20434b03d6f1d748&p=333833&viewfull=1#post333833 http://northernsounds.com/forum/showthread.php/37769-Acousti...
- dredmorbius 9y agoChurch organs, on the other hand, take some getting used to. Even for solo performance, but especially when performing with an ensemble or choir. https://music.stackexchange.com/questions/30454/how-does-a-pipe-organist-deal-with-latency-or-delay https://music.stackexchange.com/questions/30454/how-does-a-p...
- skybrian 9y agoThis is a good point, but remember that if you're in the habit of using computers too much, you shouldn't want lower latency. Higher latency is less addictive if you're trying to cut back.
- majewsky 9y ago> in the habit of using computers too much If you have any advice how to use computers less in my job as a developer and Devops engineer, I'll gladly take it.
- skybrian 9y agoYeah, I'm thinking more about social networks and games. I've never heard of anyone addicted to the command line.
- reificator 9y agoMight as well face it, you're addicted to bash EDIT: My Unicode musical notes at the start and end of the line didn't make it. :(
- zero_intp 9y agohear it now.
- loopdoend 9y agoI realize that smartphones are computers, but you might find the SSH client "Prompt 2" by Panic on iOS useful for the devops part. Avoids the need to whip out the laptop to SSH in somewhere.
- Skunkleton 9y agoKen M, is that you?
- deleted 9y ago[deleted]
- secure 9y agoI agree. A while ago, I was so fed up with how long my prompt took to render, I went through my zshrc and cleaned up a bunch of stuff to make it faster: https://github.com/stapelberg/configfiles/compare/5ccd3cbd38b67e5ec91671b6fe07d5dded0e96fa...9ee8b13de00c2c84463681fc91f3fd64ae2e4342 https://github.com/stapelberg/configfiles/compare/5ccd3cbd38... The general techniques used in order of preference are eliminating/skipping work, lazily doing work later, replacing external commands with zsh builtins.
- majewsky 9y agoViewing your diff made me wonder if there is a market for custom-compiled shells, where things like the custom prompt or termtitle are baked in at compilation time.
- twhb 9y agoAlong similar lines, I noticed some latency to Apple Terminal's prompt and made this to fix it. https://github.com/twhb/terminal-prompt-perf https://github.com/twhb/terminal-prompt-perf
- zde 9y agoPython startup latency is horrible, and unfixable. It got much worse in python3 because it loads much more modules (think of all the unicode crap).
- Skunkleton 9y agoYeah, I did a little test on my system where I wrote a program in C, Python, Perl, and Bash that just prints hello to the console then timed how long it took to fork/exec from bash. C takes ~0.5ms, Perl is ~1.5ms, Bash is ~2.5 ms, and Python 3 is ~35ms. Kind of sad because there are lots of places where a python script would be a nice way to solve a problem, but I cant use it because it adds an annoying delay.
- aaronbwebber 9y agoI think Python's primary use case has now shifted far enough from scripting to server-side web development that ~35 ms of startup time to deal with Unicode better is a worthwhile tradeoff for the majority of Python users. It does raise an interesting question about whether there is now an opening for a new scripting language to develop. I don't think any of the well-known languages developed in the last ~10 years have been what you might call "scripting" languages.
- Skunkleton 9y agoI am not knocking python here at all, just pointing out that it doesn't work well for some tasks. I wonder if the startup latency could be fixed though?
- hvidgaard 9y agoIn what use case, is a 35ms startup time an issue?
- deleted 9y ago[deleted]
- 9y ago
- KirinDave 9y agoFor those who are fans of Powerline but fed up with the latency of Python, you can use powerline-server OR you can take a similar cue and use: https://github.com/rdnetto/powerline-hs https://github.com/rdnetto/powerline-hs
- jlgaddis 9y agoI like powerline but it really is slow as molasses -- even after I disabled a bunch of the (useless) default stuff. powerline-daemon was supposed to help but, if it did, it wasn't really noticeable.
- KirinDave 9y agoPowerline-hs is pretty quick.
- kuschku 9y agoI decided to rewrite https://github.com/banga/powerline-shell https://github.com/banga/powerline-shell in go after reading this article yesterday evening (almost done, only mercurial, svn and fossil are missing), and the performance is amazing. The latency went down to 200µs (except when git is used, then it’s ~4ms), and it’s fast enough. Here’s a video: https://s3.kuschku.de/public/2017-08-21_16-43-41.mp4 https://s3.kuschku.de/public/2017-08-21_16-43-41.mp4 I’ll put it on https://github.com/justjanne/powerline-go https://github.com/justjanne/powerline-go later today, once I’m done.
- diegorbaquero 9y agoCheck mosh! It's an amazing tool for that lag
- majewsky 9y agomosh is definitely on my list of "stuff that I need to check out", but the things that I showed in the article was all on localhost.
- majewsky 9y agoAs a semi-related followup, since my blog made the frontpage for the first time, I looked at whether the HN crowd is visible on the monitoring charts: https://blog.bethselamin.de/posts/latency-matters-aftermath.html https://blog.bethselamin.de/posts/latency-matters-aftermath....
- dredmorbius 9y agoAnd a semi-related question: is there some particular reason you've replaced a sensible, directly-proportional, and useful vertical scrollbar with an (IMO) insensible, literally orthogonal, top-placed horizontal scrollbar ... which cannot actually be used to control location within the document? I've noted the demise of the vertical scrollbar before. This is the first chance I've had to ask someone who's apparently implemented a horizontal one directly. I'm quite curious as to the rationale. Previously: https://ello.co/dredmorbius/post/0hgfswmoti3fi5zgftjecq https://ello.co/dredmorbius/post/0hgfswmoti3fi5zgftjecq https://ello.co/dredmorbius/post/0hgfswmoti3fi5zgftjecq https://ello.co/dredmorbius/post/0hgfswmoti3fi5zgftjecq
- jlgaddis 9y agoFrom "Russians Engineer a Brilliant Slot Machine Cheat—And Casinos Have No Fix" [0]: > Finally, the St. Petersburg team transmits a list of timing markers to a custom app on the operative’s phone; those markers cause the handset to vibrate roughly 0.25 seconds before the operative should press the spin button. > "The normal reaction time for a human is about a quarter of a second, which is why they do that,” says Allison, who is also the founder of the annual World Game Protection Conference. [0]: https://www.wired.com/2017/02/russians-engineer-brilliant-slot-machine-cheat-casinos-no-fix/ https://www.wired.com/2017/02/russians-engineer-brilliant-sl...
- kevmo314 9y agoSometimes I wonder if it would be called cheating if you could do the math to figure out the PRNG parameters in your head, then calculate the next known timestamp. It seems similar in premise to Ethereum contracts, where an "exploit" is technically just following the contract.
- stinos 9y agoHow do some applications practically get to latencies smaller than 16.6mSec? That can only be possible if the character typed is being rendered directly into the GPU buffer which currently is being drawn right? Or does the screen used for testing this run at a higher refresh rate than 60Hz? Or does 'latency' not mean time between hardware keypress and character appearing on screen?
- Qwertious 9y ago16.6ms is the maximum lag between the monitor receiving the framebuffer and drawing it - the average would therefore be half of that, and the minimum would be essentially zero. But, that's ignoring all the other little delays in the system. For instance, monitors have a delay of a few milliseconds. In short, this is a massive oversimplification.
- dlsniper 9y agoSee here how to actually check for latency: https://pavelfatin.com/typing-with-pleasure/ https://pavelfatin.com/typing-with-pleasure/ :)