[GH-ISSUE #2933] Optimization: remove extra buffers and encoders in TBS::new() #1093

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

Originally created by @divergentdave on GitHub (Apr 15, 2025).
Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/2933

TBS::new() creates a new Vec and BinEncoder for the RDATA of each record in the RRset it is encoding. This is done to both assert that encoding is successful and get the length of the RDATA before writing to the TBS buffer. We could eliminate these extra allocations and copies by creating a Place placeholder for the RDATA length, writing directly to the final buffer through the main encoder, and then using Place::replace() to fill in the RDATA length once we know it.

Originally created by @divergentdave on GitHub (Apr 15, 2025). Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/2933 TBS::new() creates a new `Vec` and `BinEncoder` for the RDATA of each record in the RRset it is encoding. This is done to both assert that encoding is successful and get the length of the RDATA before writing to the TBS buffer. We could eliminate these extra allocations and copies by creating a `Place` placeholder for the RDATA length, writing directly to the final buffer through the main encoder, and then using `Place::replace()` to fill in the RDATA length once we know it.
kerem closed this issue 2026-03-16 01:35:33 +03:00
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#1093
No description provided.