Quantcast
Channel: xda-developers - Android Software and Hacking General [Developers Only]
Viewing all articles
Browse latest Browse all 3614

Need rom maintainer feedback: Speed up /etc/hosts processing by sorting

$
0
0
Hi,

the standard for adblocking on rooted Android phones currently is to create a huge /etc/hosts file that redirects known advertiser domains to localhost. This certainly is faster than redirecting everything through a proxy as adblock plus does, but it is still slow because android reads the entire file and compares line by line all the domains for each DNS request and the file tends to have >30.000 entries. This takes about 20ms per request on a SGS5 for a domain that is not contained in the list with the most recent adaway hosts file. It would be much faster to use a sorted hosts file instead and then do a binary search in this file. I've tried that and got a ~100x performance boost - which is noticeable.

Here's my speed results and patches for libc:
Results/discussion: https://github.com/phillipberndt/and...hosts-proposal
Proposed patch for bionic/libc: https://github.com/phillipberndt/and...e-lookup.patch

This certainly isn't something for AOSP, but I wondered if there's an interest among custom ROM devs to integrate this feature, be it with my patch or a different implementation.

Viewing all articles
Browse latest Browse all 3614

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>