mirror of
https://github.com/hickory-dns/hickory-dns.git
synced 2026-04-25 11:15:54 +03:00
[PR #1399] [MERGED] Remove a lot of bounds checks in BinDecoder by tracking position with a second slice #2292
Labels
No labels
blocked
breaking-change
bug
bug:critical
bug:tests
cleanup
compliance
compliance
compliance
crate:all
crate:client
crate:native-tls
crate:proto
crate:recursor
crate:resolver
crate:resolver
crate:rustls
crate:server
crate:util
dependencies
docs
duplicate
easy
easy
enhance
enhance
enhance
feature:dns-over-https
feature:dns-over-quic
feature:dns-over-tls
feature:dnsssec
feature:global_lb
feature:mdns
feature:tsig
features:edns
has workaround
ops
perf
platform:WASM
platform:android
platform:fuchsia
platform:linux
platform:macos
platform:windows
pull-request
question
test
tools
tools
trust
unclear
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/hickory-dns#2292
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/hickory-dns/hickory-dns/pull/1399
Author: @saethlin
Created: 3/5/2021
Status: ✅ Merged
Merged: 3/11/2021
Merged by: @djc
Base:
main← Head:shrink-errors📝 Commits (2)
65df2d8Implement BinDecoder with a pair of slicesfdf2420pop using slice::split_first()📊 Changes
1 file changed (+27 additions, -33 deletions)
View changed files
📝
crates/proto/src/serialize/binary/decoder.rs(+27 -33)📄 Description
This branch is now awkwardly-named. It used to be a lot of changes, but I'm trickling them in one PR at a time. I don't mind the name, but I'm happy to replace the PR if y'all care.
The representation of
BinDecoderincurred an extra bounds check on every operation, which was guaranteed to succeed. Using two slices (one is the original so that it can backtrack) to represent the state removes one bounds check on every access, and this also adds an assert toread_u32andread_i32to reduce the number of bounds checks in those.This change to the representation of
BinDecoderproduces a ~19% improvement in the message-parsing code. This is not so much because the bounds checks were actually that much overhead; removing the checks shrinks the code size of manyBinDecodermethods enough that LLVM decides to inline them where it didn't before.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.