<div dir="ltr"><div>Hi all,</div><div><br></div><div>I'm attaching a patch to optimize a speed issue introduced in version 2.86.</div><div><br></div><div>I have two ISP upstreams and need to forward different sites to different ISP's DNS providers. For example:</div><div><br></div><div>server=/<a href="http://meituan.com/114.114.114.114" target="_blank">meituan.com/114.114.114.114</a></div><div>... (lots of records)</div><div>server=/<a href="http://taobao.com/223.5.5.5" target="_blank">taobao.com/223.5.5.5</a></div><div>... (lots of records)</div><div><br></div><div>It works well before v2.86. Since v2.86 the configuration load time becomes extremely long (more than 1 minutes to load all server records). The time consuming part is inside the rewritten domain-match.c. When adding a new server record, the code will traverse all existing records so the configuration load becomes quadratic time complexity. The issue still persists on v2.88rc3.</div><div>This patch will optimize the config load time by bypassing the time consuming code block. During the config load mark_servers() will never be called so does not need to waste time on the record traversal and re-order part.</div><div><br></div><div>Before:</div><div>dnsmasq --test  77.50s user 0.30s system 99% cpu 1:17.84 total<br></div><div>After:</div><div>dnsmasq --test  0.16s user 0.02s system 99% cpu 0.188 total<br></div><div><br></div><a href="https://gist.github.com/zhouye/adfd509f51645d314f53992331449c45" target="_blank">https://gist.github.com/zhouye/adfd509f51645d314f53992331449c45</a><br><div><br></div></div>