Skip to content

⚡ Bolt: Extract typeScores from search loops to prevent memory allocation#32

Open
dttdrv wants to merge 1 commit intomasterfrom
jules-1294132155847344070-96f4eb1a
Open

⚡ Bolt: Extract typeScores from search loops to prevent memory allocation#32
dttdrv wants to merge 1 commit intomasterfrom
jules-1294132155847344070-96f4eb1a

Conversation

@dttdrv
Copy link
Copy Markdown
Owner

@dttdrv dttdrv commented Mar 11, 2026

💡 What: Extracted the typeScores configuration object from the search and fuzzySearch loop execution paths in src/utils/searchEngine.ts to a module-level constant TYPE_SCORES. Also changed let declarations for maps and sets to const.
🎯 Why: The search engine functions were unnecessarily re-allocating the same static typeScores mapping object in memory for every iteration of a user's search query, causing garbage collection overhead.
📊 Impact: Reduces memory allocation and garbage collection pressure during high-frequency fuzzy searches, leading to faster execution and more stable framerates for the user.
🔬 Measurement: Profile the application during typing in the search bar. Observe a reduction in object allocations inside the search and fuzzySearch execution paths.


PR created automatically by Jules for task 1294132155847344070 started by @dttdrv

@google-labs-jules
Copy link
Copy Markdown

👋 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.

Copilot AI review requested due to automatic review settings March 11, 2026 06:25
@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying schoolmap with  Cloudflare Pages  Cloudflare Pages

Latest commit: 5cd5127
Status: ✅  Deploy successful!
Preview URL: https://30dd6059.schoolmap.pages.dev
Branch Preview URL: https://jules-1294132155847344070-96.schoolmap.pages.dev

View logs

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Optimizes the search engine’s hot paths by hoisting a static type-priority map out of per-result loops, reducing repeated allocations during frequent search/fuzzySearch calls.

Changes:

  • Moved type ranking weights into a module-level TYPE_SCORES constant used by both search and fuzzySearch.
  • Converted module-scope Map/Set bindings to const where they are not reassigned.
  • Improved a bbox-loading warning log by including the caught error.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/utils/searchEngine.ts Reduces allocation pressure in search scoring and tightens module-scope immutability.
.jules/bolt.md Records the optimization learning/action for future reference.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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