Skip to content

perf(rewrite): use literal replacement for path placeholders - #8545

Open
sunnysabor wants to merge 1 commit into
apache:masterfrom
sunnysabor:perf/literal-rewrite-replacement
Open

sunnysabor wants to merge 1 commit into
apache:masterfrom
sunnysabor:perf/literal-rewrite-replacement

Conversation

@sunnysabor

Copy link
Copy Markdown
Contributor

Problem and change

The Rewrite plugin calls PathMatchUtils.replaceAll for literal path placeholders. The helper quotes both inputs before calling String.replaceAll, which compiles a regular expression for each replacement. Use String.replace for the literal substitution. Regression coverage verifies repeated placeholders, a literal dot in the target, dollar signs and backslashes in the replacement, and a target that is absent. The Rewrite plugin's regular-expression branch continues to use its existing implementation.

An isolated Java 17 allocation probe using warmed loops and ThreadMXBean.getThreadAllocatedBytes measured about 1,904 B/op for the previous expression and 56 B/op for the new expression when replacing {id}/{region} in /orders/{id}/{region} with alternating 125/us and 126/eu values. This measurement covers the replacement expression only.

IssueSpec

IssueSpec-Mode: lightweight
IssueSpec-Reason: This removes regex work from literal placeholder replacement while preserving the public helper and the rewrite configuration contract.
IssueSpec-Validation: ./mvnw -B -ntp -o -pl :shenyu-plugin-rewrite -am test passed with Checkstyle. Apache RAT passed for plugin-base and rewrite. Branch diff check passed. Full repository install and deployed gateway performance tests were not run.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant