Skip to content

Commit 196207e

Browse files
committed
perf(release): cache ccache and disable LTO to speed up Nuitka builds
Nuitka --onefile compiles all Python to C on every run, which on cold CI runners routinely takes 15+ minutes in the Scons stage. Two mitigations: - Persist ~/.cache/ccache across workflow runs via actions/cache, keyed on target + Python version + hash of pyproject.toml and build-binary.sh so a Nuitka pin bump or flag change buckets into a fresh cache. ccache is content-addressed, so changing Python source invalidates only the .o files whose generated C actually changed. Windows is skipped because MSVC does not integrate with ccache. macOS gains a brew install step. - Pass --lto=no to Nuitka. LTO roughly doubles link time on gcc 11 and the runtime win is not worth paying on every tag push. Also drops the redundant --standalone flag (--onefile implies it) and prints ccache stats after each build for visibility into hit rate. Signed-off-by: Sodawyx <sodawyx@126.com>
1 parent 66e2e62 commit 196207e

2 files changed

Lines changed: 36 additions & 1 deletion

File tree

.github/workflows/release.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,36 @@ jobs:
118118
sudo apt-get update -qq
119119
sudo apt-get install -y -qq patchelf ccache
120120
121+
- name: Install ccache (macOS)
122+
if: startsWith(matrix.target, 'darwin-')
123+
shell: bash
124+
run: brew install ccache
125+
126+
# Persist ccache across runs. Key hashes pyproject.toml + build-binary.sh
127+
# so a Nuitka pin bump or a build-script flag change buckets the cache
128+
# into a fresh partition. ccache itself is content-addressed, so stale
129+
# .o reuse is not a concern: if the generated C changes, it misses.
130+
# Skipped on Windows because Nuitka uses MSVC there and ccache does not
131+
# integrate with cl.exe.
132+
- name: Restore ccache
133+
if: ${{ !startsWith(matrix.target, 'windows-') }}
134+
uses: actions/cache@v4
135+
with:
136+
path: |
137+
~/.cache/ccache
138+
~/Library/Caches/ccache
139+
key: ccache-${{ matrix.target }}-py${{ env.PYTHON_VERSION }}-${{ hashFiles('pyproject.toml', 'scripts/build-binary.sh') }}
140+
restore-keys: |
141+
ccache-${{ matrix.target }}-py${{ env.PYTHON_VERSION }}-
142+
ccache-${{ matrix.target }}-
143+
144+
- name: Configure ccache
145+
if: ${{ !startsWith(matrix.target, 'windows-') }}
146+
shell: bash
147+
run: |
148+
ccache --max-size=2G
149+
ccache --zero-stats
150+
121151
- name: Install project + Nuitka
122152
shell: bash
123153
run: |
@@ -131,6 +161,11 @@ jobs:
131161
bash scripts/build-binary.sh
132162
ls -lh dist/
133163
164+
- name: Print ccache stats
165+
if: ${{ !startsWith(matrix.target, 'windows-') }}
166+
shell: bash
167+
run: ccache --show-stats
168+
134169
- name: Smoke test binary
135170
shell: bash
136171
run: |

scripts/build-binary.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ mkdir -p dist
9494
echo "=== Building agentrun (version: $VERSION) with Nuitka --onefile ==="
9595
python3 -m nuitka \
9696
--onefile \
97-
--standalone \
9897
--assume-yes-for-downloads \
9998
--output-filename=agentrun \
10099
--output-dir=dist \
@@ -104,6 +103,7 @@ python3 -m nuitka \
104103
--product-name=agentrun \
105104
--product-version="$PRODUCT_VERSION" \
106105
--python-flag=-O \
106+
--lto=no \
107107
--nofollow-import-to="$EXCLUDES" \
108108
--remove-output \
109109
src/agentrun_cli/main.py

0 commit comments

Comments
 (0)