Skip to content

Use RapidFuzz for server-side fuzzy search#5827

Closed
evnchn wants to merge 3 commits intozauberzeug:mainfrom
evnchn:server-side-search
Closed

Use RapidFuzz for server-side fuzzy search#5827
evnchn wants to merge 3 commits intozauberzeug:mainfrom
evnchn:server-side-search

Conversation

@evnchn
Copy link
Copy Markdown
Collaborator

@evnchn evnchn commented Feb 20, 2026

Motivation

Google SEO favors INP. The Core Web Vitals testing platform is opaque but it appears that CPU is slow, Network is slow.

https://pagespeed.web.dev/analysis/https-nicegui-io/li5rniz6jo?hl=en_GB&form_factor=mobile

Implementation

Can we move the search load to the server-side? Yes we can.

End effects:

  • Lighthouse mobile 67 -> 70
  • Saves 88kB downlink
  • Cuts 1 round-trip for data display

Considering that our mean latency across fly.io is 15ms circa (if Claude is to be trusted), and INP for desktop is 71ms, I think that 4x 15ms (up down up down) + 11ms (CPU) network time is the likely current status.

Then INP for desktop after this PR could hit 41ms, and by proportional scaling INP for mobile could hit 107ms which would be a huge win.

Progress

  • I chose a meaningful title that completes the sentence: "If applied, this PR will..."
  • The implementation is complete.
  • If this PR addresses a security issue, it has been coordinated via the security advisory process.
  • Pytests have been added (or are not necessary).
  • Documentation has been added (or is not necessary).

Final notes

IMO search results actually improved. There are people saying fuse.js isn't the best, and I guess I would agree based on our thing which we are searching through. Ref: https://www.reddit.com/r/nextjs/comments/10yxu92/what_is_your_go_to_clientside_fuzzy_searching/

Less shallow than #5824. Can be adopted together.

Are we ready for the additional CPU load which is needed to sustain the search?

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
@evnchn evnchn added the documentation Type/scope: Documentation, examples and website label Feb 20, 2026
@evnchn
Copy link
Copy Markdown
Collaborator Author

evnchn commented Feb 20, 2026

Btw each call to rapidfuzz takes 1ms, no need run.cpu_bound

@falkoschindler falkoschindler added this to the 3.10 milestone Feb 21, 2026
@falkoschindler falkoschindler added the review Status: PR is open and needs review label Feb 21, 2026
@evnchn
Copy link
Copy Markdown
Collaborator Author

evnchn commented Feb 22, 2026

Actually got one more commit at https://github.com/evnchn/nicegui/tree/expt/truncated-search-results which could further mimimize the time (reduce what is being sent, dodge ui.markdown which runs DOMPurify)

But not sure whether server-side fuzzy search is adopted in the end so I'm leaving it here for now.

@evnchn
Copy link
Copy Markdown
Collaborator Author

evnchn commented Mar 29, 2026

image

Well that's weird. For some reason the new NiceGUI website, though I seem to think it's more visual flare, is actually better in Core Web Vitals that ALL of our pages land in good territory?

Group INP for the worst (and biggest) group https://nicegui.io/documentation/XXX is now 187ms? I guess if it ain't broken don't fix it, so yeah this PR can be archived until our INP is bad again.

I'm still puzzled though 😵

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Type/scope: Documentation, examples and website review Status: PR is open and needs review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants