func (m *Measurement) getHist(op string, err error, current bool) *Histogram {
opMeasurement := m.OpSumMeasurement
if current {
opMeasurement = m.OpCurMeasurement
}
// Create hist of {op} and {op}_ERR at the same time, or else the TPM would be incorrect
opPairedKey := fmt.Sprintf("%s_ERR", op)
if err != nil {
op, opPairedKey = opPairedKey, op
}
m.RLock()
opM, ok := opMeasurement[op]
m.RUnlock()
if !ok {
opM = NewHistogram(m.MinLatency, m.MaxLatency, m.SigFigs)
opPairedM := NewHistogram(m.MinLatency, m.MaxLatency, m.SigFigs)
m.Lock()
opMeasurement[op] = opM
opMeasurement[opPairedKey] = opPairedM
m.Unlock()
}
return opM
}
there will exist data loss under multi threads in pkg/measurement/measure.go: if !ok {...}
there will exist data loss under multi threads in
pkg/measurement/measure.go
:if !ok {...}