Skip to content
Snippets Groups Projects
before-check.sh 2.98 KiB
Newer Older
#!/bin/bash
#
# Script used to check that the machine is ready for running benchmarks. This
# script assumes that the asv command is in the current PATH


# Ensure asv now machine characteristics
asv machine --yes

echo
echo "check that system is ready for benchmark"
echo "(use ASV_SKIP_SYSTEM_CHECK=1 to skip it)"

if [ -z "${ASV_SKIP_SYSTEM_CHECK:-}" ]; then
    # Check that the machine is ready for benchmark
    python -m pyperf system show
fi

# Ensure all repository are here

echo "Ensuring we have a mercurial clone handy"
if [ ! -d mercurial ]; then
    echo "  no Mercurial clone found, making a fresh clone"
    hg clone https://www.mercurial-scm.org/repo/hg mercurial --config format.sparse-revlog=no --config format.usegeneraldelta=no --config experimental.evolution.exchange=no
if [ "$SCMPERF_WARMCACHE" != "skip" ] ; then
    echo "preparing cache warming"
    # get to the highest revision for future cache warming
    if [ -n "$TESTTMP" ]; then
        # do a lesser, quicker and quieter version of the setup for tests
        (cd mercurial;
         unset HGWITHRUSTEXT;
         make clean --silent > /dev/null 2>&1;
         make local --silent "PURE=--pure --quiet" > /dev/null 2>&1;);
    else
        hg -R mercurial update --clean -r "max(branch(default))"
        (cd mercurial; make local );
    fi
fi

repofiles="./default.repos"
if [ -e "./local.repos" ]; then
    repofiles="./local.repos"
fi

echo "Setting up all target repositories (from $repofiles)"
./script/setup-repos $repofiles ./repos
echo "Creating the skip file"
python ./create_skip_file.py

# We prewarm all caches with the latest know mercurial changeset.
#
# This avoid the `hg debugupdatecache` run happening within the benchmark to
# take too long, leading to benchmark failing from timing out.
#
# However, this is not ideal because more agressive cache warming usually led
# to performance gain. So running caching warming from "later version" can
# artificially speed up timing from "later version".
#
# This is a trade-off. Having a risk of sightly too fast timing in some case
# seems a lesser evil than having many benchmark failing from timeout. The
# status without this pre-warming was not great either because the version used
# for the last cache warming was not controled either.
#
# The main concrete issue with this approach is that even on warm cache `hg
# debugupdatecache` can take some time multiple seconds. given the large number
# of repositories used in scm-perf. This can adds up to a couple of minutes.

if [ "$SCMPERF_WARMCACHE" != "skip" ] ; then
    echo "Warming caches for all repos"
    echo "(use SCMPERF_WARMCACHE=skip to skip it)"
    starttime=`date +%s`
    for r in repos/*/.hg repos/partial-references/*/.hg; do
        r="`dirname $r`"
        echo checking caches for: $r
        # dropping HGRC to avoid user extension interfering
        HGRCPATH= mercurial/hg -R "$r" debugupdatecache
    done
    endtime=`date +%s`
    echo warming cache took `expr $endtime - $starttime` seconds
fi