microsoft / microsoft/MSBuildCache

Materialize outputs after recursively memoized cache hits

未关闭
#167 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
C#
星标
64
派生
24
平均合并
1 天 14 小时
30 天内合并 PR
2

描述

Summary

Recursive cache results are memoized only by NodeContext, but each memoized Lazy<Task<CacheResult>> captures whether outputs should be materialized.

Impact

With MSBuildCacheGetResultsForUnqueriedDependencies=true, a recursive query that does not require outputs can populate the memoized result first. A later direct query for the same node reuses that cache hit without materializing required files, allowing MSBuild to proceed with missing reference assemblies or other outputs.

Evidence

src/Common/MSBuildCachePluginBase.cs stores recursive results in ConcurrentDictionary<NodeContext, Lazy<Task<CacheResult>>>. materializeOutputs is not part of the key or separately tracked. The implementation comments assume the node will not later be queried directly, while the setting is documented for builds that are not executed in graph order.

Suggested fix

Separate result lookup from materialization state. A direct caller requiring outputs should be able to materialize a previously memoized non-materialized hit without repeating fingerprint/cache lookup. Alternatively, include the materialization requirement in memoization while preventing duplicate result mutation.

Acceptance criteria

  • A recursive non-materializing hit followed by a direct query materializes outputs exactly once.
  • The fix covers out-of-order dependency queries and multi-targeting inner builds.
  • Default and non-recursive behavior remains unchanged.
  • A deterministic concurrency/order test covers the regression.

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

阅读 src/Common/MSBuildCachePluginBase.cs,重点关注 ConcurrentDictionary<NodeContext, Lazy<Task>> 的递归结果路径,以及 materializeOutputs 的处理方式。跟踪递归查询和直接查询,然后添加一个确定性的并发/顺序测试,覆盖乱序依赖查询和 multi-targeting 内部构建。完成标准是:一次不进行 materialize 的递归命中会使所需输出恰好 materialize 一次,同时默认行为和非递归行为保持不变。

由索引模型根据 Issue 内容生成。

评估

技术栈
csharp
领域
build-system
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
冷清
描述清晰度
基本清楚
新手友好度
48/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。