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

Faster searching with Fuse.js #38

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

jthemphill
Copy link

Unlike match-sorter, Fuse.js creates an index which is cached in between renders. This drastically cuts down on the time spent writing queries. We can also debounce so we don't overload the CPU while the user is typing.

These videos are taken with the CPU throttled to 25% capacity!

Before:

prod.mov

After:

dev.mov

@tchajed
Copy link
Owner

tchajed commented Jan 21, 2025

What's blocking this? Does it rely on the vite build, or something else broken about the build?

@jthemphill
Copy link
Author

jthemphill commented Jan 21, 2025

What's blocking this? Does it rely on the vite build, or something else broken about the build?

It doesn't rely on the vite build. It works as-is, though page loads are slower. To fix that, we need to either cache the indices in localstorage or build the indices on the server during fetch-assets.

I've tried to create the character search index during fetch-assets on the server, but every attempt to do so winds up being more invasive than this PR should probably be. It looks like we'd either need to restructure the character search logic, or copy/paste all the character search logic, to do so. The project doesn't seem to be set up to share code between the frontend and backend right now.

I personally kind of want to remove the character search. It seems extremely niche to me, because we don't execute a character search unless we generate a search query that produces fewer than 10 title-based matches. And this isn't documented anywhere. I think this might have made sense when there were fewer scripts, and when fewer of the scripts had the names of characters in their titles.

Of course, character search would be a lot more useful if we make it more accessible in the UI, via a separate tab or explicit option, so that a user can explicitly choose to run a search by character.

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.

Improve script search performance
3 participants