Skip to content

Commit fd5d486

Browse files
committed
pretend sticky for ~/.cache/nix
1 parent d14e16f commit fd5d486

1 file changed

Lines changed: 21 additions & 9 deletions

File tree

‎.github/workflows/nix-build.yml‎

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ jobs:
4040
- { workers: 32, max_memory: 3840 }
4141
- { workers: 24, max_memory: 4608 }
4242
- { workers: 16, max_memory: 7168 }
43+
include:
44+
# Like quick-sticky, but keeps ~/.cache/nix between the untimed and timed runs.
45+
# Comparing it with the quick-sticky row for the same limits shows how much of eval time is binary cache lookups.
46+
- install: quick-sticky-warm-cache
47+
limits: { workers: 32, max_memory: 3072 }
4348
steps:
4449
- name: Checkout Repo
4550
uses: actions/checkout@v7.0.1
@@ -54,16 +59,16 @@ jobs:
5459
# Each matrix row gets its own disk, so rows don't overwrite each other's store.
5560
# The key is new because a store from the multi-user install is owned by root.
5661
- name: Mount Nix store from sticky disk
57-
if: matrix.install == 'quick-sticky'
62+
if: startsWith(matrix.install, 'quick-sticky')
5863
uses: useblacksmith/stickydisk@v1.7.2
5964
with:
60-
key: ${{ github.repository }}-eval-bench-nix-store-v1-${{ matrix.limits.workers }}-${{ matrix.limits.max_memory }}
65+
key: ${{ github.repository }}-eval-bench-nix-store-v1-${{ matrix.install }}-${{ matrix.limits.workers }}-${{ matrix.limits.max_memory }}
6166
path: /nix
6267

6368
# The single-user install needs to own /nix.
6469
# A disk that already has a store means this run starts warm.
6570
- name: Own sticky disk mount point
66-
if: matrix.install == 'quick-sticky'
71+
if: startsWith(matrix.install, 'quick-sticky')
6772
run: |
6873
sudo chown "$(id -u):$(id -g)" /nix
6974
if [[ -d /nix/store ]]; then
@@ -75,7 +80,7 @@ jobs:
7580
# nix-quick-install-action v35 tops out at Nix 2.34.7; our install-nix action uses 2.35.3.
7681
# Eval itself runs inside nix-eval-jobs, which brings its own Nix, so this mainly changes the store and daemon side.
7782
- name: Install nix (single user)
78-
if: matrix.install == 'quick-sticky'
83+
if: startsWith(matrix.install, 'quick-sticky')
7984
uses: nixbuild/nix-quick-install-action@v35
8085
with:
8186
nix_version: 2.34.7
@@ -103,12 +108,14 @@ jobs:
103108
# Sticky disk writes from PRs are thrown away, so a quick-sticky row would always start with an empty store.
104109
# To stand in for a warm sticky disk, run eval once untimed to fill the store, then time a second run.
105110
# The narinfo cache in ~/.cache/nix is deleted in between, because it would not be on the sticky disk.
111+
# The quick-sticky-warm-cache row keeps it, to show what caching ~/.cache/nix as well would save.
106112
# This is a best case: a real sticky disk reads its snapshot over the network the first time each file is used.
107113
- name: Fill the store with an untimed eval
108-
if: matrix.install == 'quick-sticky'
114+
if: startsWith(matrix.install, 'quick-sticky')
109115
env:
110116
WORKERS: ${{ matrix.limits.workers }}
111117
MAX_MEMORY: ${{ matrix.limits.max_memory }}
118+
INSTALL: ${{ matrix.install }}
112119
run: |
113120
set -euo pipefail
114121
"$NIX_EVAL_JOBS" \
@@ -122,8 +129,13 @@ jobs:
122129
--workers "$WORKERS" \
123130
--select 'outputs: { inherit (outputs) checks legacyPackages; }' \
124131
>/dev/null
125-
rm -rf ~/.cache/nix
126-
echo "STORE=warmed in job ($(find /nix/store -mindepth 1 -maxdepth 1 | wc -l) paths)" >>"$GITHUB_ENV"
132+
paths=$(find /nix/store -mindepth 1 -maxdepth 1 | wc -l)
133+
if [[ $INSTALL == quick-sticky-warm-cache ]]; then
134+
echo "STORE=warmed in job ($paths paths), ~/.cache/nix kept" >>"$GITHUB_ENV"
135+
else
136+
rm -rf ~/.cache/nix
137+
echo "STORE=warmed in job ($paths paths)" >>"$GITHUB_ENV"
138+
fi
127139
128140
# Time flake input fetching and eval together, in one run, the way the eval job does it.
129141
- name: Time eval
@@ -201,9 +213,9 @@ jobs:
201213
echo "Each table is sorted by eval time, fastest first."
202214
echo "Rows missing from a table are runs that failed."
203215
echo
204-
echo "### Sticky disk (quick-sticky)"
216+
echo "### Sticky disk (quick-sticky, quick-sticky-warm-cache)"
205217
echo
206-
awk -F'\t' '$1 == "quick-sticky"' all.tsv | table
218+
awk -F'\t' '$1 ~ /^quick-sticky/' all.tsv | table
207219
echo "### No sticky disk (multi-user)"
208220
echo
209221
awk -F'\t' '$1 == "multi-user"' all.tsv | table

0 commit comments

Comments
 (0)