Skip to content

make pickers not block typing when it is processing (using libuv async handle) #386

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

Closed

Conversation

oberblastmeister
Copy link
Contributor

I have made the on_lines callback for nvim_buf_attach async using uv_async_t. This has extreme performance benefits even with such a small code change because the cursor can keep moving while telescope is processing. I am using uv_async_t instead of luv_work_ctx_t or luv_thread_t because I don't think that the thread ones can change state. In my tests they crash while the async one is fine. We probably still need to make the actual picker faster but making it async is a good step as it makes the user feel like it is going fast.

@Conni2461
Copy link
Member

I notified tj. He wanna look at that but if that works that could be huge :) Thank you very much 😄

@clason
Copy link
Contributor

clason commented Jan 4, 2021

Briefly testing it, I noticed that the grep_string finder spawns a new rg instance every time it is run and then abandoned -- leaving a bunch of rgs hanging around and eating memory until neovim is closed.

@oberblastmeister
Copy link
Contributor Author

@clason did you mean it happens on live_grep because I tested it and it only happens on live_grep. I also tested it on the main branch and my async branch and the same behavior seems to happen.

@tjdevries
Copy link
Member

@oberblastmeister Thanks! I will try and test soon.

@clason sounds like I need to track down this issue anyway :) I can try and figure it out -- I thought we were freeing those results, but maybe we are not. Thanks for testing.

@clason
Copy link
Contributor

clason commented Jan 4, 2021

@oberblastmeister no, it's on builtin.grep_string { search = '' } (on my home directory, so the result list is long)

You're right that the rg processes hang around on master, too, but they don't eat memory and delay neovim. Might have to test more, though?

@kkharji
Copy link
Member

kkharji commented Jan 5, 2021

according to #392 (comment) the issue is still present

Comment on lines +810 to +813
utils.async(function() self.previewer:preview(
entry,
status
)
) end)()
Copy link
Member

@Conni2461 Conni2461 Jan 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wound not do that at all. The buffer previewers are already async and termopen previewer does also not need that.

Edit: yes it also doesn't fix the issue we have with slow tree sitter parsing. Example min.js file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will probably remove that. I might put stuff that doesn't make sense because I am still testing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah that was an issue that I was finding, rust and markdown files were very slow

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for me though that actually made markdown files preview faster but still not fast

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also tried to make just ts highlighter async. Doesn't do anything because we are just attaching a highlighter which is already super fast and parsing happens not when attaching.

@Conni2461
Copy link
Member

I tried that PR again. It does absolutely nothing for me :|. Run on home dir

@oberblastmeister
Copy link
Contributor Author

What is not working for you? Is it the typing experience that is freezing or the fact that grepping on home dir will not open?

@Conni2461
Copy link
Member

Still freezing and i didn't notice any difference to current version. But i also didn't used a stopwatch just my feeling.
Also i was getting an previewer issue with 1004 is not a valid winid which is probably an issue with that async previewer

@tjdevries
Copy link
Member

I have a feeling this doesn't do what we think it does :) I'm very busy applying for jobs, but we can try some stuff later. Sorry for the delays :)

@tjdevries
Copy link
Member

done with new async await strat

@tjdevries tjdevries closed this Apr 9, 2021
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

Successfully merging this pull request may close these issues.

5 participants