Skip to content

⚡ Bolt: Add pre-calculated search indexing for faster rendering#40

Open
MrAlokTech wants to merge 1 commit intomainfrom
bolt-search-index-optimization-6137551055321525041
Open

⚡ Bolt: Add pre-calculated search indexing for faster rendering#40
MrAlokTech wants to merge 1 commit intomainfrom
bolt-search-index-optimization-6137551055321525041

Conversation

@MrAlokTech
Copy link
Owner

⚡ Bolt: Add pre-calculated search indexing for faster rendering

💡 What: Added prepareSearchIndex to compute derived runtime fields (_searchStr, _formattedDate, _isNew) exactly once when the database loads. Removed repeated toLowerCase() and new Date() instantiation from the .filter loop and the createPDFCard function.

🎯 Why: Previously, searching required performing multiple .toLowerCase() string conversions and concatenations for every PDF item on every keystroke. Additionally, dates were being instantiated and formatted dynamically every time a card was rendered. This blocked the main thread and caused perceivable lag during typing on slower devices or large datasets.

📊 Impact: Reduces per-item processing cost from multi-step string manipulation to a single O(1) string inclusion check (includes()), improving filtering speeds significantly. Reduces DOM rendering overhead by accessing static pre-formatted strings rather than instantiating new Date objects per card.

🔬 Measurement: Verify by typing rapidly in the search bar and observing lower main-thread blocking time in Chrome DevTools Performance tab, leading to a smoother frame rate.


PR created automatically by Jules for task 6137551055321525041 started by @MrAlokTech

Implement `prepareSearchIndex` to pre-calculate lowercased search strings
and format upload dates exactly once during initial data load. This
eliminates the need to perform these computationally expensive operations
on the fly within the `renderPDFs` search filter loop and
`createPDFCard` component instantiation.

* 💡 What: Added `prepareSearchIndex` to pre-calculate derived fields.
* 🎯 Why: Recomputing `.toLowerCase()` strings and `new Date()` multiple times per keystroke blocks the main thread.
* 📊 Impact: O(1) attribute access vs O(N) string processing per item per keystroke.
* 🔬 Measurement: Observe lower CPU overhead via Chrome DevTools during rapid search typing.

Co-authored-by: MrAlokTech <107493955+MrAlokTech@users.noreply.github.com>
@google-labs-jules
Copy link
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@cloudflare-workers-and-pages
Copy link

Deploying classnotes with  Cloudflare Pages  Cloudflare Pages

Latest commit: 5d75a5b
Status: ✅  Deploy successful!
Preview URL: https://bcca2e40.classnotes.pages.dev
Branch Preview URL: https://bolt-search-index-optimizati.classnotes.pages.dev

View logs

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.

1 participant