private void UpdateAggregations(LimitingResource limitingResource) { lock (m_lock) { int time = (int)(DateTime.UtcNow - m_lastSnapshotUtc).TotalMilliseconds; m_lastSnapshotUtc = DateTime.UtcNow; switch (limitingResource) { case LimitingResource.GraphShape: m_blockedOnGraphMs += time; break; case LimitingResource.CPU: m_blockedOnCpuMs += time; break; case LimitingResource.Disk: m_blockedOnDiskMs += time; break; case LimitingResource.Memory: m_blockedOnMemoryMs += time; break; case LimitingResource.ProjectedMemory: m_blockedOnProjectedMemoryMs += time; break; case LimitingResource.Semaphore: m_blockedOnSemaphoreMs += time; break; case LimitingResource.ConcurrencyLimit: m_blockedOnPipSynchronization += time; break; case LimitingResource.UnavailableSlots: m_blockedOnUnavailableSlotsMs += time; break; case LimitingResource.Other: m_blockedOnUnknownMs += time; break; default: Contract.Assert(false, "Unexpected LimitingResource:" + limitingResource.ToString()); throw new NotImplementedException("Unexpected Limiting Resource:" + limitingResource.ToString()); } } }
/// <summary> /// Updates the limiting resource based on observed state /// </summary> /// <param name="aggregator">Performance Aggregator</param> /// <param name="readyProcessPips">Process pips whose graph dependencies have been satisfied but are not currently executing</param> /// <param name="executinProcessPips">Number of process pips that are currently executing</param> /// <param name="lastLimitingResource">The most recent limiting worker resource</param> internal LimitingResource OnPerfSample(PerformanceCollector.Aggregator aggregator, long readyProcessPips, long executinProcessPips, WorkerResource?lastLimitingResource) { if (m_lastSnapshotUtc == DateTime.MinValue) { // We don't have a window, so don't collect this sample and just remember when the next window starts m_lastSnapshotUtc = DateTime.UtcNow; return(LimitingResource.Other); } LimitingResource limitingResource = DetermineLimitingResource(aggregator, readyProcessPips, executinProcessPips, lastLimitingResource); UpdateAggregations(limitingResource); return(limitingResource); }