Skip to content

Optimize literal host predicate matching - #4348

Open
2748109647 wants to merge 1 commit into
spring-cloud:mainfrom
2748109647:GH-4335-host-fast-path
Open

2748109647 wants to merge 1 commit into
spring-cloud:mainfrom
2748109647:GH-4335-host-fast-path

Conversation

@2748109647

Copy link
Copy Markdown

Summary

Fixes #4335.

  • Precompute literal host patterns when the route predicate is created and use a Set lookup when the route has no URI-template variables.
  • Keep ordered matching for routes containing {var} patterns, so the first matching template continues to populate URI variables as before.
  • Preserve the configured PathMatcher behavior by using the existing matcher path whenever a custom matcher is set.
  • Skip URI-template extraction for literal matches while still merging an empty variable map into the exchange.

Verification

  • ./mvnw -pl spring-cloud-gateway-server-webflux -Dtest=HostRoutePredicateFactoryTests test — 11 tests passed.
  • Checkstyle reported 0 violations during the Maven validation phase.
  • git diff --check — passed.

Signed-off-by: Alpha <2748109647@qq.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HostRoutePredicateFactory dominates CPU on large route tables: AntPathMatcher per pattern per route, host re-parsed on every call

2 participants