INNER CODE UNIT · Go

newTTFBTransport

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

func newTTFBTransport() *ttfbTransport {
	return &ttfbTransport{
		base: http.DefaultTransport,
		sk:   sketch.NewWindowedSketch(0.01, 30*time.Second),
	}
}

func (t *ttfbTransport) RoundTrip(req *http.Request) (*http.Response, error) {
	start := time.Now()
	resp, err := t.base.RoundTrip(req)
	t.sk.Add(float64(time.Since(start)))
	return resp, err
}

// staticHedgeTransport fires a hedge request after a fixed delay regardless of
// learned latency. It represents a transport miscalibrated from a TTFB sketch
// (hedge delay ≈ 1 ms = minDelay clamp) that fires a redundant request on
// virtually every call.

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…