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

Searching in a long line can be slow #370

Closed
gwsw opened this issue May 28, 2023 · 3 comments
Closed

Searching in a long line can be slow #370

gwsw opened this issue May 28, 2023 · 3 comments

Comments

@gwsw
Copy link
Owner

gwsw commented May 28, 2023

Searching for text near the end of a very long line can be unreasonably slow. For example, run

seq 30000 | tr '\n' ' ' | less

This produces a file containing one line which is 168,894 chars long. Type /29999 to search for a string near the end of the line. On a fairly fast desktop system this takes 160 seconds to complete.

@gwsw
Copy link
Owner Author

gwsw commented Sep 11, 2023

Fixed in 236e041.
The seq test now takes less than 1 second instead of 160 seconds.

@gwsw gwsw closed this as completed Sep 11, 2023
@gwsw
Copy link
Owner Author

gwsw commented Nov 21, 2023

Note: 236e041 was buggy when used with non-ASCII text.
Really fixed in 3f8d4ab.

@mohd-akram
Copy link

This is still slow for me, but it was never 160 seconds. Performance is the same between versions (on a MBP 2016):

less 643:

$ less --version | head -n1
less 643 (POSIX regular expressions)
$ seq 30000 | tr '\n' ' ' | time less +/29999 +q
       10.80 real         7.49 user         0.12 sys

less 651x:

$ ./less --version | head -n1
less 651x (POSIX regular expressions)
$ seq 30000 | tr '\n' ' ' | time ./less +/29999 +q
        9.25 real         6.21 user         0.07 sys

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