From: man dog <dogman888888@gmail.com>
To: git@vger.kernel.org
Subject: Bug report: git -L requires excessive memory.
Date: Sun, 30 Oct 2022 01:59:41 +0900 [thread overview]
Message-ID: <CAFOPqVXz2XwzX8vGU7wLuqb2ZuwTuOFAzBLRM_QPk+NJa=eC-g@mail.gmail.com> (raw)
Thank you for filling out a Git bug report!
Please answer the following questions to help us understand your issue.
What did you do before the bug happened? (Steps to reproduce your issue)
git log -L /regex/,/regex/:myfile to a repo in which 2MB text file is
committed about 2800 times.
What did you expect to happen? (Expected behavior)
get the result.
What happened instead? (Actual behavior)
fatal: Out of memory, malloc failed (tried to allocate 2346801 bytes)
What's different between what you expected and what actually happened?
The function requires too much memory.
-n option should work for -L function.
Anything else you want to add:
I made a script to reproduce this. Please run the script below.
Results in each environments are in its header.
A workaround which is given in other BBS is included also.
#!/bin/bash
#
# Bug report: git -L requires excessive memory.
# Run this script to reproduce
#
# MINGW32(git version 2.38.1.windows.1) fatal: Out of memory, malloc
failed (tried to allocate 2346801 bytes)
# MINGW64(git version 2.38.1.windows.1) requires 8.6GB
# Linux64(git version 2.20.1 ) requires 13.1GB
#
git --version
if [ ! -d .git ]; then
git init
c=${1:-3000}
for (( i=0;i<c;i++)); do
gawk -v r="$i" '
BEGIN{
for (i=0;i<100;i++) {
if (r>=i) {
printf("function func_%03d(){ // revised at %d\n",i,
int((r-i)/100)*100+i%100)
printf(" // contents of function\n")
printf("}\n")
make_subfuncs(i);
}
}
exit
}
function make_subfuncs(i, j){
for (j=0;j<300;j++) {
printf("function func_%03d_sub%03d(){\n",i,j)
printf(" // contents of sub functions are NOT revised.\n")
printf("}\n")
}
}' > test.txt
git add test.txt
git commit -m "revision $i"
done
git gc
fi
git log -L /func_007\(/,/}$/:test.txt # this command requires excessive memory.
git log -L /func_007\(/,/}$/:test.txt -n 10 # -n option doesn't work also.
#git log -L /func_007\(/,/}$/:test.txt HEAD~10..HEAD~0 # this works.
#
# This can be a workaround
#
step=50
num=`git log | grep -c commit`
for ((i=0;i<$num;i+=$step)); do
end=$((i+$step))
range=HEAD~$end..HEAD~$i
if [ $end -ge $num ]; then
range=HEAD~$i
fi
# echo $range
git --no-pager log -L /func_007\(/,/}$/:test.txt $range
done
[System Info]
[Enabled Hooks]
next reply other threads:[~2022-10-29 17:01 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-29 16:59 man dog [this message]
2022-10-31 21:45 ` Bug report: git -L requires excessive memory SZEDER Gábor
2022-10-31 21:56 ` Taylor Blau
2022-11-02 22:01 ` [PATCH 0/3] line-log: plug some memory leaks SZEDER Gábor
2022-11-02 22:01 ` [PATCH 1/3] line-log: free diff queue when processing non-merge commits SZEDER Gábor
2022-11-03 0:20 ` Taylor Blau
2022-11-07 15:11 ` SZEDER Gábor
2022-11-07 15:29 ` Ævar Arnfjörð Bjarmason
2022-11-07 15:57 ` SZEDER Gábor
2022-11-08 2:14 ` Taylor Blau
2022-11-02 22:01 ` [PATCH 2/3] line-log: free the diff queues' arrays when processing merge commits SZEDER Gábor
2022-11-03 0:21 ` Taylor Blau
2022-11-02 22:01 ` [PATCH 3/3] diff.c: use diff_free_queue() SZEDER Gábor
2022-11-03 0:24 ` Taylor Blau
2022-11-07 16:13 ` SZEDER Gábor
2022-11-08 2:14 ` Taylor Blau
2022-11-03 9:05 ` [PATCH 0/3] line-log: plug some memory leaks Ævar Arnfjörð Bjarmason
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='CAFOPqVXz2XwzX8vGU7wLuqb2ZuwTuOFAzBLRM_QPk+NJa=eC-g@mail.gmail.com' \
--to=dogman888888@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).