The second time will cause the array to be constructed, and m_singleBucketValue is populated into the array.
But within the third call, if (m_singleBucketNum == bucket) will still be true, and the metric is still added into m_singleBucketValue instead of the array.
Inside the indexer:
https://github.com/microsoft/perfview/blob/c671d460fdd4abd915a96beb1410c8c7748432fb/src/TraceEvent/Stacks/Histogram.cs#L119-L126
the m_singleBucketValue isn't used when the array is not null, causing the entry for m_singleBucketNum to be returned with incorrected value.
I don't have the whole knowledge of how Histogram is used, so I don't sure if this is really a bug. And this problem might not be a big issue due to the usage pattern, cause I don't see any bucket to be obviously wrong in the GUI.
I was looking around the source code and the following piece of code seems a bit buggy to me: https://github.com/microsoft/perfview/blob/c671d460fdd4abd915a96beb1410c8c7748432fb/src/TraceEvent/Stacks/Histogram.cs#L48-L68 Let's say the following sequence of
AddMetric
is called:The second time will cause the array to be constructed, and
m_singleBucketValue
is populated into the array. But within the third call,if (m_singleBucketNum == bucket)
will still be true, and the metric is still added intom_singleBucketValue
instead of the array. Inside the indexer: https://github.com/microsoft/perfview/blob/c671d460fdd4abd915a96beb1410c8c7748432fb/src/TraceEvent/Stacks/Histogram.cs#L119-L126 them_singleBucketValue
isn't used when the array is not null, causing the entry form_singleBucketNum
to be returned with incorrected value.I don't have the whole knowledge of how Histogram is used, so I don't sure if this is really a bug. And this problem might not be a big issue due to the usage pattern, cause I don't see any bucket to be obviously wrong in the GUI.