Typing latency #296

Open
indutny opened this Issue Jul 19, 2016 · 34 comments

Comments

Projects
None yet

indutny commented Jul 19, 2016 edited

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.

Owner

matheuss commented Jul 26, 2016

I don't see that latency here 😰

Contributor

rauchg commented Jul 26, 2016

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

Contributor

iamstarkov commented Jul 26, 2016

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

indutny commented Jul 26, 2016

@iamstarkov 👍

indutny commented Jul 27, 2016

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 commented Jul 27, 2016

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 commented Jul 27, 2016

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

Owner

matheuss commented Jul 27, 2016

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

indutny commented Jul 27, 2016

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

Owner

matheuss commented Jul 27, 2016

Oh, my bad 😅 Thanks!

Contributor

freebroccolo commented Jul 27, 2016

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.

Contributor

rauchg commented Jul 27, 2016

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).

indutny commented Jul 27, 2016

@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 commented Jul 27, 2016

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

Owner

matheuss commented Jul 27, 2016

You can find the old versions here ^~^

Owner

TooTallNate commented Jul 27, 2016

Incredible @indutny

indutny commented Jul 27, 2016

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

indutny commented Jul 27, 2016

Good job HyperTerm, though!

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 ✌️

Contributor

mike-engel commented Jul 29, 2016

I've noticed some "perceived" latency when using the backspace key—that is, when typing, it seems pretty performant. When using backspace/delete, I've noticed that there's a small time difference between when the character goes away and when the cursor moves to the previous position. I don't know if this is what @indutny was talking about (it may have been typoing in both directions). If so, we can probably do some work to move the cursor faster to where it should be.

goes away and when the cursor moves to the previous position

This is due to how hterm implements the cursor update :)
https://github.com/dbkaplun/hterm-umdjs/blob/master/dist/index.js#L13004-L13013

I would say this is WAI :)

Contributor

mike-engel commented Jul 29, 2016

Interesting...thanks @samccone. Probably some room for improvement there 😄

I'm seeing the behavior described by @mike-engel as well. I frankly can't tell the latency difference between iterm and hyperterm, but that deletion latency is really visible.

@chenglou do you observe "latency" in the char being deleted or the cursor moving?

The cursor moving. Also somewhat visible during insertion.

Here's a slowed down recording of what I'm seeing:
perceivedlatency

This is due to how hterm implements the cursor update :)
https://github.com/dbkaplun/hterm-umdjs/blob/master/dist/index.js#L13004-L13013

^ 😄 -- this could be fixed upstream

Zirro commented Aug 27, 2016 edited

I can confirm seeing the delay between character input and cursor movement as well. Unfortunately it is enough to make typing in HyperTerm an uncomfortable experience.

EDIT: Things seems to have changed for the better in builds of latest master, perhaps as a side-effect of another update since there was no mention here. The delay is far less pronounced and the improvement clearly visible on a slowed down recording.

fernahh referenced this issue in frontendbr/forum Oct 20, 2016

Open

Vantagens de usar o Hyper.App #332

I'm not sure if this belongs here or if I should open another issue, but:

If I am using render heavy commandline apps, e.g. midnight commander. I can recognize a very heavy latency of half a second with every input. This make it unusable.

You can reproduce this with installing midnight commander and just try to navigate with the arrow keys.

@reicheltp can you record a timeline please right click and save and then share a link to it on https://chromedevtools.github.io/timeline-viewer/

thanks

Contributor

rauchg commented Nov 23, 2016

@reicheltp very interesting! I'd love to reproduce it as well. Can you tell me exactly what programs you open and in what order?

@samccone Here a short timeline:
https://chromedevtools.github.io/timeline-viewer/?loadTimelineFromURL=https://gist.github.com/reicheltp/0bd72cbe69575b43073c7b02320b4bc0/raw

The first long frame is, when I opened the midnight commander with mc, Second and third are a simple tab to switch columns. And fifth and sixth are page-up and page-down. As you can see, the frames are really long.

@rauchg I have used Midnight Commander for Windows (Get it here https://sourceforge.net/projects/mcwin32/) or the OSX/Linux version here (https://www.midnight-commander.org/)

My Setup is Windows 10 Enterprise x64 with latest Hyper.app. Tried with powershell and cmd.

Collaborator

chabou commented Apr 13, 2017

@reicheltp is it still a valid issue? Can you reproduce with v1.3.1?

@chabou Although I can notice a slightly performance improvement with v1.3.1, the issue still exists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment