Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pasting large blocks of characters into the interactive interface #46

Open
driftluo opened this issue Jun 29, 2018 · 4 comments
Open

Pasting large blocks of characters into the interactive interface #46

driftluo opened this issue Jun 29, 2018 · 4 comments

Comments

@driftluo
Copy link

driftluo commented Jun 29, 2018

Problems with performance when pasting large blocks of characters in the interactive interface.

For example, copy 1.5w characters into the interactive interface, it takes more than one minute to complete, and during this time, the program will occupy a 100% CPU usage. But in a terminal such as bash/zsh/fish, it can be completed within seconds.

This phenomenon is easy to reproduce, I think it should be a bit of a problem reading part. . I need some help,is there any problem with my use?

@murarth
Copy link
Owner

murarth commented Jun 29, 2018

Yes, there is a noticeable delay when pasting even reasonable amounts of text, such as a few hundred characters. I'm looking into how this can be addressed.

For example, copy 1.5w characters

Is this is a typo? I'm not sure what you're trying to say.

@driftluo
Copy link
Author

driftluo commented Jun 30, 2018

Sorry, 1.5w characters means 15 thousand characters

Chinese “万” => "wan" => w

@murarth
Copy link
Owner

murarth commented Jun 30, 2018

I've improved the performance a bit by not re-acquiring the write lock for each character input. When compiled in release mode, the demo can handle a paste of 15,000 xs in about five seconds.

perf is showing that the most time is spent running display_size, which is used to determine the line/column position of some cursor position, in order to determine when output is about to hit the edge of the terminal screen. This function is run on the entire existing buffer for each character of pasted input. This is most likely the cause of poor performance when pasting large texts.

One solution to this problem is to cache the current line/column position of the cursor, but keeping that cached value correct with all the various cursor movement and text manipulation commands supported by linefeed would not be a simple task.

I'll give the problem some thought and try a few things and let you know what I come up with.

@driftluo
Copy link
Author

So cool, although the problem persists in debug mode, the efficiency in release mode is already acceptable.

I look forward to even better optimization, by the wey, the confirmation of the position of the cursor does have some minor problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants