From: Dian Xu <dianxudev@gmail.com>
To: git@vger.kernel.org
Subject: git bug report: 'git add' hangs in a large repo which has sparse-checkout file with large number of patterns in it
Date: Wed, 29 Jun 2022 15:11:31 -0400 [thread overview]
Message-ID: <CAKSRnEzMaQEv=3mkNWRpy6+-c0rz=R191iqheCQ2ptXFs1CQgw@mail.gmail.com> (raw)
Dear Git developers,
Reporting Issue:
'git add' hangs in a large repo which has
sparse-checkout file with large number of patterns in it
Found in:
Git 2.34.3. Issue occurs after 'audit for interaction
with sparse-index' was introduced in add.c
Reproduction steps:
1. Clone a repo which has e.g. 2 million plus files
2. Enable sparse checkout by: git config core.sparsecheckout true
3. Create a .git/info/sparse-checkout file with a large
number of patterns, e.g. 16k plus lines
4. Run 'git add', which will hang
Investigations:
1. Stack trace:
add.c: cmd_add
-> add.c: prune_directory
-> pathspec.c: add_pathspec_matches_against_index
-> dir.c: path_in_sparse_checkout_1
2. In Git 2.33.3, the loop at pathspec.c line 42 runs
fast, even when istate->cache_nr is at 2 million
3. Since Git 2.34.3, the newly introduced 'audit for
interaction with sparse-index' (dir.c line 1459:
path_in_sparse_checkout_1) decides to loop through 2 million files and
match each one of them against the sparse-checkout patterns
4. This hits the O(n^2) problem thus causes 'git add' to
hang (or ~1.5 hours to finish)
Please help us take a look at this issue and let us know if you need
more information.
Thanks,
Dian Xu
Mathworks, Inc
1 Lakeside Campus Drive, Natick, MA 01760
508-647-3583
next reply other threads:[~2022-06-29 19:11 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-29 19:11 Dian Xu [this message]
2022-06-29 21:53 ` git bug report: 'git add' hangs in a large repo which has sparse-checkout file with large number of patterns in it Victoria Dye
2022-06-30 4:06 ` Elijah Newren
2022-06-30 5:06 ` Victoria Dye
2022-07-01 3:42 ` Elijah Newren
2022-07-01 20:24 ` Dian Xu
2022-07-01 21:52 ` Elijah Newren
2022-07-04 19:11 ` Konstantin Ryabitsev
2022-07-05 13:08 ` Dian Xu
2022-07-08 1:53 ` Elijah Newren
2022-07-12 13:00 ` Dian Xu
2022-06-30 3:10 ` Elijah Newren
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAKSRnEzMaQEv=3mkNWRpy6+-c0rz=R191iqheCQ2ptXFs1CQgw@mail.gmail.com' \
--to=dianxudev@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).