From 22a03931ae46d0decc068e8d1ffe83e6187ed812 Mon Sep 17 00:00:00 2001 From: WeidiDeng Date: Sat, 24 Aug 2024 01:04:18 +0800 Subject: [PATCH] prefetch immediately if matchers requires more data and if not already prefecthed (#239) --- layer4/routes.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/layer4/routes.go b/layer4/routes.go index 9d3ff75..b8ac942 100644 --- a/layer4/routes.go +++ b/layer4/routes.go @@ -157,6 +157,10 @@ func (routes RouteList) Compile(logger *zap.Logger, matchingTimeout time.Duratio if errors.Is(err, ErrConsumedAllPrefetchedBytes) { lastNeedsMoreIdx = i routesStatus[i] = routeNeedsMore + // the first time a matcher requires more data, exit the loop to force a prefetch + if !matcherNeedMore { + break + } continue // ignore and try next route } if err != nil {