Skip to content

Simplify and speed up DNS name decompression

Tony Finch requested to merge 3655-decompress-faster into main

The aim is to do less work per byte:

  • Check the bounds once then call isc_ascii_lowercopy() or memmove(), instead of checking the bounds for each character and copying each character one by one.

  • To remember where the name ends, we only need to update the end marker when we see a compression pointer or when we reach the root label. There is no need to check if we jumped back and conditionally update the counter for every byte.

  • To parse a compression pointer, we no longer take a diversion around the outer loop in between reading the upper byte of the pointer and the lower byte.

  • The parser state machine is now implicit in the instruction pointer, instead of being an explicit variable. Similarly, when we reach the root label we break directly out of the loop instead of setting a second state machine variable.

Closes #3655 (closed)

Edited by Tony Finch

Merge request reports