Skip to content

Slow on Windows with lots of submodules #1701

@Vynce

Description

@Vynce

git status is substantially slower on Windows than on Linux. I'm working in a repo with ~240 submodules. By default, when you run git status in a repo with submodules, it'll recursively run git status in every submodule as well (sequentially). git diff behaves similarly to git status. Pre-commit appears to run git status once at the beginning (to check if anything needs to be stashed?) and then runs git diff before and after each hook (to detect any changes made by the hook?). These calls quickly add up and make pre-commit unusable in these large repos.

The bottlenecks can be seen clearly in this Process Monitor capture:

procmon_pre-commit

Running one hook takes ~35s in this case. Two hooks take ~54s.

If I add --ignore-submodules to this git status call and this git diff call, pre-commit only takes ~1.5s for one hook and ~1.9s for two hooks.

If I understand the use of git status and git diff in pre-commit correctly, it seems like it would be completely safe to ignore submodules in the git status call since submodules can't be stashed to restore later. The git diff case might be more risky because I guess hooks could modify submodules? Perhaps an "ignore submodules" setting could be added to pre-commit?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions