Skip to content

⚡ Optimize get_installed_mod_ids performance#17

Open
tstapler wants to merge 1 commit intomasterfrom
performance-optimize-mod-id-retrieval-17521740914088185828
Open

⚡ Optimize get_installed_mod_ids performance#17
tstapler wants to merge 1 commit intomasterfrom
performance-optimize-mod-id-retrieval-17521740914088185828

Conversation

@tstapler
Copy link
Owner

The get_installed_mod_ids function was optimized by replacing a loop-based list construction and subsequent set conversion with a set comprehension using the walrus operator (:=). Additionally, the regular expression used for matching mod IDs was pre-compiled at the module level to avoid redundant compilation. These changes were applied to both main.py and manage_mods.py.

Performance Impact:

  • Baseline: 6.06s for 2000 iterations over 2000 items (1000 matches).
  • Optimized: 3.83s for 2000 iterations.
  • Improvement: ~37% faster.

Functionality was verified with existing and new tests. A minor bug in test_manage_mods.py's test_tag_mod was also fixed to match the actual implementation's data structure.


PR created automatically by Jules for task 17521740914088185828 started by @tstapler

…led regex

- Pre-compiled RE_MOD_ID regex at the module level in main.py and manage_mods.py.
- Refactored get_installed_mod_ids to use a set comprehension with the walrus operator, reducing redundant matching and avoiding intermediate list construction.
- Updated scan_local_mods to use the pre-compiled regex for consistency.
- Fixed a pre-existing test expectation in test_manage_mods.py.
- Performance improvement: ~37% faster in benchmarks.

Co-authored-by: tstapler <3860386+tstapler@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.

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