Esempio n. 1
0
 /// <summary>
 /// Sets the max parallelism for the given queue
 /// </summary>
 public void SetMaxParallelDegreeByKind(DispatcherKind kind, int maxParallelDegree)
 {
     if (m_queuesByKind[kind].AdjustParallelDegree(maxParallelDegree) && maxParallelDegree > 0)
     {
         TriggerDispatcher();
     }
 }
 internal void Dequeued()
 {
     if (m_currentQueue != DispatcherKind.None)
     {
         var duration = DateTime.UtcNow - m_queueEnterTime;
         QueueDurations.Value[(int)m_currentQueue] += duration;
         m_currentQueue = DispatcherKind.None;
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Sets the max parallelism for the given queue
        /// </summary>
        public void SetMaxParallelDegreeByKind(DispatcherKind kind, int maxParallelDegree)
        {
            if (maxParallelDegree == 0)
            {
                // We only allow 0 for ChooseWorkerCpu and ChooseWorkerCacheLookup dispatchers.
                // For all other dispatchers, 0 is not allowed for potential deadlocks.
                if (!kind.IsChooseWorker())
                {
                    maxParallelDegree = 1;
                }
            }

            if (m_queuesByKind[kind].AdjustParallelDegree(maxParallelDegree) && maxParallelDegree > 0)
            {
                TriggerDispatcher();
            }
        }
        internal void Dequeued(bool hasWaitedForMaterializeOutputsInBackground)
        {
            if (m_currentQueue != DispatcherKind.None)
            {
                var duration = DateTime.UtcNow - m_queueEnterTime;

                if (hasWaitedForMaterializeOutputsInBackground)
                {
                    QueueWaitDurationForMaterializeOutputsInBackground = duration;
                }
                else
                {
                    QueueDurations.Value[(int)m_currentQueue] += duration;
                }

                m_currentQueue = DispatcherKind.None;
            }
        }
        protected ChooseWorkerContext(
            LoggingContext loggingContext,
            IReadOnlyList <Worker> workers,
            IPipQueue pipQueue,
            DispatcherKind kind,
            int maxParallelDegree)
        {
            Workers           = workers;
            PipQueue          = pipQueue;
            LocalWorker       = (LocalWorker)workers[0];
            LoggingContext    = loggingContext;
            Kind              = kind;
            MaxParallelDegree = maxParallelDegree;

            foreach (var worker in Workers)
            {
                worker.ResourcesChanged += OnWorkerResourcesChanged;
            }
        }
 internal void Enqueued(DispatcherKind kind)
 {
     m_currentQueue   = kind;
     m_queueEnterTime = DateTime.UtcNow;
 }
Esempio n. 7
0
 /// <inheritdoc/>
 public int GetMaxParallelDegreeByKind(DispatcherKind queueKind) => m_innerQueue.GetMaxParallelDegreeByKind(queueKind);
Esempio n. 8
0
 /// <inheritdoc/>
 public void SetMaxParallelDegreeByKind(DispatcherKind queueKind, int maxParallelDegree) => m_innerQueue.SetMaxParallelDegreeByKind(queueKind, maxParallelDegree);
Esempio n. 9
0
 /// <inheritdoc/>
 public int GetNumQueuedByKind(DispatcherKind queueKind) => m_innerQueue.GetNumQueuedByKind(queueKind);
Esempio n. 10
0
        internal void UnpauseChooseWorkerQueueIfEnqueuingNewPip(RunnablePip runnablePip, DispatcherKind nextQueue)
        {
            // If enqueuing a new highest priority pip to queue
            if (nextQueue == DispatcherKind.ChooseWorkerCpu)
            {
                if (runnablePip != m_lastIterationBlockedPip)
                {
                    TogglePauseChooseWorkerQueue(pause: false);
                }

                // Capture the sequence number which will be used to compare if ChooseWorker queue is paused
                // waiting for resources for this pip to avoid race conditions where pip cannot acquire worker
                // resources become available then queue is paused potentially indefinitely (not likely but theoretically
                // possilbe)
                runnablePip.ChooseWorkerSequenceNumber = Volatile.Read(ref WorkerEnableSequenceNumber);
            }
        }
Esempio n. 11
0
 /// <inheritdoc/>
 public int GetMaxParallelDegreeByKind(DispatcherKind kind) => m_queuesByKind[kind].MaxParallelDegree;
Esempio n. 12
0
 /// <inheritdoc/>
 public int GetNumQueuedByKind(DispatcherKind kind) => m_queuesByKind[kind].NumQueued;
Esempio n. 13
0
 /// <inheritdoc/>
 public int GetNumRunningByKind(DispatcherKind kind) => m_queuesByKind[kind].NumRunning;
Esempio n. 14
0
 /// <inheritdoc/>
 public bool IsUseWeightByKind(DispatcherKind kind) => m_queuesByKind[kind].UseWeight;
Esempio n. 15
0
 /// <inheritdoc/>
 public int GetNumAcquiredSlotsByKind(DispatcherKind kind) => m_queuesByKind[kind].NumAcquiredSlots;
Esempio n. 16
0
 /// <summary>
 /// Whether this dispatcher represents a logic for choosing a worker.
 /// </summary>
 public static bool IsChooseWorker(this DispatcherKind kind)
 {
     return(kind == DispatcherKind.ChooseWorkerLight || kind == DispatcherKind.ChooseWorkerCacheLookup || kind == DispatcherKind.ChooseWorkerCpu);
 }