Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabling ccache on github builds for Ubuntu #95

Merged
merged 51 commits into from
May 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
18f4e30
CI Changes to add tiny regression tests
Apr 8, 2021
f8cf554
Adding an inspect cache step
Apr 9, 2021
6771e4c
Merge branch 'main' into jp/brt-ghci
Apr 9, 2021
ddfb2d5
Removing ccache, pursue in another
Apr 9, 2021
e6b0263
Incorporating Nick's changes through submodule merge
Apr 9, 2021
9b1cdc1
Submodule now points to master
Apr 9, 2021
6fc3207
Restoring ccache enabled workflow file
Apr 9, 2021
5948707
Restoring ccache enabled CMakeLists
Apr 9, 2021
4135d5a
cache -> ccache typo fix
Apr 9, 2021
cd397b8
Moving CCACHE setup to GitHub runner file
Apr 9, 2021
6caa7f2
Find also uses CCACHE dir
Apr 9, 2021
bdc9c52
Updating CMakeLists not to override env
Apr 9, 2021
50d944f
Cache compiler binary's contents
Apr 9, 2021
fe77f9f
Changing a few names to trigger new build; Testing cache looks fun
Apr 9, 2021
aace7bc
Merge branch 'main' into jp/brt-ghci-ccache
May 8, 2021
5c29413
USE_CCACHE=on, -L for inspection
May 8, 2021
cba3257
Adding a ccache_cmd, but will only use in next commit
May 8, 2021
91c8e80
Using ccache_cmd
May 8, 2021
e5b38fb
Removing "
May 9, 2021
5544504
Adding compiler hash script
May 9, 2021
99769e5
Bunch of absolute paths
May 9, 2021
f00ee04
GITHUB_WORKSPACE typo
May 9, 2021
1e5a536
Nah, I'll keep -L and trigger another build
May 9, 2021
759d2c2
Trying something with compiler hash on cache key backup as well
May 9, 2021
6c86e76
builtin, bash it seems
May 9, 2021
47289e0
Empty commit #1
May 9, 2021
f42d04b
Move ccache stats to after compile
May 9, 2021
9fc6836
Reshuffling ccache vars
May 9, 2021
19c71c7
No comments
May 9, 2021
eb9b1df
Updates to Github output set syntax
May 9, 2021
8e6375e
Empty Commit 1
May 9, 2021
54fd63a
Empty Commit 2
May 9, 2021
a8bdbc5
Empty commit 3
May 9, 2021
e9d6faa
Merge branch 'main' into jp/brt-ghci-ccache
May 9, 2021
c9398eb
Merge branch 'main' into jp/brt-ghci-ccache
May 10, 2021
a0d0701
/bin/bash -> bash; ccache_cmd for consistency
May 11, 2021
dd6c378
Adding ccache -s before and after build
May 11, 2021
6aa6005
Merge branch 'jp/brt-ghci-ccache' of github.com:browsermt/bergamot-tr…
May 11, 2021
3b8205d
Adding comments to compiler-hash script
May 11, 2021
06ac142
Let's build cached and non-cached variants together for comparison
May 11, 2021
ed93ebe
Fixing quotes, /bin/bash -> bash
May 11, 2021
c906014
Minor var/env adjustment
May 11, 2021
03f8b1f
Adding ccache -z before the job
May 11, 2021
c96cca4
Merge branch 'main' into jp/brt-ghci-ccache
May 12, 2021
697b979
Merge branch 'main' into jp/brt-ghci-ccache
May 12, 2021
a33e136
Reverting CMakeLists.txt without CCACHE
May 13, 2021
2f99e93
Switching to CMAKE_LANG_COMPILER_LAUNCHER instead of CMakeLists.txt rule
May 13, 2021
55d27a7
Merge branch 'jp/brt-ghci-ccache' of github.com:browsermt/bergamot-tr…
May 13, 2021
decee0c
Merge branch 'main' into jp/brt-ghci-ccache
May 13, 2021
8e0cf60
5G -> 1G cache size
May 13, 2021
aabfe1f
1G -> 2G; Hyperparameter tuning
May 13, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 87 additions & 2 deletions .github/workflows/native-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ jobs:
- name: "full-marian"
os: ubuntu-latest
gcc: 8
force_recache: false
ccache_cmd: "bash ${GITHUB_WORKSPACE}/scripts/ci/compiler-hash.sh %compiler%"
cpu: 'ON'
gpu: 'OFF'
test_tags: ""
Expand All @@ -24,10 +26,14 @@ jobs:
USE_WASM_COMPATIBLE_SOURCE: "OFF"
COMPILE_SERVER: "OFF"
COMPILE_EXAMPLES: "OFF"
CMAKE_C_COMPILER_LAUNCHER: "ccache"
CMAKE_CXX_COMPILER_LAUNCHER: "ccache"

