microsoft / microsoft-performance-toolkit-sdk

Software Development Kit for the Microsoft Performance ToolKit
MIT License
156 stars 55 forks source link

Add ResourceTimeRange. #352

Open crisl-ms opened 7 months ago

crisl-ms commented 7 months ago

ResourceTimeRange

ResourceTimeRange is a new duration-like data type that is designed to compute accurately total resource usage when aggregated as Sum.

In particular, Sum aggregation of ResourceTimeRange values avoids both:

Differences from current Duration-like Data Types

Two other duration-like data types already exist in the Microsoft Performance Toolkit SDK, TimeStampDelta and TimeRange. They either overestimate or underestimate the total usage ResourceTimeRange computes, as follows:

ResourceTimeRange combines the strengths of TimeStampDelta and TimeRange while eliminating their weaknesses for the use case of computing the total resource usage.

New Data Type Details

Technically, ResourceTimeRange contains both an int resource id and a TimeRange. The resource id interpretation can vary from column to column, so that different columns in the same or different tables could perform total resource usage computation on CPUs, disks, processes, threads, etc., depending on the corresponding resource affinity/interaction interpretation of the respective entities in the rows of the table.

Like TimeRange, ResourceTimeRange is compared and presented as a TimeStampDelta, offering an alternative Sum aggregation to TimeStampDelta's plain summing of durations.

ResourceTimeRange values sum as the sum of across resources of the total duration of the union of their time intervals on the same resource. As such, they behave like TimeRange values on the same resource and like TimeStampDelta values across different resources.

ResourceTimeRange values also aggregate as Min, Max, Count, Unique Count, similar to TimeRange values.