Class PoolStatistics
Provides statistics about the current state of a tensor pool. Use this class to monitor pool usage and tune pooling parameters.
public class PoolStatistics
- Inheritance
-
PoolStatistics
- Inherited Members
Remarks
Pool statistics help you understand: - How much memory is currently being used by pooled tensors - How many tensors are available for reuse - Whether the pool is operating efficiently
Example usage:
var pool = new TensorPool<float>();
// ... use the pool for inference operations ...
var stats = pool.GetStatistics();
Console.WriteLine($"Pool using {stats.MemoryUtilizationPercent:F1}% of max capacity");
Console.WriteLine($"Tensors in pool: {stats.PooledTensorCount}");
Properties
CurrentMemoryBytes
Gets or sets the total memory currently used by pooled tensors, in bytes.
public long CurrentMemoryBytes { get; set; }
Property Value
- long
The current memory usage in bytes.
Remarks
This value represents the memory reserved for pooled tensors. It does not include tensors that have been rented and are currently in use.
MaxMemoryBytes
Gets or sets the maximum memory allowed for pooling, in bytes. This corresponds to MaxPoolSizeBytes.
public long MaxMemoryBytes { get; set; }
Property Value
- long
The maximum pool memory capacity in bytes.
MemoryUtilizationPercent
Gets the percentage of maximum pool memory currently in use.
public double MemoryUtilizationPercent { get; }
Property Value
- double
A value from 0 to 100 representing memory utilization percentage. Returns 0 if MaxMemoryBytes is 0.
Remarks
Use this metric to determine if your pool size is appropriate: - Values consistently near 100% suggest increasing MaxPoolSizeMB - Values consistently near 0% suggest decreasing the pool size to save memory - Values between 40-80% typically indicate good pool sizing
PooledTensorCount
Gets or sets the number of tensors currently held in the pool. These tensors are available for immediate reuse without allocation.
public int PooledTensorCount { get; set; }
Property Value
- int
The count of pooled tensors across all shape buckets.
TensorBuckets
Gets or sets the number of shape buckets in the pool. Each unique tensor shape has its own bucket for storing reusable tensors.
public int TensorBuckets { get; set; }
Property Value
- int
The number of distinct shape buckets.
Remarks
A high number of buckets may indicate many different tensor shapes in use, which can reduce pooling effectiveness. Consider standardizing tensor shapes when possible to improve reuse rates.