dnsimple / erldns

DNS server, in Erlang.
MIT License
402 stars 98 forks source link

Use maps for named index #66

Closed urbanserj closed 6 years ago

urbanserj commented 7 years ago

I've changed data structure for named index because of performance reasons. build_named_index/2 was super slow for a zone with thousands of records. Here is a small performance test:

$ ./run.sh
> rr("include/erldns.hrl").
> R = #dns_rr{name = <<"s">>, type = 1, ttl = 3600, data = #dns_rrdata_a{ip = {127, 0, 0, 1}}}.
> RR = [ R#dns_rr{name = <<(integer_to_binary(N))/binary, ".p">>} || N <- lists:seq(0, 1000000)].
> Zone = {<<"test">>, <<>>, RR, []}.
> timer:tc(fun () -> erldns_zone_cache:put_zone(Zone) end).

I've got 12 minutes for master branch and 11 seconds for my version.

aeden commented 6 years ago

Thanks for the submission, and sorry for taking so long to get to it.