microsoft / microsoft/MSBuildCache
Materialize outputs after recursively memoized cache hits
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- C#
- Star
- 64
- Fork
- 24
- Merge trung bình
- 1 ngày 14 giờ
- Pull request đã merge (30 ngày)
- 2
Mô tả
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.
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Đọc src/Common/MSBuildCachePluginBase.cs, tập trung vào đường dẫn kết quả đệ quy của ConcurrentDictionary<NodeContext, Lazy<Task>> và cách materializeOutputs được xử lý. Theo dõi các truy vấn đệ quy và trực tiếp, sau đó thêm một kiểm thử đồng thời/thứ tự mang tính tất định, bao quát các truy vấn phụ thuộc không theo thứ tự và các inner build của multi-targeting. Hoàn thành khi một kết quả đệ quy không materialize khiến các đầu ra bắt buộc được materialize đúng một lần, trong khi hành vi mặc định và hành vi không đệ quy vẫn không thay đổi.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- csharp
- Lĩnh vực
- build-system
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Ít trao đổi
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 48/100