Skip to content

[flutter_plugin_tools] Investigate and reduce overhead of execution in pre-commit hook #188870

Open

Description

@camsim99

While implementing a pre-commit git hook in PR #11941, we observed a significant overhead (approximately 5 seconds) when invoking the analyze and format commands provided by flutter_plugin_tools; see comment for details. To mitigate this for the common case of committing non-package changes, we implemented an optimization in the hook to skip the tool execution if no staged package changes are detected. However, this overhead still affects commits that do contain package changes, making the git commit experience sluggish.

We should investigate why invoking the tool introduces this latency (maybe Dart VM startup, package resolution, or something else) and how to reduce it. Ideally, we could then remove the optimization from the pre-commit hook.

Activity

  1. added
    packageflutter/packages repository. See also p: labels.
    team-androidOwned by Android platform team
    on Jul 1, 2026
  2. stuartmorgan-g commented on Jul 1, 2026

    @stuartmorgan-g
    Contributor

    Were you running whole-repo format? That's a pretty expensive command because it has to run the Dart formatter package by package, and also has to spin up all the native formatters (which includes a JVM twice).

  3. camsim99 commented on Jul 1, 2026

    @camsim99
    ContributorAuthor

    I added a flag in the PR to only run on packages with staged changes and I also added an optimization for format to only set up the native formatters if native files were changed, so the slowdown is coming from elsewhere I believe.

  4. added
    P2Important issues not at the top of the work list
    triaged-androidTriaged by Android platform team
    on Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listpackageflutter/packages repository. See also p: labels.team-androidOwned by Android platform teamtriaged-androidTriaged by Android platform team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions