internal void AnalyzeForCacheLookup(ProcessFingerprintComputationEventData data) { var pipId = data.PipId; using (var watch = new CacheMissTimer(pipId, this)) { // During cache-lookup, we only perform cache miss analysis for strong fingerprint misses. if (!m_pipCacheMissesDict.TryGetValue(data.PipId, out PipCacheMissInfo info) || info.CacheMissType != PipCacheMissType.MissForDescriptorsDueToStrongFingerprints) { return; } if (!IsCacheMissEligible(pipId)) { return; } Process pip = m_logTarget.GetProcess(pipId); if (!TryGetFingerprintStoreEntry(pip, out FingerprintStoreEntry oldEntry)) { return; } // WeakFingerprint must match if (!string.Equals(oldEntry.PipToFingerprintKeys.Value.WeakFingerprint, data.WeakFingerprint.Hash.ToString())) { return; } foreach (var computation in data.StrongFingerprintComputations) { if (!computation.IsStrongFingerprintHit && string.Equals(ContentHashToString(computation.PathSetHash), oldEntry.PipToFingerprintKeys.Value.PathSetHash)) { // If pathSets do match and it is a strongfingerprint miss, we can perform the cache miss analysis // First, we need to create the entry. var pipFingerprintKeys = new PipFingerprintKeys(data.WeakFingerprint, computation.ComputedStrongFingerprint, ContentHashToString(computation.PathSetHash)); var newEntry = m_logTarget.CreateFingerprintStoreEntry(pip, pipFingerprintKeys, data.WeakFingerprint, computation); Counters.IncrementCounter(FingerprintStoreCounters.CacheMissAnalysisCacheLookupAnalyzeCount); PerformCacheMissAnalysis(pip, oldEntry, newEntry, true); return; } } } }
void IExecutionLogTarget.ProcessFingerprintComputation(ProcessFingerprintComputationEventData data) { // Call old observed inputs event if (CanHandleEvent(ExecutionEventId.ObservedInputs, 0, 0)) { foreach (var strongFingerprintComputation in data.StrongFingerprintComputations) { if (strongFingerprintComputation.Succeeded) { ObservedInputs(new ObservedInputsEventData() { PipId = data.PipId, ObservedInputs = strongFingerprintComputation.ObservedInputs, }); } } } ProcessFingerprintComputed(data); }
/// <summary> /// Selects the most relevant strong fingerprint computation event to use. /// </summary> private ProcessStrongFingerprintComputationData?SelectStrongFingerprintComputationData(ProcessFingerprintComputationEventData data) { var numStrongFingerprints = data.StrongFingerprintComputations.Count; if (numStrongFingerprints == 0) { return(null); } // There are two cases when fingerprints are put into the store: // // Case 1: If processing a strong fingerprint computed for cache lookup (cache hit, cache misses are ignored until execution), // cache lookup automatically stops on the strong fingerprint match, so the last strong fingerprint is the fingerprint used // // Case 2: If processing a strong fingerprint computed for execution (cache miss), // there should only be one strong fingerprint, so the last strong fingerprint is the fingerprint used return(data.StrongFingerprintComputations[numStrongFingerprints - 1]); }
/// <summary> /// Handler for <see cref="IExecutionLogTarget.ProcessFingerprintComputation"/> event /// </summary> public virtual void ProcessFingerprintComputed(ProcessFingerprintComputationEventData data) { ReportUnhandledEvent(data); }