Skip to content

⚡ Bolt: Optimize routing engine by caching module search text#5

Open
badMade wants to merge 2 commits into
mainfrom
bolt-optimize-routing-engine-9159762776880596355
Open

⚡ Bolt: Optimize routing engine by caching module search text#5
badMade wants to merge 2 commits into
mainfrom
bolt-optimize-routing-engine-9159762776880596355

Conversation

@badMade
Copy link
Copy Markdown
Owner

@badMade badMade commented Apr 11, 2026

💡 What: Added a @functools.cached_property named search_text to the PortingModule dataclass, combining its lowercased fields into a single search string. Updated the _score method in src/runtime.py to use this single precomputed string.
🎯 Why: The previous implementation created a list of three lowercased strings repeatedly inside an inner loop over tokens for every module evaluated, causing unnecessary overhead from repeated string allocations and .lower() calls.
📊 Impact: Considerably faster matching loop during routing by shifting string manipulations to initial property access only and using a simple token in haystack lookup for the evaluation.
🔬 Measurement: Verify correctness by running PYTHONPATH=. python3 -m pytest tests/ and verify style with ruff check ..


PR created automatically by Jules for task 9159762776880596355 started by @badMade

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

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces performance optimizations to the Python routing engine by caching lowercased searchable fields within the PortingModule class to reduce string allocation overhead during scoring. The review feedback identifies a potential runtime error when using cached_property on frozen dataclasses and suggests using post_init with object.setattr as an alternative, which would also allow for the removal of the now-unnecessary functools import.

Comment thread src/models.py Outdated
Comment thread src/models.py
@badMade
Copy link
Copy Markdown
Owner Author

badMade commented Apr 22, 2026

@copilot code review

@badMade
Copy link
Copy Markdown
Owner Author

badMade commented Apr 22, 2026

@claude code review

Copy link
Copy Markdown

Copilot AI commented Apr 22, 2026

@copilot code review

Reviewed the optimization commit and re-ran the available targeted validation; no additional code changes were needed. The current implementation in 21fb75b is still good to ship.

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 Python routing engine’s module matching by precomputing a single searchable string per PortingModule and using it in the scoring loop, reducing repeated string allocations/lowercasing during routing.

Changes:

  • Added PortingModule.search_text as a cached, lowercased concatenation of searchable fields.
  • Updated PortRuntime._score() to use module.search_text with a single token in haystack check.
  • Added a .jules/bolt.md note documenting the performance learning/action.

Reviewed changes

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

File Description
src/runtime.py Uses precomputed module search text in _score() to reduce per-route overhead.
src/models.py Introduces PortingModule.search_text for caching/normalizing searchable fields.
.jules/bolt.md Documents the performance rationale and intended optimization.

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

Comment thread .jules/bolt.md
Comment thread src/models.py Outdated
@badMade
Copy link
Copy Markdown
Owner Author

badMade commented Apr 23, 2026

@codex Code Review

1 similar comment
@badMade
Copy link
Copy Markdown
Owner Author

badMade commented Apr 23, 2026

@codex Code Review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Nice work!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@badMade
Copy link
Copy Markdown
Owner Author

badMade commented Apr 23, 2026

@codex code review

@badMade
Copy link
Copy Markdown
Owner Author

badMade commented Apr 23, 2026

@copilot, resolve the merge conflicts in this pull request.

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Co-authored-by: badMade <106821302+badMade@users.noreply.github.com>
Copy link
Copy Markdown

Copilot AI commented Apr 23, 2026

@copilot, resolve the merge conflicts in this pull request.

Resolved and pushed the merge conflicts in commit 6744239. The branch now cleanly merges with main.

@badMade
Copy link
Copy Markdown
Owner Author

badMade commented Apr 30, 2026

@copilot, make changes based on:

Codex Review: Didn't find any major issues. Nice work!

ℹ️ About Codex in GitHub
[Your team has set up Codex to review pull requests in this rep...

See: #5 (comment)

Copy link
Copy Markdown

Copilot AI commented Apr 30, 2026

@copilot, make changes based on:

Codex Review: Didn't find any major issues. Nice work!

ℹ️ About Codex in GitHub
[Your team has set up Codex to review pull r...

No additional code changes were needed from that review feedback. The branch remains in the resolved state at 6744239.

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.

3 participants