Skip to content

refactor: prepare extension loading for parallelization#16314

Closed
Vivekgupta008 wants to merge 16 commits intogoogle-gemini:mainfrom
Vivekgupta008:main
Closed

refactor: prepare extension loading for parallelization#16314
Vivekgupta008 wants to merge 16 commits intogoogle-gemini:mainfrom
Vivekgupta008:main

Conversation

@Vivekgupta008
Copy link
Copy Markdown

@Vivekgupta008 Vivekgupta008 commented Jan 10, 2026

Refactor: Prepare Extension Loading for Parallelization

Refactors extension loading to separate state management concerns, preparing the codebase for parallel extension loading in a future PR. This is the first of four PRs to optimize Windows startup performance.

No behavior changes - extensions still load sequentially with the same error handling and ordering guarantees.

Changes Made

Modified loadExtension Method

Before:

  • Directly mutated this.loadedExtensions array
  • Called maybeStartExtension() internally
  • Mixed loading logic with state management

After:

  • Returns extension object without side effects
  • Caller responsible for state management
  • Clear separation of concerns

Modified loadExtensions() Method

For #14429

@Vivekgupta008 Vivekgupta008 requested a review from a team as a code owner January 10, 2026 12:39
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @Vivekgupta008, 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 refactors the extension loading mechanism by separating the concerns of loading an individual extension from managing the collection of loaded extensions and their lifecycle. This foundational change prepares the codebase for future parallelization of extension loading, which is part of a larger effort to improve Windows startup performance. Crucially, these modifications introduce no behavioral changes; extensions continue to load sequentially with existing error handling and ordering guarantees.

Highlights

  • Refactored loadExtension Method: The loadExtension method no longer directly mutates the this.loadedExtensions array or calls maybeStartExtension(). It now solely focuses on loading and returning the extension object, deferring state management to the caller.
  • Updated loadExtensions Method: The loadExtensions method now takes responsibility for adding successfully loaded extensions to this.loadedExtensions and initiating them via maybeStartExtension(), ensuring a clear separation of concerns.
  • Preparation for Parallelization: These changes are a foundational step to enable parallel extension loading in future pull requests, aiming to optimize Windows startup performance without altering current sequential behavior.
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
Copy Markdown
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 extension loading mechanism to separate state management from the loading logic, which is a good step towards enabling parallel extension loading. However, a high-severity Path Traversal vulnerability was identified in the loadExtensions function. The code does not validate subdirectory names read from the filesystem, allowing a maliciously crafted directory name to cause the application to load an "extension" from an unintended path, potentially leading to information disclosure or arbitrary code execution. Additionally, there's a high-severity suggestion in extension-manager.ts to improve performance and adhere to best practices by using asynchronous file I/O and more efficient array manipulation within the extension loading loop.

@gemini-cli gemini-cli bot added the status/need-issue Pull requests that need to have an associated issue. label Jan 10, 2026
@Vivekgupta008
Copy link
Copy Markdown
Author

Vivekgupta008 commented Jan 10, 2026

Parallelize Extension Loading for Faster Startup

This commit builds on the previous refactor and parallelizes extension loading to reduce startup time, with a particular benefit on Windows.

By switching from sequential loading to parallel I/O and async filesystem operations, extension loading is significantly faster while preserving existing behavior.

Expected impact: ~200ms faster startup on Windows (~4× speedup for extension loading).

Part of fixing issue #14429

@scidomino scidomino enabled auto-merge January 14, 2026 01:24
@scidomino
Copy link
Copy Markdown
Collaborator

@Vivekgupta008 looks like you have some flakey tests in src/config/extension.test.ts please fix

@gemini-cli gemini-cli bot added size/s A small PR review/involved PRs that may take a lot of work to review labels Jan 14, 2026
@gemini-cli gemini-cli bot added size/l A large sized PR and removed size/s A small PR labels Jan 14, 2026
@Vivekgupta008
Copy link
Copy Markdown
Author

@scidomino We're good to go now

@scidomino
Copy link
Copy Markdown
Collaborator

Don't update the branch unnecessarily. I have to approve the test runs each time and without passing tests it can't enter the merge queue.

@scidomino
Copy link
Copy Markdown
Collaborator

I see we have a bunch of test failures still. Ping me when you've fixed them and you can run npm run preflight without errors.

@bdmorgan
Copy link
Copy Markdown
Collaborator

Hi @Vivekgupta008, thank you so much for your contribution to Gemini CLI! We really appreciate the time and effort you've put into this.

We're making some updates to our contribution process to improve how we track and review changes. Please take a moment to review our recent discussion post: Improving Our Contribution Process & Introducing New Guidelines.

Key Update: Starting January 26, 2026, the Gemini CLI project will require all pull requests to be associated with an existing issue. Any pull requests not linked to an issue by that date will be automatically closed.

Thank you for your understanding and for being a part of our community!

@gemini-cli
Copy link
Copy Markdown
Contributor

gemini-cli bot commented Jan 24, 2026

Hi there! Thank you for your contribution to Gemini CLI.

To improve our contribution process and better track changes, we now require all pull requests to be associated with an existing issue, as announced in our recent discussion and as detailed in our CONTRIBUTING.md.

This pull request is being closed because it is not currently linked to an issue. You can easily reopen this PR once you have linked it to an issue.

How to link an issue:
Add a keyword followed by the issue number (e.g., Fixes #123) in the description of your pull request. For more details, see the GitHub Documentation.

Thank you for your understanding and for being a part of our community!

@gemini-cli gemini-cli bot closed this Jan 24, 2026
auto-merge was automatically disabled January 24, 2026 16:47

Pull request was closed

@Vivekgupta008
Copy link
Copy Markdown
Author

@ishaanxgupta Can you help me out here?

@scidomino scidomino reopened this Feb 24, 2026
@scidomino
Copy link
Copy Markdown
Collaborator

@Vivekgupta008 reopened. Please rebase to the latest version and fix your merge conflicts.

@scidomino scidomino closed this Feb 24, 2026
@scidomino
Copy link
Copy Markdown
Collaborator

Actually, nevermind. I will implement these changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review/involved PRs that may take a lot of work to review size/l A large sized PR status/need-issue Pull requests that need to have an associated issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants