Skip to content

Faster RRTYPE and CLASS parsing #6

Closed
@k0ekk0ek

Description

@k0ekk0ek

Record types are currently looked up using bsearch. While already being much better than simply iterating over all supported record types, i.e. O(log n) as opposed to O(n), this operation can be much improved. Note that lookup times increase with the addition of additional record types.

The same idea can be applied to classes. i.e. names for record classes cannot overlap with record types as no distinction between class and record can be made. Hence, a specialized lookup function can be implemented to simplify parsing the ttl+class+type trinity.

The idea is to use a best-effort one-level radix tree. Use the lower cased letter of the name to select a SIMD vector of 8x16, then use the hash of the lower cased name to identify the record type by issuing a straightforward _mm_cmpeq_epi8 (perhaps _mm_cmpeq_epi16). Then use the index to lookup the type descriptor in a properly indexed vector, much like the algorithm applied in ART (adaptive radix tree).

Preliminary tests show a performance increase of ~10% when applied to parsing the header. Note though that this mechanism will also significantly increase performance when parsing NSEC and NSEC3 record types.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is neededquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions