@@ -23,6 +23,11 @@ ARG ENABLE_KVBM=false
23
23
ARG ARCH=amd64
24
24
ARG ARCH_ALT=x86_64
25
25
26
+ # sccache configuration
27
+ ARG USE_SCCACHE
28
+ ARG SCCACHE_BUCKET=""
29
+ ARG SCCACHE_REGION=""
30
+
26
31
27
32
# #################################
28
33
# ######### Base Image ############
@@ -109,13 +114,39 @@ RUN wget --tries=3 --waitretry=5 https://github.com/etcd-io/etcd/releases/downlo
109
114
rm /tmp/etcd.tar.gz
110
115
ENV PATH=/usr/local/bin/etcd/:$PATH
111
116
117
+ # Install sccache if requested
118
+ ARG USE_SCCACHE
119
+ ARG SCCACHE_BUCKET
120
+ ARG SCCACHE_REGION
121
+ RUN if [ "$USE_SCCACHE" = "true" ]; then \
122
+ SCCACHE_VERSION="v0.8.2" && \
123
+ wget --tries=3 --waitretry=5 "https://github.com/mozilla/sccache/releases/download/${SCCACHE_VERSION}/sccache-${SCCACHE_VERSION}-x86_64-unknown-linux-musl.tar.gz" && \
124
+ tar -xzf "sccache-${SCCACHE_VERSION}-x86_64-unknown-linux-musl.tar.gz" && \
125
+ mv "sccache-${SCCACHE_VERSION}-x86_64-unknown-linux-musl/sccache" /usr/local/bin/ && \
126
+ rm -rf sccache*; \
127
+ fi
128
+
129
+ # Set sccache environment variables if USE_SCCACHE is set
130
+ ENV SCCACHE_BUCKET=${USE_SCCACHE:+${SCCACHE_BUCKET}} \
131
+ SCCACHE_REGION=${USE_SCCACHE:+${SCCACHE_REGION}} \
132
+ SCCACHE_S3_KEY_PREFIX=${USE_SCCACHE:+${ARCH}} \
133
+ RUSTC_WRAPPER=${USE_SCCACHE:+sccache} \
134
+ CMAKE_C_COMPILER_LAUNCHER=${USE_SCCACHE:+sccache} \
135
+ CMAKE_CXX_COMPILER_LAUNCHER=${USE_SCCACHE:+sccache} \
136
+ CMAKE_CUDA_COMPILER_LAUNCHER=${USE_SCCACHE:+sccache}
137
+
112
138
# ## UCX EFA Setup ###
139
+ # Keep CC and CXX environment variables set to sccache if USE_SCCACHE is set to true for UCX build since this requirement is specific to UCX
113
140
RUN rm -rf /opt/hpcx/ucx && \
114
141
rm -rf /usr/local/ucx && \
115
142
echo "Building UCX with reference $NIXL_UCX_REF" && \
116
143
cd /usr/local/src && \
117
144
git clone https://github.com/openucx/ucx.git && \
118
145
cd ucx && git checkout $NIXL_UCX_REF && \
146
+ CC=${USE_SCCACHE:+sccache gcc} && \
147
+ CXX=${USE_SCCACHE:+sccache g++} && \
148
+ export CC=${CC} && \
149
+ export CXX=${CXX} && \
119
150
./autogen.sh && \
120
151
./configure \
121
152
--prefix=/usr/local/ucx \
@@ -133,6 +164,8 @@ RUN rm -rf /opt/hpcx/ucx && \
133
164
--enable-mt && \
134
165
make -j$(nproc) && \
135
166
make -j$(nproc) install-strip && \
167
+ echo "=== sccache stats AFTER UCX build ===" && \
168
+ sccache --show-stats && \
136
169
echo "/usr/local/ucx/lib" > /etc/ld.so.conf.d/ucx.conf && \
137
170
echo "/usr/local/ucx/lib/ucx" >> /etc/ld.so.conf.d/ucx.conf && \
138
171
ldconfig && \
@@ -155,6 +188,8 @@ RUN git clone --depth 1 --branch ${NIXL_REF} "https://github.com/ai-dynamo/nixl.
155
188
fi && \
156
189
meson setup build/ --buildtype=release --prefix=$NIXL_PREFIX $nixl_build_args && \
157
190
ninja -C build/ -j$(nproc) && \
191
+ echo "=== sccache stats AFTER NIXL build ===" && \
192
+ sccache --show-stats && \
158
193
ninja -C build/ install && \
159
194
echo "$NIXL_LIB_DIR" > /etc/ld.so.conf.d/nixl.conf && \
160
195
echo "$NIXL_PLUGIN_DIR" >> /etc/ld.so.conf.d/nixl.conf && \
@@ -218,7 +253,11 @@ COPY --from=base $RUSTUP_HOME $RUSTUP_HOME
218
253
COPY --from=base $CARGO_HOME $CARGO_HOME
219
254
COPY --from=base $NIXL_PREFIX $NIXL_PREFIX
220
255
COPY --from=base $VIRTUAL_ENV $VIRTUAL_ENV
221
- ENV PATH=$CARGO_HOME/bin:$VIRTUAL_ENV/bin:$PATH
256
+
257
+ ENV PATH=$CARGO_HOME/bin:$VIRTUAL_ENV/bin:$PATH:/usr/local/bin/sccache
258
+
259
+ # Copy sccache from base stage if it was installed
260
+ COPY --from=base /usr/local/bin/sccache /usr/local/bin/sccache
222
261
223
262
# Copy configuration files first for better layer caching
224
263
COPY pyproject.toml README.md LICENSE Cargo.toml Cargo.lock rust-toolchain.toml hatch_build.py /opt/dynamo/
@@ -227,10 +266,22 @@ COPY pyproject.toml README.md LICENSE Cargo.toml Cargo.lock rust-toolchain.toml
227
266
COPY lib/ /opt/dynamo/lib/
228
267
COPY components/ /opt/dynamo/components/
229
268
269
+ # Redeclare sccache ARGs for wheel_builder stage
270
+ ARG USE_SCCACHE
271
+ ARG SCCACHE_BUCKET
272
+ ARG SCCACHE_REGION
273
+
274
+ # Set sccache environment variables if USE_SCCACHE is set
275
+ ENV SCCACHE_BUCKET=${USE_SCCACHE:+${SCCACHE_BUCKET}} \
276
+ SCCACHE_REGION=${USE_SCCACHE:+${SCCACHE_REGION}} \
277
+ SCCACHE_S3_KEY_PREFIX=${USE_SCCACHE:+${ARCH}} \
278
+ RUSTC_WRAPPER=${USE_SCCACHE:+sccache}
279
+
230
280
# Build dynamo wheel
231
281
RUN uv build --wheel --out-dir /opt/dynamo/dist && \
232
282
cd /opt/dynamo/lib/bindings/python && \
233
283
uv pip install maturin[patchelf] && \
284
+ echo "RUSTC_WRAPPER set to: $RUSTC_WRAPPER" && \
234
285
if [ "$ENABLE_KVBM" = "true" ]; then \
235
286
maturin build --release --features block-manager --out /opt/dynamo/dist; \
236
287
else \
@@ -240,7 +291,9 @@ RUN uv build --wheel --out-dir /opt/dynamo/dist && \
240
291
# do not enable KVBM feature, ensure compatibility with lower glibc
241
292
uv run --python 3.11 maturin build --release --out /opt/dynamo/dist && \
242
293
uv run --python 3.10 maturin build --release --out /opt/dynamo/dist; \
243
- fi
294
+ fi && \
295
+ echo "=== sccache stats after dynamo build ===" && \
296
+ sccache --show-stats
244
297
245
298
# #############################################
246
299
# ######### Dev entrypoint image ##############
0 commit comments