From: John Keeping <john@keeping.me.uk>
To: Steffen Prohaska <prohaska@zib.de>
Cc: Junio C Hamano <gitster@pobox.com>,
git@vger.kernel.org, peff@peff.net, schacon@gmail.com
Subject: Re: [PATCH v2 2/2] convert: Stream from fd to required clean filter instead of mmap
Date: Sat, 16 Aug 2014 11:27:03 +0100 [thread overview]
Message-ID: <20140816102703.GD7857@serenity.lan> (raw)
In-Reply-To: <1407303134-16635-3-git-send-email-prohaska@zib.de>
On Wed, Aug 06, 2014 at 07:32:14AM +0200, Steffen Prohaska wrote:
[...]
> The expectation on the process size is tested using /usr/bin/time. An
> alternative would have been tcsh, which could be used to print memory
> information as follows:
>
> tcsh -c 'set time=(0 "%M"); <cmd>'
>
> Although the logic could perhaps be simplified with tcsh, I chose to use
> 'time' to avoid a dependency on tcsh.
[...]
> @@ -190,6 +196,58 @@ test_expect_success 'required filter clean failure' '
> test_must_fail git add test.fc
> '
>
> +# Handle differences in /usr/bin/time.
> +#
> +# - Linux: call with '-v'.
> +# output: <spaces><description>:<space><value-in-KBytes>
> +#
> +# - Mac: call with '-l'.
> +# output: <spaces><value-in-Bytes><spaces><description>
> +# Strip three digits to get to KB (base 10 is good enough).
> +#
> +case $(uname -s) in
> +Linux)
> + test_set_prereq HAVE_MAX_MEM_USAGE
> + max_mem_usage_KB () {
> + /usr/bin/time -v "$@" 2>&1 |
> + grep 'Maximum resident set size' |
> + cut -d ':' -f 2
> + }
> + ;;
> +Darwin)
> + test_set_prereq HAVE_MAX_MEM_USAGE
> + max_mem_usage_KB () {
> + /usr/bin/time -l "$@" 2>&1 |
> + grep 'maximum resident set size' |
> + sed -e 's/ */ /' |
> + cut -d ' ' -f 2 |
> + sed -e 's/...$//'
> + }
> + ;;
> +esac
> +
> +max_mem_usage_is_lt_KB () {
> + limit=$1
> + shift
> + mem_usage=$(max_mem_usage_KB "$@")
> + if [ $mem_usage -lt $limit ]; then
> + true
> + else
> + printf 'Command used too much memory (expected limit %dKB, actual usage %dKB).\n' \
> + $limit $mem_usage
> + false
> + fi
> +}
> +
> +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?
next prev parent reply other threads:[~2014-08-16 10:27 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-06 5:32 [PATCH v2 0/2] Stream fd to clean filter Steffen Prohaska
2014-08-06 5:32 ` [PATCH v2 1/2] convert: Refactor would_convert_to_git() to single arg 'path' Steffen Prohaska
2014-08-06 5:32 ` [PATCH v2 2/2] convert: Stream from fd to required clean filter instead of mmap Steffen Prohaska
2014-08-16 10:27 ` John Keeping [this message]
2014-08-16 16:26 ` Steffen Prohaska
2014-08-16 17:00 ` Andreas Schwab
2014-08-17 10:08 ` Steffen Prohaska
2014-08-17 11:03 ` Andreas Schwab
2014-08-17 7:27 ` Jeff King
2014-08-17 10:25 ` Steffen Prohaska
2014-08-17 11:33 ` Duy Nguyen
2014-08-19 7:53 ` Jeff King
2014-08-19 8:26 ` Steffen Prohaska
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140816102703.GD7857@serenity.lan \
--to=john@keeping.me.uk \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=peff@peff.net \
--cc=prohaska@zib.de \
--cc=schacon@gmail.com \
/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.
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 NNTP newsgroup(s).