ci(docker): 层缓存改 mode=min + 固定 scope(9.52 GiB 的 buildkit 把配额吃满了) - #133
Merged
Merged
Conversation
实测:仓库缓存 9.64 GiB / 配额 10 GiB,其中 9.52 GiB 是 12 条 buildkit-blob, 全来自本工作流的 cache-to: type=gha,mode=max(无 scope)。mode=max 把每个中间层 都存一份快照,且每次构建的 blob key 都不同 → 旧快照成近重复垃圾但仍计配额; 默认 scope 又按 ref 分桶(main / PR / tag 各一份),等于把增长乘三。 症状不在 docker 上而在别的作业:LRU 先挤小缓存 —— 性能门禁的 benchmark 基线 (2.8 KB)存进去两小时就 Cache not found(issue #118 的后续),12 平台矩阵的 setup-python/pip 缓存也没了。这也是为什么 #127 给门禁补了 L3 仓内基线。 - cache-to: type=gha,mode=min,scope=tts-mm / cache-from 同 scope - 新增 tests/test_docker_cache_budget.py:只核生效行(解释注释里当然有 mode=max), 变异复验过(退回 mode=max 且去 scope → 2 条红;还原 → 2 passed) - benchmarks/README.md 的 L1 那格把"两小时被驱逐"的元凶写清(不再只报总数) Signed-off-by: ReSerendipity <zengyangc@outlook.com>
Owner
Author
手工清理已执行(owner 批准口径:删旧代、保最新)
中间那次"不降反升"是关键读数:我删完的 15 分钟里,在跑的两个 docker 构建又各写了一份 ~3.2 GiB 快照。 删掉的 14 条(
保留:12:17 那一代(3215 + 28 + 27 MiB)与全部非 buildkit 条目。 一个正向副作用:配额腾出来之后,12 平台矩阵的 合并后的观察(不属于本 PR,记下来)
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
症状不在 docker,在别的作业
issue #118 的后续:性能门禁的基线缓存存进去两小时就
Cache not found。查配额时量到:buildkit-blob-*refs/heads/mainv2.2.4tag push / main push)元凶是
docker-publish.yml的cache-to: type=gha,mode=max且不带 scope:mode=max把每个中间层都存一份,而且每次构建的 blob key 都不一样(快照含构建期元数据),于是旧快照变成没人引用但
仍计配额的近重复垃圾;默认 scope 按 ref 分桶,push / PR / tag 各存一份。
LRU 是按"最近使用"驱逐的,所以先被挤掉的是小缓存 —— benchmark 基线 2.8 KB 与 12 平台矩阵的
setup-pythonpip 缓存。这也就是 #127 必须给门禁补 L3 仓内基线的原因。改了什么
mode=min只缓存"下一步要用到的"层(base 镜像与依赖层,正是耗时的那部分),不缓存中间产物;固定
scope让所有事件共用一个桶。代价说清楚:镜像构建会比mode=max慢一些(少数中间层要重跑),换回来的是配额不再被 3 × 3.2 GiB 的快照吃掉。
tests/test_docker_cache_budget.py:核mode=min+ 两边 scope 一致且是写死的常量。只查生效行 —— 我那段解释注释里当然出现
mode=max这个字符串(第一版就被自己的注释假红过一次)。变异复验:把
cache-to退回mode=max并去掉 scope → 2 条红;还原 → 2 passed。benchmarks/README.md的 L1 那格把"两小时被驱逐"的元凶写清,不再只报总数。与手工清理的关系
这条只防复发。当前占用的 9.64 GiB 要删旧的 buildkit 条目(owner 已批:删 11:41 / 11:46 两代、
保留 11:52 那一代,预计回收 ~6.4 GiB),删除的实际结果贴在本 PR 最后一条评论。
一个观察,不属于本 PR
docker-build.yml(PR 侧的 Docker Build)没有用type=gha层缓存,所以本仓只有这一条工作流在写 buildkit 缓存;
grep -rn "type=gha" .github/workflows/现在只命中改过的这两行。守卫测试也因此只核一个步骤,并显式断言"带 cache-to 的构建步骤只有一条",多出来就会红。