You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Refactoring]: S3-FIFO memory cache that owns its references, LRU disk cache #32274
fileservice/fifocache backs the memory, meta and disk caches:
Callers manage reference counts through callbacks, so a missed or extra callback leaks or frees a value that is still in use. The memory cache holds C.malloc memory, so that mistake corrupts memory.
Keys can be half-inserted, which every caller has to handle.
Under a parallel Set storm the memory cache stops evicting and stays at about 200% of its capacity.
On the disk cache, S3-FIFO admission is a poor fit. A file is evicted unless it is read again soon after insertion, but TPC-H re-reads a file one full round later, so files are evicted just before their reuse.
Describe the solution you'd like
Memory and meta caches: replace fifocache with a new fileservice/s3fifo package.
The cache owns each value's reference counts; callbacks only report insertions and removals.
A key becomes visible only once it is fully published.
The cache is sharded, with eviction limited to one goroutine at a time.
Memory use is bounded: past a 1/16 overshoot, a Set waits for eviction instead of skipping it.
Data disk cache: use the existing lrucache, as the index-file cache already does, with eviction callbacks run outside its lock.
Describe alternatives you've considered
Patch fifocache in place. The caller-managed reference counts and half-inserted keys are part of its API, so that doesn't remove the bug class.
Use S3-FIFO for the disk cache too. Measured: with TPC-H and wiki_all 1M alternating, it reads about twice as many objects from S3 and TPC-H runs about 27% slower than with LRU.
Activity
refactor(fileservice): S3-FIFO memory cache that owns its references,…
XuPeng-SH commentedon Nov 7, 2026
QA 交接:缓存引用所有权与淘汰策略重构
main #32275 已于 2026-11-07 01:54:31 UTC 合入,merge SHA
906848d5ef5a582b108a5bc2dc55c5006b4ec7be,最终 PR head47ad7bfac533f2a1591e7e589b8aa20d43e9ae58。已核对 issue 正文、完整空评论历史及 PR 全部 11 项讨论/评审;本问题属于产品缓存重构,不是 CI flaky。当前未发现适用于已合并范围的已验证反例或尚未完成的开发 follow-up,交 QA,保持 open。修复范围与已解决的旧项:
证据与限制:
491cd699b7c95b0e7b88bab2c7100de788548aef,复核 6 文件 follow-up 并核对其余 46 文件或删除项,复用已有 CI 和作者证据。其 fresh race 因 Go 1.27.1 下载超时而执行 0 tests,不是本轮或最终 head 的实测通过。Mergify 的最终合并记录另行显示 CI Required success 和未解决 review threads 为 0,未独立读取每个 job 原始日志。请 @Ariznawlll 重点验证:
移除研发负责人,改派唯一 Ariznawlll。转测不等于验收通过;没有自动关闭 issue 或新增 backport 要求。
XuPeng-SH commentedon Nov 7, 2026
QA 状态补充:出现尚未合并的开发 follow-up
#32345 是 #32275 / 本 issue 的新后续修复,当前仍 open、未合入 main。核对时 head 为
0b6dd9b1c488c6bd966d8e1881da29ce0dda4fd0,base 为已合并的906848d5ef5a582b108a5bc2dc55c5006b4ec7be。已读取 PR 正文、返回 patch 与全部当前讨论,以及本 issue 正文和完整评论;此前 02:02 UTC 的交接是当时的证据状态,不代表新 follow-up 已完成。作者报告合并代码中发现 7 项后续缺陷,修复范围为:后台下载保留请求 deadline 并随 DiskCache.Close 结束;8 个后台槽位占满后,已取得所需字节的读不再被后续下载失败反向判失败;超容量单个 LRU 文件优先淘汰;下载中已服务字节计入读量;内存内容写缓存不污染对象存储下载速率;只对服务端自行完整读取的 range 采样耗时;插入通知完成前不淘汰该项,避免读量记录泄漏。
PR 作者报告逐项撤销修复会使对应回归失败(Close 场景为超时),新回归及既有下载/流式测试各 100 次 race、fileservice 全包 normal 及相关 3 包 race 通过。这些是作者报告,不是本轮本地验证,也不是已合并版本的验收结论;本轮未运行 Go、race、SQL、集群或性能测试,未独立读取原始运行日志。
目前存在明确且尚未合并的开发 follow-up,不新增转测或关闭动作。issue 保持 open,现有 QA 负责人 Ariznawlll 不重复改派;请在后续验证中区分原合并范围与 #32345,待新修复合并后再按完整讨论、当前反例和回归边界重新判断。产品缓存缺陷不按 CI flaky 关闭。
fix(fileservice): bound background downloads, keep cost estimates and…
XuPeng-SH commentedon Nov 9, 2026
QA 交接补充:#32345 开发 follow-up 已合并
#32345 于 2026-11-09T01:39:40Z 合入 main,merge SHA b19ef50。此前本 issue 的“尚未合并”记录现已过时;保留现有 QA 负责人 Ariznawlll,不重复改派、不关闭,转测不代表验收通过。
本次修复后台下载 deadline/Close 生命周期、后台槽满时已成功读的结果、超容量 LRU 项优先淘汰、下载中读量与发布交错的计费、内存填充与对象存储下载速率区分、range 耗时采样及插入通知/淘汰顺序。完整讨论显示旧评审发现的 initiating capture 未计费、并发 Get 提升超大项、pending 计费和预算重验竞态、SetOldest 插入破坏超大项优先级已逐项修复;最终 2cb7435 评审 approve,未见适用于新修复的剩余已验证反例或开发 follow-up。
真实证据:作者报告各缺陷的回退负对照失败,以及 focused race/包测试通过。最终评审报告 LRU normal/race、完整 fileservice race 和 38 个 focused race 检查各 43–100 次通过。候选 fileservice normal 全包并非通过:未修改的 TestDesignDownloadFetchedOnce 因测试设置的一秒 deadline 触发允许的第二次 range 请求失败;两版本的确定性控制确认同样行为。Mergify 合并记录显示 CI Required success、未解决 review threads 为 0;未独立审计各 job 原始日志。本轮仅远端核对,未运行本地产品测试。
建议 QA 在该 merge SHA 或包含它的版本重点复核 stalled stream/Close/请求超时、8 槽占满后的成功读与后续失败、启动 SetOldest 与超大项/并发 Get/删除/淘汰交错、starter/follower 的 read-share 跨发布及立即淘汰计费、内存填充的 size/速率分离、range 失败与慢消费者采样。检查 warm entries 保留、资源释放与重复对象请求。最终评审未新增 SQL、真实远端存储或性能测试,旧性能数字不构成新版本或生产保证;这些范围仍需 QA 验证。
Ariznawlll commentedon Nov 25, 2026
已在同时包含 #32275 与 #32345 的当前 main 上完成 focused 生命周期普通/race 补测,均通过;但真实 SQL cold/warm、TPC-H SF10 + wiki_all 1M workload switch、真实远端对象存储及缓存指标尚未执行,因此本 Issue 保持 OPEN,不把本地 UT/race 写成全量验收。
实测版本与方法
568f0f4fdee3c34373f27b04316a2adf7d32a78a。906848d5ef5a582b108a5bc2dc55c5006b4ec7be、fix(fileservice): bound background downloads, keep cost estimates and read share honest #32345 mergeb19ef50f05ab0e398b65b4cf3f745470f803df09均为该 SHA 的祖先。1.27.1,GOMAXPROCS=4,-mod=readonly -count=1;普通和-race分开执行,未使用 Go test 缓存结果。实际结果
pkg/fileservice/s3fifopkg/fileservice/lrucachepkg/fileservice普通与 race 各自均为 89 个顶层测试、0 个 FAIL;含子测试各有 125 条 PASS 记录,未出现
DATA RACE或 timeout。覆盖包括:此前候选全包 normal 的历史反例
TestDesignDownloadFetchedOnce也在当前代码的普通和 race regex 中实际执行并分别 PASS;当前实现该用例的disk-download-max-extra-wait为 1 小时。这里只说明当前 focused 回执,不改写历史候选失败记录。仍未覆盖的验收边界
mo_fs_read_total、mo_fs_s3_io_bytes、cacheinuse/cap、eviction、重复下载与临时文件指标,也没有 baseline/candidate 性能对照。-count=1是最终版本 focused 回归,不等同于作者报告的 43–100 次 race 压测或完整性能验收。结论:最终 main 的 focused 生命周期普通/race 缺口已补齐;SQL、真实远端存储和原 workload-switch 证据仍缺,保持 OPEN。
Ariznawlll commentedon Dec 3, 2026
QA 测试进展更新(2026-12-03),本 Issue 保持 OPEN。
测试版本为 current main
edd86400a89a8694ee17b68bbec01b617b4e1342,macOS/arm64、Go 1.27.4,测试实例GOMAXPROCS=4。已完成并通过
cdd7e096ca6ff9af426a78460417452f471e6310。parent/current 全新集群各三轮的行数和 checksum 均正确,暖轮未重复整表回源。同对象 parent/current file-service A/B
两边分别构建同一
NewS3FS测试 harness,读取同一个 182,447,692-byte MinIO 对象,使用 512 MiB memory + 512 MiB disk cache,交错各三轮;每轮 SHA256 一致。冷轮两边均为一次完整对象 GET;两个暖缓存场景的对象 GET/bytes 均为 0。禁用 disk cache 的同对象冷读控制中位为 baseline 1.945958s、current 1.939834s,冷轮差异消失。该小信号与启用 disk cache 的路径相关,但目前不作为完整根因或普遍性能回归结论。
独立集群 SQL 对照的冷轮中位虽为 1.199298s / 0.693762s,但两边独立装载后的对象布局及实际 S3 读取量不同,因此不把该比值归因于缓存改进。
仍未满足的关闭条件
因此当前结论仅为 focused 与模拟远端定向回归通过,不关闭整个性能验收 Issue。