Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

something not very well under multi threads #183

Open
starxchina opened this issue Sep 22, 2024 · 0 comments
Open

something not very well under multi threads #183

starxchina opened this issue Sep 22, 2024 · 0 comments

Comments

@starxchina
Copy link

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 {...}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant