timc1 / kbar

fast, portable, and extensible cmd+k interface for your site
https://kbar.vercel.app
MIT License
4.84k stars 185 forks source link

Search gets stuck after 6-7 characters for a big pool of results #231

Closed codingfrenzyyyy closed 2 years ago

codingfrenzyyyy commented 2 years ago

Hi, i am searching through a pool of 4000-5000 search set. After typing 6-7 characters, the search gets stucky and sometimes hangs the web app. It only happens when the search set are big.

Kindly assist, thanks.

timc1 commented 2 years ago

How are you setting up those 4000-5000 (presumably) actions? You should be able to search through 4-5k actions without any performance hit

codingfrenzyyyy commented 2 years ago

Our implementation is similar to the example you have given, where we use useRegisterActions to dynamically pull the search set once, and calls useMatches() hook to return and render the searched results.

Yes as mentioned, there are no performance hit when we are typing 5-6 characters in KBarSearch component. However weirdly upon more characters entered, it hangs or lags. It is a prominent issue when we hold down a keyboard key (eg. we hold down 'c' character key in KBarSearch input, when the search set is 4000-5000 actions).

This issue is not observed with smaller search sets.

I wonder could it be due to the way getDeepResults or collectChildren are written?

codingfrenzyyyy commented 2 years ago

Each action has 4-5 keywords. Does it contribute to the performance of typing in search input?

codingfrenzyyyy commented 2 years ago

hi, the issue has been fixed by removing some of the longer keywords in around 40-50 search set.

Thanks for the support, but I would also like to take the chance to feedback that the performance is impacted when the keywords provided is too long.

Would be nice if the keyword matching algorithm can be optimized further.

Thanks!