Commit 0ae5535
authored
Optimize GitHub CI cache utilization (#21066)
I created to scripts to analyse the the github runner
[cache](https://github.com/duckdb/duckdb/actions/caches) items:
- `scripts/github_cache_usage.py`: summarize entries, total size and
relative size per workflow.
- `scripts/ccache_workflow_summary.py`: summarize ccache usage for a
GitHub workflow run.
### duckdb/duckdb cache usage
I've asked Mark to change the total cache size of the repo
`duckdb/duckdb` from the default 10 GiB to 50 GiB. However, we're still
reaching that limit, so GitHub evicts cache entries.
Summarizing the cache entries gives:
```sql
┌──────────────────┬─────────────┬───────────┬──────────────┐
│ workflow │ entry_count │ total_gib │ pct_of_total │
├──────────────────┼─────────────┼───────────┼──────────────┤
│ nightlytests │ 42 │ 19.324 │ 39.0 │
│ extensions │ 48 │ 13.286 │ 27.0 │
│ main │ 32 │ 13.135 │ 26.0 │
│ linux-release │ 6 │ 1.496 │ 3.0 │
│ osx │ 8 │ 1.432 │ 3.0 │
│ bundlestaticlibs │ 4 │ 0.658 │ 1.0 │
│ unmapped/other │ 8 │ 0.39 │ 1.0 │
└──────────────────┴─────────────┴───────────┴──────────────┘
```
NightlyTests is mostly running on a nightly schedule, but still
**consumes 39%(!) of the total repo cache**.
### Ccache hit rate for nightly tests
Analysing the ccache hit rate for the branch
[v1.5](https://github.com/duckdb/duckdb/actions/runs/22331644275) gives:
| job_name | ccache_hit_rate | found_ccache_file |
| --- | --- | --- |
| check-draft | N/A | N/A |
| Forcing async Sinks/Sources | 7% | Yes |
| Linux Memory Leaks | 0% | No |
| Release Assertions | 0% | Yes |
| Storage Initialization Verification | 5% | Yes |
| Extension updating test | 44% | Yes |
| Sqllogic tests | 0% | No |
| Smaller Binary | 48% | Yes |
| Hash Zero | 10% | Yes |
| Release Assertions with Clang | 55% | Yes |
| Tests different configurations with a debug build | 41% | Yes |
| Tests non-default vector and block size | 0% | No |
| Regression Tests between safe and unsafe builds | 0% | Yes |
| Release Assertions OSX Storage | 17% | Yes |
- Total jobs is 14 where 10 use a ccache file.
- The average ccache hit rate is 17%.
For the branch
[v1.4](https://github.com/duckdb/duckdb/actions/runs/22331643758):
| job_name | ccache_hit_rate | found_ccache_file |
| --- | --- | --- |
| check-draft | N/A | N/A |
| Linux Memory Leaks | 10% | No |
| Release Assertions | 37% | Yes |
| Tests non-default vector and block size | 31% | Yes |
| Release Assertions with Clang | 100% | Yes |
| Extension updating test | 37% | Yes |
| Sqllogic tests | 11% | No |
| Smaller Binary | 100% | Yes |
| Release Assertions OSX Storage | 52% | Yes |
| Forcing async Sinks/Sources | 29% | Yes |
| Regression Tests between safe and unsafe builds | 0% | Yes |
| Storage Initialization Verification | 0% | Yes |
| Hash Zero | 31% | Yes |
| Tests different configurations with a debug build | 34% | Yes |
- Total jobs is 14 where 11 use a ccache file.
- The average ccache hit rate is 36%.
For the branch
[main](https://github.com/duckdb/duckdb/actions/runs/22331643268):
| job_name | ccache_hit_rate | found_ccache_file |
| --- | --- | --- |
| check-draft | N/A | N/A |
| Forcing async Sinks/Sources | 5% | Yes |
| Linux Memory Leaks | 0% | No |
| Storage Initialization Verification | 1% | Yes |
| Regression Tests between safe and unsafe builds | 0% | Yes |
| Sqllogic tests | 0% | No |
| Release Assertions | 3% | Yes |
| Release Assertions OSX Storage | 10% | Yes |
| Tests different configurations with a debug build | 50% | Yes |
| Hash Zero | 6% | Yes |
| Extension updating test | 39% | Yes |
| Smaller Binary | 60% | Yes |
| Release Assertions with Clang | 55% | Yes |
| Tests non-default vector and block size | 0% | No |
- Total jobs is 14 where 10 use a ccache file.
- The average ccache hit rate is 18%.
### Remove ccache action for NightlyTests
The GitHub repo cache is limited to 50 GiB. We can increase this to ~80
(max 100 GiB), however it's not something we can keep increasnig.
Looking at what is stored in the cache and why, we see that 39% of the
github repo cache is filled with entries for the ccache of the workflow
[NightlyTests](https://github.com/duckdb/duckdb/actions/workflows/NightlyTests.yml).
However, that workflow is only running once at night for the release
branches and the hit rates are low (on average 20%-36%) so they do not
give a meaningful speedup in those workflow runs.
Disabling the ccache action for that workflow can lower the github repo
cache eviction pressure and allow other ccache entries to become larger.
### Future work: Increase cache size for Main and Linux Release
Another problem is the low hit rate when a ccache file is found in a CI
job.
This can be partially explained the default maximum size of 500 MiB for
the ccache action and most CI jobs
[generate](https://github.com/duckdb/duckdb/actions/runs/22341258586/job/64646738998#step:17:5)
a ccache size of `~0.6-1.0` GiB:
```
Cacheable calls: 1208 / 1216 (99.34%)
Hits: 0 / 1208 ( 0.00%)
Direct: 0
Preprocessed: 0
Misses: 1208 / 1208 (100.0%)
Errors: 8 / 1216 ( 0.66%)
Local storage:
Cache size (GB): 1.0 / 0.5 (193.7%) # <-- 2x allowed ccache size limit
Cleanups: 1054
Hits: 0 / 1208 ( 0.00%)
Misses: 1208 / 1208 (100.0%)
```
and thus start pruning files from the ccache storage to make it fit in
the default 500 MiB cache size limit.
In the future, I'll explore when/where we should increase the ccache
cache size limit.File tree
4 files changed
+474
-11
lines changed- .github
- actions/ccache-action
- workflows
- scripts
4 files changed
+474
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| 11 | + | |
| 12 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
29 | 28 | | |
30 | 29 | | |
31 | 30 | | |
| |||
251 | 250 | | |
252 | 251 | | |
253 | 252 | | |
254 | | - | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
| 253 | + | |
259 | 254 | | |
260 | 255 | | |
261 | 256 | | |
| |||
542 | 537 | | |
543 | 538 | | |
544 | 539 | | |
545 | | - | |
546 | | - | |
547 | | - | |
548 | | - | |
549 | | - | |
| 540 | + | |
550 | 541 | | |
551 | 542 | | |
552 | 543 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
0 commit comments