INNER CODE UNIT · Go

hitSigma

bhope/hedge · benchmark/streaming/main.go:82

	hitMu, hitSigma = lognParams(cacheHitMeanMs*1e6, cacheHitStdMs*1e6)
	missMu, missSigma = lognParams(cacheMissMeanMs*1e6, cacheMissStdMs*1e6)
}

func lognParams(meanNs, stdNs float64) (float64, float64) {
	cv2 := (stdNs / meanNs) * (stdNs / meanNs)
	sigma := math.Sqrt(math.Log(1 + cv2))
	mu := math.Log(meanNs) - sigma*sigma/2
	return mu, sigma
}

// sampleTTFT draws a first-token latency from the configured distribution.
func sampleTTFT() time.Duration {
	if rand.Float64() < cacheMissRate {
		return time.Duration(math.Exp(missMu + missSigma*rand.NormFloat64()))
	}
	return time.Duration(math.Exp(hitMu + hitSigma*rand.NormFloat64()))
}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…