t / perf / p5550-fetch-tags.shon commit Merge branch 'svn-escape-backslash' of git://bogomips.org/git-svn (80ba04e)
   1#!/bin/sh
   2
   3test_description='performance of tag-following with many tags
   4
   5This tests a fairly pathological case, so rather than rely on a real-world
   6case, we will construct our own repository. The situation is roughly as
   7follows.
   8
   9The parent repository has a large number of tags which are disconnected from
  10the rest of history. That makes them candidates for tag-following, but we never
  11actually grab them (and thus they will impact each subsequent fetch).
  12
  13The child repository is a clone of parent, without the tags, and is at least
  14one commit behind the parent (meaning that we will fetch one object and then
  15examine the tags to see if they need followed). Furthermore, it has a large
  16number of packs.
  17
  18The exact values of "large" here are somewhat arbitrary; I picked values that
  19start to show a noticeable performance problem on my machine, but without
  20taking too long to set up and run the tests.
  21'
  22. ./perf-lib.sh
  23
  24# make a long nonsense history on branch $1, consisting of $2 commits, each
  25# with a unique file pointing to the blob at $2.
  26create_history () {
  27        perl -le '
  28                my ($branch, $n, $blob) = @ARGV;
  29                for (1..$n) {
  30                        print "commit refs/heads/$branch";
  31                        print "committer nobody <nobody@example.com> now";
  32                        print "data 4";
  33                        print "foo";
  34                        print "M 100644 $blob $_";
  35                }
  36        ' "$@" |
  37        git fast-import --date-format=now
  38}
  39
  40# make a series of tags, one per commit in the revision range given by $@
  41create_tags () {
  42        git rev-list "$@" |
  43        perl -lne 'print "create refs/tags/$. $_"' |
  44        git update-ref --stdin
  45}
  46
  47# create $1 nonsense packs, each with a single blob
  48create_packs () {
  49        perl -le '
  50                my ($n) = @ARGV;
  51                for (1..$n) {
  52                        print "blob";
  53                        print "data <<EOF";
  54                        print "$_";
  55                        print "EOF";
  56                }
  57        ' "$@" |
  58        git fast-import &&
  59
  60        git cat-file --batch-all-objects --batch-check='%(objectname)' |
  61        while read sha1
  62        do
  63                echo $sha1 | git pack-objects .git/objects/pack/pack
  64        done
  65}
  66
  67test_expect_success 'create parent and child' '
  68        git init parent &&
  69        git -C parent commit --allow-empty -m base &&
  70        git clone parent child &&
  71        git -C parent commit --allow-empty -m trigger-fetch
  72'
  73
  74test_expect_success 'populate parent tags' '
  75        (
  76                cd parent &&
  77                blob=$(echo content | git hash-object -w --stdin) &&
  78                create_history cruft 3000 $blob &&
  79                create_tags cruft &&
  80                git branch -D cruft
  81        )
  82'
  83
  84test_expect_success 'create child packs' '
  85        (
  86                cd child &&
  87                git config gc.auto 0 &&
  88                git config gc.autopacklimit 0 &&
  89                create_packs 500
  90        )
  91'
  92
  93test_perf 'fetch' '
  94        # make sure there is something to fetch on each iteration
  95        git -C child update-ref -d refs/remotes/origin/master &&
  96        git -C child fetch
  97'
  98
  99test_done