Skip to content

Conversation

@thejcannon
Copy link
Contributor

This change internally splits modules mapping generation to be per-wheel, with a final quick "merge" action at the end.

The idea is to make this process both concurrent and cached (courtesy of Bazel), which can be ideal for codebases with a large set of requirements (as many monorepos end up doing)

Note that the generator.py interface changed. This seemed internal, so I didn't mark it breaking (but this change could actually just leave the generator alone, since the current implementation is fine with 1 wheel).

I ran this on the work repo and saw no change in output (but as I edited a single requirement, the overall process was fast ⚡ )

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @thejcannon, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a significant refactoring to how Gazelle generates its modules mapping. The core change involves splitting the mapping generation into a per-wheel process, where each Python wheel is processed independently to create its own module map. These individual maps are then consolidated by a new merging utility. This approach is intended to enhance build performance by taking advantage of Bazel's inherent concurrency and caching mechanisms, which is particularly beneficial for projects with extensive dependency trees.

Highlights

  • Refactored Module Mapping Generation: The process for generating Gazelle's modules mapping has been refactored to process each Python wheel individually, rather than all wheels at once. This change is designed to leverage Bazel's caching and concurrency capabilities.
  • New Merger Component: A new Python script, merger.py, and its corresponding Bazel rule have been introduced. This component is responsible for combining the individual modules mapping JSON files generated for each wheel into a single, final modules mapping.
  • Generator Interface Update: The generator.py script has been updated to accept a single wheel as input, aligning with the new per-wheel processing strategy. Its argument parsing was also simplified by removing the @ prefix for parameter files.
  • Improved Performance Potential: This architectural change aims to significantly improve the performance of modules mapping generation in large monorepos by enabling more efficient caching and concurrent execution of tasks within Bazel.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@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 refactors the module mapping generation to be per-wheel, which is a great improvement for performance and caching in large projects. The approach of generating intermediate files for each wheel and then merging them is sound and well-implemented in Bazel. The new merger.py script is clean and efficient.

I have a couple of suggestions to improve the code further. One is to make the new test for the merger more robust by using a better pattern for temporary files. The other is a minor suggestion to improve the naming of the intermediate files for better readability and debugging.

Overall, this is a solid refactoring that leverages Bazel's strengths effectively.

Copy link
Collaborator

@dougthor42 dougthor42 left a comment

Choose a reason for hiding this comment

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

Nice! This looks like a great speed increase.

@dougthor42 dougthor42 added this pull request to the merge queue Nov 18, 2025
Merged via the queue into bazel-contrib:main with commit da23db5 Nov 18, 2025
4 checks passed
@thejcannon thejcannon deleted the jcannon/split-the-gen branch November 18, 2025 11:37
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