Skip to content

tonic-xds: avoid allocations when matching domains - #2858

Open
metaphorics wants to merge 4 commits into
grpc:masterfrom
metaphorics:perf/xds-domain-matching
Open

metaphorics wants to merge 4 commits into
grpc:masterfrom
metaphorics:perf/xds-domain-matching

Conversation

@metaphorics

@metaphorics metaphorics commented Sep 9, 2026

Copy link
Copy Markdown

Removes the lowercase copies from match_domain.

Domains are compared with eq_ignore_ascii_case on the original strings, and wildcard affixes are matched through borrowed slices via checked_sub/get. Match ordering, wildcard priority, and the None-on-miss behavior are unchanged.

Also carries two Clippy fixes in tonic-xds (route_config.rs, examples/channel.rs).

Refs #2832

@YutaoMa

YutaoMa commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Thanks for the PR. The allocation optimizations lgtm, just that the Depends on https://github.com/grpc/grpc-rust/pull/2852 (measurement instrument) doesn't make sense and related change can be removed. I can help approve and merge if you drop those unrelated edits. Also it may help if you can clean up the PR description to be more concise.

@metaphorics

Copy link
Copy Markdown
Author

Surely I will clean it up. Thanks for reviewing my PR!

@metaphorics

Copy link
Copy Markdown
Author

@YutaoMa Corrected the PR.

@metaphorics

metaphorics commented Sep 16, 2026

Copy link
Copy Markdown
Author

BTW, if you are okay. Please look at #2853 too. It's a simple & quick win for performance. Doesn't break anything.

Initialize route_retry from its match expression. Keep route validation
and retry-policy parsing in the same order.

Use a checked counter in the channel example. Report counter exhaustion
instead of relying on an unbounded integer range.
Compare domain strings without creating lowercase copies. Use borrowed
byte slices for wildcard affixes and preserve ASCII case equivalence,
match priority, and the nonempty wildcard requirement.

Refs grpc#2832
@metaphorics
metaphorics force-pushed the perf/xds-domain-matching branch from 0c4578e to 1d01063 Compare September 16, 2026 06:56
Comment thread tonic-xds/src/xds/routing.rs Outdated
Route the wildcard affix comparisons in match_domain through
starts_with_ignore_ascii_case and ends_with_ignore_ascii_case,
promoting the helpers already in resource/string_matcher.rs to
pub(crate) instead of adding a second copy, and add mixed-case
wildcard unit tests.

Refs grpc#2858
@metaphorics

metaphorics commented Sep 20, 2026

Copy link
Copy Markdown
Author

@YutaoMa Done cleaning up and resolving your comments. Thx!

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.

2 participants