Skip to content

Commit 848ecd2

Browse files
mdboomleofang
andauthored
[chore] Use sccache in builds (#1156)
* [chore] Use sccache in builds * Set compiler env vars * Add the other special envvar * Try adding vars to cibuildwheel * Try a different way to pass vars fo cibuildwheel * Try another approach * Adjust SCCACHE_DIR inside the container * Specify a cache dir * Try something different * Remove explicit SCCACHE_DIR manipulation * Add envvar * Explicitly start the host * Pass along GHA cache url * Expose the necessary tokens * Try a different approach * Is the token enough? * Does this work? * ACTIONS_RESULTS_URL * Get some debug * fix syntax * try to get accurate cache hit/miss rates * debug * fix windows Reintroduced CIBW_BEFORE_TEST and CIBW_TEST_COMMAND for Linux and Windows. * Try to fix cache writing * restore SCCACHE_GHA_ENABLED * set up env vars in build stage * pass env vars to cibuildwheel * fix * try this * try this * start server on host and make container aware of the ports Uncommented sccache start server step and added container engine configuration. * Revert "start server on host and make container aware of the ports" This reverts commit 93b92b7. * try local build approach with all env vars passed to container * clean up & apply sccache to cuda.core builds * Add steps to find cl.exe and generate wrapper script * fix * defer format normalization * debug * debug * debug * debug * debug * debug * debug * debug * use big gun * fix * debug * fix sccache dir * Remove windows experimentations --------- Co-authored-by: Leo Fang <[email protected]> Co-authored-by: Leo Fang <[email protected]>
1 parent ef4a9cc commit 848ecd2

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

.github/workflows/build-wheel.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,19 @@ jobs:
4545
with:
4646
fetch-depth: 0
4747

48+
# The env vars ACTIONS_CACHE_SERVICE_V2, ACTIONS_RESULTS_URL, and ACTIONS_RUNTIME_TOKEN
49+
# are exposed by this action.
50+
- name: Enable sccache
51+
uses: mozilla-actions/sccache-action@7d986dd989559c6ecdb630a3fd2557667be217ad # 0.0.9
52+
53+
# xref: https://github.com/orgs/community/discussions/42856#discussioncomment-7678867
54+
- name: Adding addtional GHA cache-related env vars
55+
uses: actions/github-script@v7
56+
with:
57+
script: |
58+
core.exportVariable('ACTIONS_CACHE_URL', process.env['ACTIONS_CACHE_URL'])
59+
core.exportVariable('ACTIONS_RUNTIME_URL', process.env['ACTIONS_RUNTIME_URL'])
60+
4861
- name: Setup proxy cache
4962
uses: nv-gha-runners/setup-proxy-cache@main
5063
continue-on-error: true
@@ -129,9 +142,27 @@ jobs:
129142
CIBW_ENVIRONMENT_LINUX: >
130143
CUDA_PATH=/host/${{ env.CUDA_PATH }}
131144
CUDA_PYTHON_PARALLEL_LEVEL=${{ env.CUDA_PYTHON_PARALLEL_LEVEL }}
145+
CC="/host/${{ env.SCCACHE_PATH }} cc"
146+
CXX="/host/${{ env.SCCACHE_PATH }} c++"
147+
SCCACHE_GHA_ENABLED=true
148+
ACTIONS_RUNTIME_TOKEN=${{ env.ACTIONS_RUNTIME_TOKEN }}
149+
ACTIONS_RUNTIME_URL=${{ env.ACTIONS_RUNTIME_URL }}
150+
ACTIONS_RESULTS_URL=${{ env.ACTIONS_RESULTS_URL }}
151+
ACTIONS_CACHE_URL=${{ env.ACTIONS_CACHE_URL }}
152+
ACTIONS_CACHE_SERVICE_V2=${{ env.ACTIONS_CACHE_SERVICE_V2 }}
153+
SCCACHE_DIR=/host/${{ env.SCCACHE_DIR }}
154+
SCCACHE_CACHE_SIZE=${{ env.SCCACHE_CACHE_SIZE }}
132155
CIBW_ENVIRONMENT_WINDOWS: >
133156
CUDA_PATH="$(cygpath -w ${{ env.CUDA_PATH }})"
134157
CUDA_PYTHON_PARALLEL_LEVEL=${{ env.CUDA_PYTHON_PARALLEL_LEVEL }}
158+
# check cache stats before leaving cibuildwheel
159+
CIBW_BEFORE_TEST_LINUX: >
160+
"/host/${{ env.SCCACHE_PATH }}" --show-stats
161+
# force the test stage to be run (so that before-test is not skipped)
162+
# TODO: we might want to think twice on adding this, it does a lot of
163+
# things before reaching this command.
164+
CIBW_TEST_COMMAND: >
165+
echo "ok!"
135166
136167
- name: List the cuda.bindings artifacts directory
137168
run: |
@@ -167,11 +198,29 @@ jobs:
167198
CUDA_PYTHON_PARALLEL_LEVEL=${{ env.CUDA_PYTHON_PARALLEL_LEVEL }}
168199
CUDA_CORE_BUILD_MAJOR=${{ env.BUILD_CUDA_MAJOR }}
169200
PIP_FIND_LINKS=/host/${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}
201+
CC="/host/${{ env.SCCACHE_PATH }} cc"
202+
CXX="/host/${{ env.SCCACHE_PATH }} c++"
203+
SCCACHE_GHA_ENABLED=true
204+
ACTIONS_RUNTIME_TOKEN=${{ env.ACTIONS_RUNTIME_TOKEN }}
205+
ACTIONS_RUNTIME_URL=${{ env.ACTIONS_RUNTIME_URL }}
206+
ACTIONS_RESULTS_URL=${{ env.ACTIONS_RESULTS_URL }}
207+
ACTIONS_CACHE_URL=${{ env.ACTIONS_CACHE_URL }}
208+
ACTIONS_CACHE_SERVICE_V2=${{ env.ACTIONS_CACHE_SERVICE_V2 }}
209+
SCCACHE_DIR=/host/${{ env.SCCACHE_DIR }}
210+
SCCACHE_CACHE_SIZE=${{ env.SCCACHE_CACHE_SIZE }}
170211
CIBW_ENVIRONMENT_WINDOWS: >
171212
CUDA_PATH="$(cygpath -w ${{ env.CUDA_PATH }})"
172213
CUDA_PYTHON_PARALLEL_LEVEL=${{ env.CUDA_PYTHON_PARALLEL_LEVEL }}
173214
CUDA_CORE_BUILD_MAJOR=${{ env.BUILD_CUDA_MAJOR }}
174215
PIP_FIND_LINKS="$(cygpath -w ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }})"
216+
# check cache stats before leaving cibuildwheel
217+
CIBW_BEFORE_TEST_LINUX: >
218+
"/host${{ env.SCCACHE_PATH }}" --show-stats
219+
# force the test stage to be run (so that before-test is not skipped)
220+
# TODO: we might want to think twice on adding this, it does a lot of
221+
# things before reaching this command.
222+
CIBW_TEST_COMMAND: >
223+
echo "ok!"
175224
176225
- name: List the cuda.core artifacts directory and rename
177226
run: |
@@ -330,11 +379,29 @@ jobs:
330379
CUDA_PYTHON_PARALLEL_LEVEL=${{ env.CUDA_PYTHON_PARALLEL_LEVEL }}
331380
CUDA_CORE_BUILD_MAJOR=${{ env.BUILD_PREV_CUDA_MAJOR }}
332381
PIP_FIND_LINKS=/host/${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }}
382+
CC="/host/${{ env.SCCACHE_PATH }} cc"
383+
CXX="/host/${{ env.SCCACHE_PATH }} c++"
384+
SCCACHE_GHA_ENABLED=true
385+
ACTIONS_RUNTIME_TOKEN=${{ env.ACTIONS_RUNTIME_TOKEN }}
386+
ACTIONS_RUNTIME_URL=${{ env.ACTIONS_RUNTIME_URL }}
387+
ACTIONS_RESULTS_URL=${{ env.ACTIONS_RESULTS_URL }}
388+
ACTIONS_CACHE_URL=${{ env.ACTIONS_CACHE_URL }}
389+
ACTIONS_CACHE_SERVICE_V2=${{ env.ACTIONS_CACHE_SERVICE_V2 }}
390+
SCCACHE_DIR=/host/${{ env.SCCACHE_DIR }}
391+
SCCACHE_CACHE_SIZE=${{ env.SCCACHE_CACHE_SIZE }}
333392
CIBW_ENVIRONMENT_WINDOWS: >
334393
CUDA_PATH="$(cygpath -w ${{ env.CUDA_PATH }})"
335394
CUDA_PYTHON_PARALLEL_LEVEL=${{ env.CUDA_PYTHON_PARALLEL_LEVEL }}
336395
CUDA_CORE_BUILD_MAJOR=${{ env.BUILD_PREV_CUDA_MAJOR }}
337396
PIP_FIND_LINKS="$(cygpath -w ${{ env.CUDA_BINDINGS_ARTIFACTS_DIR }})"
397+
# check cache stats before leaving cibuildwheel
398+
CIBW_BEFORE_TEST_LINUX: >
399+
"/host${{ env.SCCACHE_PATH }}" --show-stats
400+
# force the test stage to be run (so that before-test is not skipped)
401+
# TODO: we might want to think twice on adding this, it does a lot of
402+
# things before reaching this command.
403+
CIBW_TEST_COMMAND: >
404+
echo "ok!"
338405
339406
- name: List the cuda.core artifacts directory and rename
340407
run: |

ci/tools/env-vars

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ if [[ "${1}" == "build" ]]; then
4545
echo "BUILD_CUDA_MAJOR=${BUILD_CUDA_MAJOR}" >> $GITHUB_ENV
4646
echo "BUILD_PREV_CUDA_MAJOR=$((${BUILD_CUDA_MAJOR} - 1))" >> $GITHUB_ENV
4747
CUDA_BINDINGS_ARTIFACT_BASENAME="cuda-bindings-python${PYTHON_VERSION_FORMATTED}-cuda${CUDA_VER}-${HOST_PLATFORM}"
48+
# Enforce an explicit cache dir so that we can reuse this path later
49+
echo "SCCACHE_DIR=${HOME}/.cache/sccache" >> $GITHUB_ENV
50+
echo "SCCACHE_CACHE_SIZE=1G" >> $GITHUB_ENV
4851
elif [[ "${1}" == "test" ]]; then
4952
BUILD_CUDA_MAJOR="$(cut -d '.' -f 1 <<< ${BUILD_CUDA_VER})"
5053
TEST_CUDA_MAJOR="$(cut -d '.' -f 1 <<< ${CUDA_VER})"

0 commit comments

Comments
 (0)