git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 2/2] convert: Stream from fd to required clean filter instead of mmap

From
Steffen Prohaska <prohaska@zib.de>
Date
Aug 16, 2014, 16:26 UTC
Message-ID
<FA3F1197-25C5-42E4-9418-1C821D430819@zib.de>
In-Reply-To
<20140816102703.GD7857@serenity.lan>
On Aug 16, 2014, at 12:27 PM, John Keeping <john@keeping.me.uk> wrote:
Show 31 quoted lines
>> +test_expect_success HAVE_MAX_MEM_USAGE \
>> +'filtering large input to small output should use little memory' '
>> +	git config filter.devnull.clean "cat >/dev/null" &&
>> +	git config filter.devnull.required true &&
>> +	for i in $(test_seq 1 30); do printf "%1048576d" 1; done >30MB &&
>> +	echo "30MB filter=devnull" >.gitattributes &&
>> +	max_mem_usage_is_lt_KB 15000 git add 30MB
>> +'
> 
> This test fails for me:
> 
> -- 8< --
> expecting success: 
>        git config filter.devnull.clean "cat >/dev/null" &&
>        git config filter.devnull.required true &&
>        for i in $(test_seq 1 30); do printf "%1048576d" 1; done >30MB &&
>        echo "30MB filter=devnull" >.gitattributes &&
>        max_mem_usage_is_lt_KB 15000 git add 30MB
> 
> Command used too much memory (expected limit 15000KB, actual usage 15808KB).
> not ok 8 - filtering large input to small output should use little memory
> -- >8 --
> 
> This is on Linux 3.16 x86_64 with GCC 4.8.3 and glibc 2.19.  My GCC also
> has "-fstack-protector" and "-D_FORTIFY_SOURCE=2" enabled by default;
> turning those off for Git decreased the memory usage by about 500KB but
> not enough to make the test pass.  Of course, all of the libraries Git
> is linking are also compiled with those flags...
> 
> Is the 15MB limit supposed to be imposed somewhere or is it just a guide
> of how much memory we expect Git to use in this scenario?
The test should confirm that the the file that is added is not mmapped to memory.  The process size should be relatively small independently of the size of the file that is added.  I wanted to keep the file size small.  The chosen sizes worked for me on Mac and Linux.
A simple solution could be to increase the size of the test file and the limit.  I'd suggest to squash the diff below.  The test should still run reasonably fast with a 50 MB test file.
Junio, shall I send a whole updated patch series?
	Steffen
diff --git a/t/t0021-conversion.sh b/t/t0021-conversion.sh
index 2cb2414..43de87d 100755
--- a/t/t0021-conversion.sh
+++ b/t/t0021-conversion.sh
@@ -243,9 +243,9 @@ test_expect_success HAVE_MAX_MEM_USAGE \
 'filtering large input to small output should use little memory' '
        git config filter.devnull.clean "cat >/dev/null" &&
        git config filter.devnull.required true &&
-       for i in $(test_seq 1 30); do printf "%1048576d" 1; done >30MB &&
-       echo "30MB filter=devnull" >.gitattributes &&
-       max_mem_usage_is_lt_KB 15000 git add 30MB
+       for i in $(test_seq 1 50); do printf "%1048576d" 1; done >50MB &&
+       echo "50MB filter=devnull" >.gitattributes &&
+       max_mem_usage_is_lt_KB 35000 git add 50MB
 '
Previous: John KeepingNext: Andreas Schwab
Message 5 of 13 in “Stream fd to clean filter”
  1. 0/2 Stream fd to clean filterSteffen Prohaska, Aug 6, 2014
  2. 1/2 convert: Refactor would_convert_to_git() to single arg 'path'Steffen Prohaska, Aug 6, 2014
  3. 2/2 convert: Stream from fd to required clean filter instead of mmapSteffen Prohaska, Aug 6, 2014
  4. John KeepingAug 16, 2014
  5. Steffen ProhaskaAug 16, 2014
  6. Andreas SchwabAug 16, 2014
  7. Steffen ProhaskaAug 17, 2014
  8. Andreas SchwabAug 17, 2014
  9. Jeff KingAug 17, 2014
  10. Steffen ProhaskaAug 17, 2014
  11. Duy NguyenAug 17, 2014
  12. Jeff KingAug 19, 2014
  13. Steffen ProhaskaAug 19, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.