- name: "minimal-marian"
os: ubuntu-latest
gcc: 8
force_recache: false
ccache_cmd: "bash ${GITHUB_WORKSPACE}/scripts/ci/compiler-hash.sh %compiler%"
cpu: 'ON'
gpu: 'OFF'
test_tags: "'#wasm'"
Expand All @@ -37,6 +43,42 @@ jobs:
USE_WASM_COMPATIBLE_SOURCE: "ON"
COMPILE_SERVER: "OFF"
COMPILE_EXAMPLES: "OFF"
CMAKE_C_COMPILER_LAUNCHER: "ccache"
CMAKE_CXX_COMPILER_LAUNCHER: "ccache"

- name: "full-marian-force-recache"
os: ubuntu-latest
gcc: 8
force_recache: true
ccache_cmd: "bash ${GITHUB_WORKSPACE}/scripts/ci/compiler-hash.sh %compiler%"
cpu: 'ON'
gpu: 'OFF'
test_tags: ""
cmake:
CMAKE_BUILD_TYPE: "Release"
COMPILE_TESTS: "ON"
USE_WASM_COMPATIBLE_SOURCE: "OFF"
COMPILE_SERVER: "OFF"
COMPILE_EXAMPLES: "OFF"
CMAKE_C_COMPILER_LAUNCHER: "ccache"
CMAKE_CXX_COMPILER_LAUNCHER: "ccache"

- name: "minimal-marian-force-recache"
os: ubuntu-latest
gcc: 8
force_recache: true
ccache_cmd: "bash ${GITHUB_WORKSPACE}/scripts/ci/compiler-hash.sh %compiler%"
cpu: 'ON'
gpu: 'OFF'
test_tags: "'#wasm'"
cmake:
CMAKE_BUILD_TYPE: "Release"
COMPILE_TESTS: "OFF" # Minimal marian has no sqlite support and COMPILE_TEST=ON fails.
USE_WASM_COMPATIBLE_SOURCE: "ON"
COMPILE_SERVER: "OFF"
COMPILE_EXAMPLES: "OFF"
CMAKE_C_COMPILER_LAUNCHER: "ccache"
CMAKE_CXX_COMPILER_LAUNCHER: "ccache"


runs-on: ${{ matrix.os }}
Expand All @@ -57,7 +99,7 @@ jobs:
sudo apt-get update
sudo apt-get install -y \
libgoogle-perftools-dev libprotobuf-dev protobuf-compiler \
libboost-all-dev g++-${{ matrix.gcc }}
libboost-all-dev g++-${{ matrix.gcc }} ccache

# https://software.intel.com/content/www/us/en/develop/articles/installing-intel-free-libs-and-python-apt-repo.html
- name: Install MKL
Expand All @@ -68,24 +110,67 @@ jobs:
sudo apt-get install -y --no-install-recommends intel-mkl-64bit-2020.0-088
if: matrix.cmake.USE_WASM_COMPATIBLE_SOURCE == 'OFF'

- name: Generate ccache_vars
id: ccache_vars
shell: bash
run: |
echo "::set-output name=hash::$(${{ matrix.ccache_cmd }})"
echo "::set-output name=timestamp::$(date '+%Y-%m-%dT%H.%M.%S')"

- name: Setup ccache environment variables
run: |
echo "CCACHE_COMPILERCHECK=${{ matrix.ccache_cmd }}" >> $GITHUB_ENV
echo "CCACHE_BASE_DIR=${{ github.workspace }}" >> $GITHUB_ENV
echo "CCACHE_DIR=${{ github.workspace }}/.ccache" >> $GITHUB_ENV
echo "CCACHE_COMPRESS=true" >> $GITHUB_ENV
echo "CCACHE_COMPRESSLEVEL=6" >> $GITHUB_ENV
echo "CCACHE_MAXSIZE=2G" >> $GITHUB_ENV

- name: Setup ccache recache on
run: |
echo "CCACHE_RECACHE=" >> $GITHUB_ENV
if: matrix.force_recache == true

- name: Cache-op for build-cache through ccache
uses: actions/cache@v2
with:
path: ${{ env.CCACHE_DIR }}
key: ccache-${{ matrix.name }}-${{ steps.ccache_vars.outputs.hash }}-${{ github.ref }}-${{ steps.ccache_vars.outputs.timestamp }}
restore-keys: |
ccache-${{ matrix.name }}-${{ steps.ccache_vars.outputs.hash }}-${{ github.ref }}-
ccache-${{ matrix.name }}-${{ steps.ccache_vars.outputs.hash }}-
ccache-${{ matrix.name }}-

