[GH-ISSUE #3240] LowerName and LowerQuery may be redundant #1158

Closed
opened 2026-03-16 01:45:35 +03:00 by kerem · 2 comments
Owner

Originally created by @divergentdave on GitHub (Aug 28, 2025).
Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/3240

LowerName is similar to Name, and is in fact a newtype around Name, with its new() constructor converting names to lowercase. At this point, <Name as Ord> uses case-insensitive comparison, so converting to lowercase only has superficial impacts when displaying the name, etc. Similarly, LowerQuery wraps a LowerName and a Query, with the invariant that the name field is the lowercase form of the query's name. There is a comment that "LowerQuery is intended to reduce complexity for lookups in authorities", but I think that this is no longer the case, since all Name comparisons are case-insensitive. We could likely remove both wrappers, saving us from doing some conversions and eliminating some extra copies.

Originally created by @divergentdave on GitHub (Aug 28, 2025). Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/3240 `LowerName` is similar to `Name`, and is in fact a newtype around `Name`, with its `new()` constructor converting names to lowercase. At this point, `<Name as Ord>` uses case-insensitive comparison, so converting to lowercase only has superficial impacts when displaying the name, etc. Similarly, `LowerQuery` wraps a `LowerName` and a `Query`, with the invariant that the name field is the lowercase form of the query's name. There is a comment that "LowerQuery is intended to reduce complexity for lookups in authorities", but I think that this is no longer the case, since all `Name` comparisons are case-insensitive. We could likely remove both wrappers, saving us from doing some conversions and eliminating some extra copies.
kerem closed this issue 2026-03-16 01:45:41 +03:00
Author
Owner

@bluejekyll commented on GitHub (Sep 3, 2025):

The reason I added LowerName was for performance. Given all the Name comparisons in the code, use a case-sensitive comparison vs. a case-insensitive comparison has a noticeable impact to micro-benchmark performance, and overall I think accounted for something on the order of a 10% boost in request latency.

<!-- gh-comment-id:3250795017 --> @bluejekyll commented on GitHub (Sep 3, 2025): The reason I added LowerName was for performance. Given all the Name comparisons in the code, use a case-sensitive comparison vs. a case-insensitive comparison has a noticeable impact to micro-benchmark performance, and overall I think accounted for something on the order of a 10% boost in request latency.
Author
Owner

@divergentdave commented on GitHub (Sep 4, 2025):

Ah, that makes sense. I ran the benchmarks in the proto crate, and I get similar results.

<!-- gh-comment-id:3254380419 --> @divergentdave commented on GitHub (Sep 4, 2025): Ah, that makes sense. I ran the benchmarks in the proto crate, and I get similar results.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hickory-dns#1158
No description provided.