nvim-cmp icon indicating copy to clipboard operation
nvim-cmp copied to clipboard

perf: improve for source providing huge list of items

Open yioneko opened this issue 1 year ago • 19 comments

Problem

nvim-cmp is still not ideally responsive when dealing with huge list of completion items, especially with tailwindcss which sends thousands of candidates on each completion response: #1009 #1828 #1949. Though some improvements have been done before but cmp is still apparently slower than other completion engine like vscode and coc.nvim in extreme cases.

Attempt to improve

This PR extracts two commits from my experimental perf branch fork which I think could be better upstreamed. The details and rationales are explained in commit descriptions.

The commits introduce massive changes to the codebase, and I'm not sure if you'd like to accept them. Since the changes are made just for improving performance in extreme cases, it's totally fine for me if you consider that it is not worth it.

Comparison

Recorded at https://github.com/hrsh7th/nvim-cmp/commit/a110e12d0b58eefcf5b771f533fc2cf3050680ac: cmp2

PR: cmp1

yioneko avatar Jul 09 '24 13:07 yioneko

Good jobs. This plugin is still very useful. Unfortunately, the author doesn't seem to have much time to maintain this plugin.

epheien avatar Jul 09 '24 14:07 epheien

@hrsh7th please let's get this performance boost in asap

idelice avatar Aug 04 '24 09:08 idelice

But it seems draft state. It is ready to merge?

Shougo avatar Aug 04 '24 10:08 Shougo

I tested this by forking @yioneko and there is a huge difference in the autocompletion. Everything works like the same - just better.

I also tested it by forking the original nvim-cmp and copying this PR changes over, and things seems to break. Could be because it's few commits behind which are kinda deal-breaking!

idelice avatar Aug 04 '24 10:08 idelice

@idelice Could you expand on what is breaking? I just rebased the branch onto the main locally and it seems to work fine as before. I've been using this for about one month personally without issues and I think this is generally ready for review if no more problems found.

yioneko avatar Aug 04 '24 12:08 yioneko

@idelice Could you expand on what is breaking? I just rebased the branch onto the main locally and it seems to work fine as before. I've been using this for about one month personally without issues and I think this is generally ready for review if no more problems found.

I don't know. I'm not familiar with lua enough to pinpoint what caused my user-testing to fail

idelice avatar Aug 04 '24 12:08 idelice

Hm... I think more testers are needed.

Shougo avatar Aug 04 '24 14:08 Shougo

Works well so far 😄

xzbdmw avatar Aug 05 '24 03:08 xzbdmw

It works fine for me, no issues. I'll be using this fork for now, @yioneko thanks for the improvement!

lopi-py avatar Aug 26 '24 00:08 lopi-py

This is awesome, but why is it still draft? @yioneko you feel like its not ready yet?

tronikelis avatar Aug 27 '24 15:08 tronikelis

I think this is generally ready for review. It might do not matter whether the PR status is draft or open as it seems that it would take a while to receive response from the owner, so I'll just change it to indicate that the branch here is open to user testing.

About the CI failing: https://github.com/leafo/gh-actions-lua/issues/49 and it passed before the rebase and all the tests are passed on my local environment.

yioneko avatar Aug 28 '24 09:08 yioneko

Hopefully this will be merged, can't wait to test it.

pidgeon777 avatar Aug 31 '24 15:08 pidgeon777

Tested with cmp-dictionary, and with 1000 items this branch is 6x faster, 300ms vs 2s 🚀

xzbdmw avatar Sep 02 '24 05:09 xzbdmw

I know I could use this PR personally but I still desire it gets merged and I believe it must benefit every user. Apologize sincerely for the ping @hrsh7th .

rockyzhang24 avatar Sep 02 '24 05:09 rockyzhang24

I tested the PR and I also noticed a big improvement in performance.

pidgeon777 avatar Sep 02 '24 11:09 pidgeon777

I tested this PR and noticed a significant improvement in performance. I haven't encountered any bugs. (yet?)

EuCaue avatar Sep 18 '24 11:09 EuCaue

Hello! I would like to kindly ask if there is any news about the testing outcome

pidgeon777 avatar Oct 01 '24 10:10 pidgeon777

Sorry for the late reply. I'll do review.

hrsh7th avatar Oct 09 '24 03:10 hrsh7th

My last review subject is entry.lua, which is a bit complicated. It will take some time.

hrsh7th avatar Oct 17 '24 09:10 hrsh7th