- name: Cache stats before build
run: |
ccache -s
ccache -z

# Boost is installed on GitHub-hosted runners in a non-standard location
# https://github.com/actions/virtual-environments/issues/687#issuecomment-610471671
- name: Configure CMake
run: |
mkdir -p build
cd build
CC=/usr/bin/gcc-${{ matrix.gcc }} CXX=/usr/bin/g++-${{ matrix.gcc }} CUDAHOSTCXX=/usr/bin/g++-${{ matrix.gcc }} \
cmake .. \
cmake -L .. \
-DCMAKE_BUILD_TYPE=${{ matrix.cmake.CMAKE_BUILD_TYPE }}\
-DCOMPILE_TESTS=${{ matrix.cmake.COMPILE_TESTS }}\
-DCOMPILE_EXAMPLES=${{ matrix.cmake.COMPILE_EXAMPLES }} \
-DCOMPILE_SERVER=${{ matrix.cmake.COMPILE_SERVER }} \
-DUSE_WASM_COMPATIBLE_SOURCE=${{ matrix.cmake.USE_WASM_COMPATIBLE_SOURCE }} \
-DCMAKE_C_COMPILER_LAUNCHER=${{ matrix.cmake.CMAKE_C_COMPILER_LAUNCHER}} \
-DCMAKE_CXX_COMPILER_LAUNCHER=${{ matrix.cmake.CMAKE_CXX_COMPILER_LAUNCHER}}


- name: Compile bergamot-translator
working-directory: build
run: make -j2

- name: Cache stats after build
run: |
ccache -s
jerinphilip marked this conversation as resolved.
Show resolved Hide resolved

- name: Run unit tests
working-directory: build
run: make test
Expand Down
35 changes: 35 additions & 0 deletions scripts/ci/compiler-hash.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

jerinphilip marked this conversation as resolved.
Show resolved Hide resolved
# Uses the command from https://stackoverflow.com/a/9355840/4565794.
# -v displays the commands executed to run compilation. Of this cc1 additional
# flags which contain the flags triggered by -march=native is what we need.
# -E stop after preprocessing stage.

# Output on a linux machine with gcc-8 looks as follows:

# $ gcc -march=native -E -v - </dev/null 2>&1 | grep cc1
# /usr/lib/gcc/x86_64-linux-gnu/8/cc1 -E -quiet -v -imultiarch x86_64-linux-gnu
# - -march=skylake-avx512 -mmmx -mno-3dnow -msse -msse2 -msse3 -mssse3
# -mno-sse4a -mcx16 -msahf -mmovbe -maes -mno-sha -mpclmul -mpopcnt -mabm
# -mno-lwp -mfma -mno-fma4 -mno-xop -mbmi -mno-sgx -mbmi2 -mno-pconfig
# -mno-wbnoinvd -mno-tbm -mavx -mavx2 -msse4.2 -msse4.1 -mlzcnt -mno-rtm
# -mno-hle -mrdrnd -mf16c -mfsgsbase -mrdseed -mprfchw -madx -mfxsr -mxsave
# -mxsaveopt -mavx512f -mno-avx512er -mavx512cd -mno-avx512pf -mno-prefetchwt1
# -mclflushopt -mxsavec -mxsaves -mavx512dq -mavx512bw -mavx512vl
# -mno-avx512ifma -mno-avx512vbmi -mno-avx5124fmaps -mno-avx5124vnniw -mclwb
# -mno-mwaitx -mno-clzero -mpku -mno-rdpid -mno-gfni -mno-shstk
# -mno-avx512vbmi2 -mavx512vnni -mno-vaes -mno-vpclmulqdq -mno-avx512bitalg
# -mno-movdiri -mno-movdir64b --param l1-cache-size=32 --param
# l1-cache-line-size=64 --param l2-cache-size=28160 -mtune=skylake-avx512
# -fstack-protector-strong -Wformat -Wformat-security

# The sha256sum of the output is computed, and stripped to the first 8
# characters for use in ccache and github cache store key. Can effectively be
# considered as a hash of the compiler version and the flags activated by
# -march=native.

COMPILER=$1

$COMPILER -march=native -E -v - < /dev/null 2>&1 | grep cc1 \
graemenail marked this conversation as resolved.
Show resolved Hide resolved
| sha256sum | cut -c1-8