Skip to content

PerformanceCounters

AshleyF edited this page Sep 16, 2020 · 2 revisions

On Windows, performance counters can be used to gather metrics similar to the diagnostics system, to be viewed in the Windows Performance Monitor (perfmon) tool.

The following counters are available on Emitters:

  • MessageCount - Total messages / second - Number of messages received per second (RateOfCountsPerSecond32)
  • MessageLatency - Message latency (microseconds) - The end-to-end latency, from originating time to the time when processing completed. (NumberOfItems32) Scheduler:

The following counters are available on Receivers:

  • Total - Total messages / second - Number of messages received per second (RateOfCountsPerSecond32)
  • Dropped - Dropped messages / second - Number of messages dropped per second (RateOfCountsPerSecond32)
  • Processed - Messages / second - Number of messages processed per second (RateOfCountsPerSecond32)
  • ProcessingTime - Processing time (ns) - The time it takes the component to process a message (NumberOfItems32)
  • PipelineExclusiveDelay - Exclusive pipeline delay (ns) - The delta between the originating time of the message and the time the message was received. (NumberOfItems32)
  • IngestTime - Ingest time (ns) - The delta between the time the message was posted and the time the message was received. (NumberOfItems32)
  • TimeInQueue - Time in queue (ns) - The time elapsed between posting of the message and beginning its processing (NumberOfItems32)
  • ProcessingDelay - Total processing delay (ns) - The time elapsed between posting of the message and completing its processing. (NumberOfItems32)
  • PipelineInclusiveDelay - Inclusive pipeline delay (ns) - The end-to-end delay, from originating time to the time when processing completed. (NumberOfItems32)
  • QueueSize - Queue size - The number of messages waiting in the delivery queue (NumberOfItems32)
  • MaxQueueSize - Max queue size - The maximum number of messages ever waiting at the same time in the delivery queue (NumberOfItems32)
  • ThrottlingRequests - Throttling requests / second - The number of throttling requests issued due to queue full, per second (RateOfCountsPerSecond32)
  • OutstandingUnrecycled - Unrecycled messages - The number of messages that are still in use by the component (NumberOfItems32)
  • AvailableRecycled - Recycled messages - The number of messages that are available for recycling (NumberOfItems32)
  • WorkitemCount - Workitem queue count - The number of work items in the global queue (NumberOfItems32)
  • EnqueuingTime - Enqueuing time - The time to enqueue a work item (NumberOfItems32)
  • DequeueingTime - Dequeuing time - The time to dequeuing a work item (NumberOfItems32)
  • EnqueueingRetries - Enqueuing retry average - The number of retries per work item enqueue operation. (AverageCount64)
  • EnqueueingCount - Enqueue count - The base counter for computing the work item enqueuing retry count. (AverageBase)
  • DequeuingRetries - Dequeuing retry average - The number of retries per work item dequeue operation. (AverageCount64)
  • DequeueingCount - Dequeue count - The base counter for computing the work item enqueuing retry count. (AverageBase)

The following are available on the Scheduler:

  • LocalToGlobalPromotions - Local-to-global promotions - The percentage of workitems promoted to the global queue (AverageCount64)
  • LocalQueueCount - Local workitem count - The number of messages in the thread-local queues (AverageBase)
  • WorkitemsPerSecond - Workitems / second - The number of workitems executed per second (RateOfCountsPerSecond32)
  • GlobalWorkitemsPerSecond - Global workitems / second - The number of workitems from the global queue executed per second (RateOfCountsPerSecond32)
  • LocalWorkitemsPerSecond - Local workitems / second - The number of workitems from the thread-local queues executed per second (RateOfCountsPerSecond32)
  • ImmediateWorkitemsPerSecond - Immediate workitems / second - The number of workitems executed synchronously without enqueuing, per second (RateOfCountsPerSecond32)
  • ActiveThreads - Active threads - The count of active threads (NumberOfItems32)

Enabling Performance Counters

These are defined in the Microsoft.Psi.Windows assembly and may be enabled on individual receivers, emitters and on the scheduler by calling EnablePerfCounters(...) passing a collection of counters to enable. For example, to enable all of the ReceiverCounters on a particular receiver:

myComponent.In.EnablePerfCounters("InterestingStream", new PerfCounters<ReceiverCounters>());

Then, run your application under admin credentials. Running as admin needs to be done only once in order to install the performance counters. You should see something like this in the console or output window:

Performance counters Microsoft Psi scheduler queue installed.
Performance counters Microsoft Psi message delivery installed.

While your app is running, open Performance Monitor (type perfmon in the Start menu or a command window). This will open MMC with the performance snapin. Under Monitoring Tools, select the Performance Monitor node. Click the green + icon, which will open the performance counter picker. From the list of available counters, find and select "Microsoft Psi message delivery", for example. The list should contain all the receivers for which you enabled perf counters, e.g. "InterestingStream" in the example above. Click the Add button at the bottom. The main window should start plotting.

Clone this wiki locally