microsoft / microsoft/MSBuildCache

Materialize outputs after recursively memoized cache hits

Aperta
#167 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
C#
Stelle
64
Fork
24
Merge medio
1g 14h
PR unite (30g)
2

Descrizione

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.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Leggi src/Common/MSBuildCachePluginBase.cs, concentrandoti sul percorso dei risultati ricorsivi di ConcurrentDictionary<NodeContext, Lazy<Task>> e sulla gestione di materializeOutputs. Traccia le risultati delle query ricorsive e dirette, quindi aggiungi un test deterministico di concorrenza/ordine che copra query delle dipendenze fuori ordine e inner build di multi-targeting. Il lavoro è completato quando un hit ricorsivo che non esegue la materializzazione fa sì che gli output richiesti vengano materializzati esattamente una volta, mentre il comportamento predefinito e quello non ricorsivo rimangono invariati.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
csharp
Ambito
build-system
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Tranquilla
Chiarezza
Abbastanza chiara
Idoneità per principianti
48/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.