hyper icon indicating copy to clipboard operation
hyper copied to clipboard

Typing latency

Open indutny opened this issue 10 years ago • 47 comments

Is there any way to reduce latency when typing things? It is not super slow, but noticeably slower than any other terminal that I use.

It feels like I'm typing on ssh terminal.

indutny avatar Jul 19 '16 20:07 indutny

I don't see that latency here 😰

matheuss avatar Jul 26 '16 18:07 matheuss

Neither do I. @indutny can you record a video with your mobile phone?

rauchg avatar Jul 26 '16 19:07 rauchg

there are tools to objective latency measurement https://pavelfatin.com/typing-with-pleasure/ in russian http://tonsky.livejournal.com/306545.html

iamstarkov avatar Jul 26 '16 21:07 iamstarkov

@iamstarkov 👍

indutny avatar Jul 26 '16 21:07 indutny

Just wrote a small C application to measure latency. Turns out HyperTerm is actually faster than iTerm2. My bad!

Still would be cool if anyone else would be able to confirm it independently. I am not absolutely sure that my tool is correct.

(The tool is here)

screen shot 2016-07-26 at 10 01 39 pm

indutny avatar Jul 27 '16 02:07 indutny

Here is updated bench with the latency of typing in this comments form (just for fun): screen shot 2016-07-26 at 10 04 21 pm

indutny avatar Jul 27 '16 02:07 indutny

Though, may be HyperTerm just became faster since last time? :) Have you done anything about performance?

indutny avatar Jul 27 '16 02:07 indutny

Can you publish that C app here at GitHub? I'm interested in how it works 😊

matheuss avatar Jul 27 '16 02:07 matheuss

@matheuss I already did in a comment above. Here it is just in case: https://gist.github.com/indutny/b530593a996bbbe8bfd51fc3f38c45f2

indutny avatar Jul 27 '16 02:07 indutny

Oh, my bad 😅 Thanks!

matheuss avatar Jul 27 '16 02:07 matheuss

Still would be cool if anyone else would be able to confirm it independently.

My observations (subjective) are that HyperTerm has noticeably less latency as I type than iTerm2 but in my case I know a lot of that is due to my zsh config which causes a lot of redrawing as I type.

Though, may be HyperTerm just became faster since last time? :) Have you done anything about performance?

There have been a couple of updates of electron in the HyperTerm package. The most recent one 1.3.0 updates Chrome to version 52 and node to 6.3.0. So there may be some performance improvements just from that.

ghost avatar Jul 27 '16 02:07 ghost

There are certainly some actions at which HyperTerm can be slow. Typing in a new prompt is certainly not one of them (as shown above :P), but we have to consider a lot of different scenarios (like large screen redraws).

rauchg avatar Jul 27 '16 02:07 rauchg

@freebroccolo

There have been a couple of updates of electron in the HyperTerm package. The most recent one 1.3.0 updates Chrome to version 52 and node to 6.3.0. So there may be some performance improvements just from that.

This must be it. I wish I had an old version to compare to.

indutny avatar Jul 27 '16 02:07 indutny

Decided to publish my tool as a separate repo with build instructions (OS X only): https://github.com/indutny/latetyper

indutny avatar Jul 27 '16 02:07 indutny

You can find the old versions here ^~^

matheuss avatar Jul 27 '16 02:07 matheuss

Incredible @indutny

TooTallNate avatar Jul 27 '16 02:07 TooTallNate

@matheuss just tested old versions, all of them seems to be faster than the latest iTerm2 :(

indutny avatar Jul 27 '16 03:07 indutny

Good job HyperTerm, though!

indutny avatar Jul 27 '16 03:07 indutny

Is there any way to reduce latency when typing things?

So it comes down to our measurement approach here. The approach. I chose here is "when can I see the letters after hitting a button on my keyboard". If we drop down into devtools and look at things per each frame we can get a better look at exactly when the new chars are shipped to the user.

image

^ We can see the majority of our frames are shipped to the user well under budget. Since the update loop for the screen is running inside of a requestAnimationFrame we are kinda self limiting how fast we are updating the screen (this is good, and bad in someways -- if we are trying to optimize for shipping the chars to screen as fast as possible)

image

I will be looking more into the costs associated with typing and some easy wins that we can get.

More on this later ✌️

samccone avatar Jul 28 '16 01:07 samccone

Nice @samccone, This might be relevant: http://www.html5rocks.com/en/tutorials/speed/unnecessary-paints/

albinekb avatar Jul 28 '16 01:07 albinekb