Skip to content

Faster DNS name validation#112

Merged
djc merged 3 commits into
mainfrom
faster-name-validation
Jul 22, 2026
Merged

Faster DNS name validation#112
djc merged 3 commits into
mainfrom
faster-name-validation

Conversation

@djc

@djc djc commented Jul 22, 2026

Copy link
Copy Markdown
Member

While looking at benchmark results for

I noticed that rustls_pki_types::server_name::validate() was more expensive than I expected. Worked with Claude to optimize it (and verify that it has the same results). Criterion results from this improvement:

     Running benches/dns_name.rs (target/release/deps/dns_name-bef6433e6c7ace85)
Gnuplot not found, using plotters backend
dns_name/typical        time:   [124.84 ns 125.63 ns 126.45 ns]
                        change: [−55.558% −55.144% −54.712%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 1 outliers among 100 measurements (1.00%)
  1 (1.00%) high mild
dns_name/ip_like_rejected
                        time:   [20.163 ns 20.318 ns 20.484 ns]
                        change: [−27.528% −26.440% −25.354%] (p = 0.00 < 0.05)
                        Performance has improved.
Found 3 outliers among 100 measurements (3.00%)
  3 (3.00%) high mild
dns_name/max_length     time:   [132.86 ns 137.70 ns 143.23 ns]
                        change: [−68.711% −67.456% −66.337%] (p = 0.00 < 0.05)
                        Performance has improved.

@djc
djc requested a review from ctz July 22, 2026 09:36
@djc djc changed the title Faster name validation Faster DNS name validation Jul 22, 2026

@ctz ctz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have both the performance the formal state-machine type? What happens if we have the state machine type without the large fields?

@djc
djc force-pushed the faster-name-validation branch from 8bae56c to 5f88476 Compare July 22, 2026 13:18
@djc

djc commented Jul 22, 2026

Copy link
Copy Markdown
Member Author

Can we have both the performance the formal state-machine type? What happens if we have the state machine type without the large fields?

Here's a new version that I largely wrote myself. It's a little faster still:

dns_name/typical        time:   [101.92 ns 102.61 ns 103.32 ns]
                        change: [−63.516% −63.198% −62.871%] (p = 0.00 < 0.05)
                        Performance has improved.
dns_name/ip_like_rejected
                        time:   [14.064 ns 14.223 ns 14.412 ns]
                        change: [−46.518% −45.556% −44.498%] (p = 0.00 < 0.05)
                        Performance has improved.
dns_name/max_length     time:   [126.00 ns 126.60 ns 127.36 ns]
                        change: [−74.322% −74.016% −73.717%] (p = 0.00 < 0.05)
                        Performance has improved.

@djc
djc force-pushed the faster-name-validation branch from 5f88476 to 54c55d7 Compare July 22, 2026 13:19
@djc
djc added this pull request to the merge queue Jul 22, 2026
Merged via the queue into main with commit ef2985d Jul 22, 2026
20 checks passed
@djc
djc deleted the faster-name-validation branch July 22, 2026 15:59
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