Skip to content

Commit

Permalink
run-make-check.sh: ccache goodness for everyone
Browse files Browse the repository at this point in the history
Since run-make-check.sh already ensures that ccache is installed,
it makes sense to let everyone benefit from the ccache
tweaks introduced by 4cb5a59

Note 1: The previous solution using "date" would cause build tools to reset
their timestamps after 24 hours, on subsequent runs of run-make-check.sh.
In order to maximize ccache effectiveness, this commit sets SOURCE_DATE_EPOCH
to a fixed value: the number of seconds elapsed since the Unix epoch as at
January 1, 2000 (chosen to commemorate Y2K armageddon).

Note 2: this commit introduces "set -e". This was actually in effect
before, via "source install-deps.sh". Better to make it explicit.

Fixes: http://tracker.ceph.com/issues/24777
Signed-off-by: Nathan Cutler <[email protected]>
  • Loading branch information
smithfarm committed Jul 9, 2018
1 parent c8691cd commit 2315928
Showing 1 changed file with 49 additions and 28 deletions.
77 changes: 49 additions & 28 deletions run-make-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,26 @@
# version 2.1 of the License, or (at your option) any later version.
#

#
# Return MAX(1, (number of processors / 2)) by default or NPROC
#
set -e

trap clean_up_after_myself EXIT

ORIGINAL_CCACHE_CONF="$HOME/.ccache/ccache.conf"
SAVED_CCACHE_CONF="$HOME/.run-make-check-saved-ccache-conf"

function save_ccache_conf() {
test -f $ORIGINAL_CCACHE_CONF && cp $ORIGINAL_CCACHE_CONF $SAVED_CCACHE_CONF || true
}

function restore_ccache_conf() {
test -f $SAVED_CCACHE_CONF && mv $SAVED_CCACHE_CONF $ORIGINAL_CCACHE_CONF || true
}

function clean_up_after_myself() {
rm -fr ${CEPH_BUILD_VIRTUALENV:-/tmp}/*virtualenv*
restore_ccache_conf
}

function get_processors() {
if test -n "$NPROC" ; then
echo $NPROC
Expand Down Expand Up @@ -60,6 +77,11 @@ function run() {
echo "This probably means distribution $ID is not supported by run-make-check.sh" >&2
fi

if ! type ccache > /dev/null 2>&1 ; then
echo "ERROR: ccache could not be installed"
exit 1
fi

if test -f ./install-deps.sh ; then
$DRY_RUN source ./install-deps.sh || return 1
fi
Expand All @@ -76,28 +98,34 @@ function run() {

CMAKE_BUILD_OPTS="-DWITH_FIO=ON -DWITH_GTEST_PARALLEL=ON"

# Are we in the CI ?
cat <<EOM
Note that the binaries produced by this script do not contain correct time
and git version information, which may make them unsuitable for debugging
and production use.
EOM
save_ccache_conf
# remove the entropy generated by the date/time embedded in the build
CMAKE_BUILD_OPTS="$CMAKE_BUILD_OPTS -D ENABLE_GIT_VERSION=OFF"
export SOURCE_DATE_EPOCH="946684800"
ccache -o sloppiness=time_macros
ccache -o run_second_cpp=true
if [ -n "$JENKINS_HOME" ]; then
echo "Jenkins got detected, let's tune the build"
# The following settings are made for improving ccache efficiency
# by removing the entropy generated by the date/time embedded in the build
CMAKE_BUILD_OPTS="$CMAKE_BUILD_OPTS -D ENABLE_GIT_VERSION=OFF"
export SOURCE_DATE_EPOCH=$(date +%D |date -f- +%s)
ccache -o sloppiness=time_macros
ccache -o run_second_cpp=true

# Build host has plenty of space available, let's use it to keep
# various versions of the built objects. This could increase the cache hit
# if the same or similar PRs are running several times
ccache -o max_size=100G
ccache -z # Reset the ccache statistics
# Build host has plenty of space available, let's use it to keep
# various versions of the built objects. This could increase the cache hit
# if the same or similar PRs are running several times
ccache -o max_size=100G
else
echo "Current ccache max_size setting:"
ccache -p | grep max_size
fi
ccache -z # Reset the ccache statistics

$DRY_RUN ./do_cmake.sh $CMAKE_BUILD_OPTS $CMAKE_PYTHON_OPTS $@ || return 1
$DRY_RUN cd build
$DRY_RUN make $BUILD_MAKEOPTS tests || return 1
if [ -n "$JENKINS_HOME" ]; then
ccache -s # print the ccache statistics to evaluate the efficiency
fi

ccache -s # print the ccache statistics to evaluate the efficiency

# prevent OSD EMFILE death on tests, make sure large than 1024
$DRY_RUN ulimit -n $(ulimit -Hn)
if [ $(ulimit -n) -lt 1024 ];then
Expand All @@ -124,14 +152,7 @@ function main() {
echo "Please fix 'hostname --fqdn', otherwise 'make check' will fail"
return 1
fi
if run "$@" ; then
rm -fr ${CEPH_BUILD_VIRTUALENV:-/tmp}/*virtualenv*
echo "cmake check: successful run on $(git rev-parse HEAD)"
return 0
else
rm -fr ${CEPH_BUILD_VIRTUALENV:-/tmp}/*virtualenv*
return 1
fi
run "$@" && echo "make check: successful run on $(git rev-parse HEAD)"
}

main "$@"

0 comments on commit 2315928

Please sign in to comment.