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

Reduce debounce to make search about 2x faster #2407

Closed
wants to merge 2 commits into from

Conversation

LilithHafner
Copy link
Contributor

On docs.julialang.com, the time between pressing typing the final character of the search query and seeing search results is about 457ms (N=1). 300ms of that is waiting for the debounce to decide the user is done typing and start the search process. After this PR, the total delay drops to 249ms (N=1). I measured delay by taking a slow motion video of my fingers on the keyboard and the display on the screen so this is an "all inclusive" timing. On docs.julialang.org this speeds up searches by 1.8x, and on smaller search domains (e.g. most packages) the speedup may be a bit larger, approaching 3x.

This should not result in overwhelming the browser on fast typing. Faster than 10 chars/s will simply wait for the final character and then 100 more ms. Slower than 10 chars/s the search should be able to handle.

It is possible to do much more intelligent/clever debouncing that, for example, dynamically adjusts the debouncing delay based on observed typing speed and observed search runtime. That seems like an interesting project to pursue, but for now, this PR is quite simple and gives substantial performance gains.

I also switched keyup to keydown to shave a few extra milliseconds off the latency. Once a user presses a key down in the search bar, they are committed to performing a search for the new term, so we might as well start the clock a bit earlier.

@LilithHafner LilithHafner changed the title Make search about 2x faster Reduce debounce to make search about 2x faster Jan 20, 2024
@mortenpi
Copy link
Member

mortenpi commented Feb 5, 2024

Superseded by #2415.

@mortenpi mortenpi closed this Feb 5, 2024
@LilithHafner LilithHafner deleted the patch-1 branch February 5, 2024 19:24
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.

2 participants