plugin/forward: fast-path string comparison in isAllowedDomain (#8385)

* test: add benchmark cases for Request IP/Port and parseRequest

Signed-off-by: Manuel Rüger <manuel@rueg.eu>

* test(kubernetes): add BenchmarkServices and BenchmarkServicesHeadless

Signed-off-by: Manuel Rüger <manuel@rueg.eu>

* perf(forward): fast-path string comparison in isAllowedDomain

Signed-off-by: Manuel Rüger <manuel@rueg.eu>

---------

Signed-off-by: Manuel Rüger <manuel@rueg.eu>
This commit is contained in:
Manuel Rüger
2026-08-04 03:44:27 +02:00
committed by GitHub
parent d74404f8ac
commit a1642a64dc
3 changed files with 57 additions and 0 deletions

View File

@@ -381,3 +381,23 @@ func TestRequestClear(t *testing.T) {
t.Errorf("Expected st.port to be cleared after Clear")
}
}
func BenchmarkRequestIP(b *testing.B) {
st := testRequest()
b.ReportAllocs()
for b.Loop() {
st.Clear()
_ = st.IP()
}
}
func BenchmarkRequestPort(b *testing.B) {
st := testRequest()
b.ReportAllocs()
for b.Loop() {
st.Clear()
_ = st.Port()
}
}