diff --git a/.travis.yml b/.travis.yml index c29a0f509..1b37f8857 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,9 @@ sudo: required dist: xenial language: cpp +cache: + - ccache + services: - docker @@ -47,8 +50,8 @@ install: before_script: - sudo mkdir -p /mnt/huge - sudo mount -t hugetlbfs nodev /mnt/huge - - export CXX=$VER_CXX - - export CC=$VER_CC + - export CXX="ccache $VER_CXX" + - ccache -s script: # travis_wait extends the 10-min timeout to 20mins. @@ -68,6 +71,9 @@ after_failure: - more /tmp/bessd.*.INFO.* | cat # dump all bessd log files - sudo more /tmp/sanitizer* | cat # dump all sanitizer results +after_script: + - ccache -s + before_deploy: - for arch in core2 sandybridge haswell; do export CXXARCHFLAGS="-march=$arch"; diff --git a/container_build.py b/container_build.py index ca2a0a2d2..d8b4bf3dc 100755 --- a/container_build.py +++ b/container_build.py @@ -45,12 +45,15 @@ BUILD_SCRIPT = './build.py' PLUGINS = [] +CCACHE_DIR_HOST = '~/.ccache' +CCACHE_DIR_CONTAINER = '/tmp/ccache' + def docker_mount_args(plugins): """ Return the string of arguments to "docker run" suitable for - mounting BESS_DIR_HOST as BESS_DIR_CONTAINER and all the - plugins under their original paths. + mounting BESS_DIR_HOST (as BESS_DIR_CONTAINER), ccache, and + all the plugins under their original paths. Note, the plugins must not live under the BESS_DIR_CONTAINER directory itself since that will not play well. But plugins @@ -65,12 +68,17 @@ def docker_mount_args(plugins): sys.exit('Error: plugin {!r}: path {!r} is taken by ' 'bess'.format(path, BESS_DIR_CONTAINER)) - ret = ['-v {}:{}'.format(BESS_DIR_HOST, BESS_DIR_CONTAINER)] + # If the ccache directory does not exist, create one owned by the current + # user (otherwise Docker will create one with root:root) + os.system('mkdir -p %s' % CCACHE_DIR_HOST) + + ret = ['-v {}:{}'.format(CCACHE_DIR_HOST, CCACHE_DIR_CONTAINER), + '-v {}:{}'.format(BESS_DIR_HOST, BESS_DIR_CONTAINER)] # Make sure longer paths that are prefixes of shorter paths # appear after the shorter paths. That way we mount only # /foo/bar if both /foo/bar and /foo/bar/sub/dir are listed. - earlier = { BESS_DIR_HOST: True } + earlier = {BESS_DIR_HOST: True} for path in sorted(plugins, key=lambda x: x + os.path.sep): # given, e.g., /foo/bar/baz we want to look at /foo, /foo/bar, # and /foo/bar/baz to see if they're already in the mount list. @@ -102,16 +110,20 @@ def shell_quote(cmd): return "'" + cmd.replace("'", "'\\''") + "'" +def docker_env_args(): + env_vars = ['V', 'CXX', 'DEBUG', 'SANITIZE'] + return ' '.join(['-e %s' % var for var in env_vars]) + + def run_docker_cmd(cmd): - run_cmd('docker run -e V -e CXX -e DEBUG -e SANITIZE --rm -t ' - '-u %d:%d %s %s sh -c %s' % - (os.getuid(), os.getgid(), docker_mount_args(PLUGINS), - IMAGE, shell_quote(cmd))) + run_cmd('docker run %s --rm -t -u %d:%d %s %s sh -c %s' % + (docker_env_args(), os.getuid(), os.getgid(), + docker_mount_args(PLUGINS), IMAGE, shell_quote(cmd))) def run_shell(): - run_cmd('docker run -e V -e CXX -e DEBUG -e SANITIZE --rm -it %s %s' % - (docker_mount_args(PLUGINS), IMAGE)) + run_cmd('docker run %s --rm -it %s %s' % + (docker_env_args(), docker_mount_args(PLUGINS), IMAGE)) def find_current_plugins(): diff --git a/core/gate_hooks/track.cc b/core/gate_hooks/track.cc index 3fd845d56..65a45046e 100644 --- a/core/gate_hooks/track.cc +++ b/core/gate_hooks/track.cc @@ -57,7 +57,6 @@ CommandResponse Track::CommandReset(const bess::pb::EmptyArg &) { } void Track::ProcessBatch(const bess::PacketBatch *batch) { - LOG(ERROR) << current_worker.wid(); TrackStats *stat = &worker_stats_[current_worker.wid()]; size_t cnt = batch->cnt(); diff --git a/env/Dockerfile b/env/Dockerfile index d7a0ebcd5..4f3c2bf65 100644 --- a/env/Dockerfile +++ b/env/Dockerfile @@ -19,12 +19,14 @@ RUN mkdir -p /build # Pre-build DPDK from the specified BESS branch ARG BESS_DPDK_BRANCH=master -ARG DPDK_ARCH=x86_64 RUN cd /build && \ git clone -b ${BESS_DPDK_BRANCH} https://github.com/netsys/bess && \ cd /build/bess && \ - setarch ${DPDK_ARCH} ./build.py dpdk && \ + ./build.py dpdk && \ mv /build/bess/deps/dpdk-17.11 /build/dpdk-17.11 && \ rm -rf /build/bess +ENV CCACHE_DIR=/tmp/ccache +ENV CCACHE_COMPRESS=true + WORKDIR /build/bess diff --git a/env/ci.yml b/env/ci.yml index 07430df05..59be464d5 100644 --- a/env/ci.yml +++ b/env/ci.yml @@ -25,3 +25,4 @@ - ca-certificates - g++-8 - clang-6.0 + - ccache diff --git a/env/rebuild_images.py b/env/rebuild_images.py index 62f5c2c3b..a7c540e84 100755 --- a/env/rebuild_images.py +++ b/env/rebuild_images.py @@ -40,11 +40,7 @@ TARGET_REPO = 'nefelinetworks/bess_build' imgs = { - 'bionic64': {'arch': 'x86_64', 'base': 'ubuntu:bionic', - 'tag_suffix': ''}, - # i386 is not supported any longer - # 'trusty32': {'arch': 'i386', 'base': 'i386/ubuntu:trusty', - # 'tag_suffix': '_32'}, + 'bionic64': {'base': 'ubuntu:bionic', 'tag_suffix': ''}, } @@ -60,7 +56,6 @@ def run_cmd(cmd, shell=False): def build(env): - arch = imgs[env]['arch'] base = imgs[env]['base'] tag_suffix = imgs[env]['tag_suffix'] bess_dpdk_branch = os.getenv('BESS_DPDK_BRANCH', 'master') @@ -69,10 +64,9 @@ def build(env): run_cmd('docker build ' '--build-arg BASE_IMAGE={base} ' '--build-arg BESS_DPDK_BRANCH={branch} ' - '--build-arg DPDK_ARCH={arch} ' '-t {target}:latest{suffix} -t {target}:{version}{suffix} ' - '.'.format(base=base, branch=bess_dpdk_branch, arch=arch, - target=TARGET_REPO, version=version, suffix=tag_suffix)) + '.'.format(base=base, branch=bess_dpdk_branch, target=TARGET_REPO, + version=version, suffix=tag_suffix)) print('Build succeeded: {}:{}{}'.format(TARGET_REPO, version, tag_suffix)) print('Build succeeded: {}:latest{}'.format(TARGET_REPO, tag_suffix))