5 ms·
Is this reasonably small enough not to cause performance issues? I notice it mentioned trying to keep the size more reasonable. Ad-blocking via hosts files can
by kup0 11y ago
Is this reasonably small enough not to cause performance issues? I notice it mentioned trying to keep the size more reasonable.
Ad-blocking via hosts files can often lead to a noticeable performance hit.
- agumonkey 11y agoI remember reading a bit on how the kernel stores the hosts list, but I stopped before finding how it scales. All I remember is that it seemed like a linear list. If it was a trie it would be alright.
- ma2rten 11y agoCompared to the overhead of a network request, the overhead of going to though even 1000 items doesn't seem that much to me.
- whorleater 11y agoWorst case you can split up the hosts file into several different files, then use gas mask[1] to toggle them individually. [1]: https://github.com/2ndalpha/gasmask https://github.com/2ndalpha/gasmask
- dredmorbius 11y agoMy Linux system runs a 60k+ /etc/hosts files, plus dnsmasq for local resolution. Nice thing about dnsmasq is that it treats domain-level entries as domain-level assignments. No measurable lag. I'd used the various blockfiles used by uBlock Origin, as well as some additional entries of my own, de-duplicated. There are some overaggressive entries, I've commented those. A nice plus: I found the dozen or so hosts/domains associated with autoplay video crap, added them, and have no more bother from that.
- rasz_pl 11y agoAt the beginning (2006) dnsmasq used very naive O(n^2) /hosts parsing procedure. I was the first person ever to attempt using dnsmasq to block ads :-) http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/2006q4/000937.html http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/200...
- dredmorbius 11y agoSweet. And if you had anything to do with the performance improvements, thank you very much.
- philip1209 11y agoYou can pay for a basic license of OpenDNS and "null route" (to a block page) ads at the device / network level. Those preferences get synced to anycasted DNS resolvers and performance hits are negligible. Some ideas here, but it's pretty straightforward and functions just like their adult content blockers: http://iradar.blogspot.com/2011/07/useful-free-tool-use-opendns-to-block.html http://iradar.blogspot.com/2011/07/useful-free-tool-use-open...
- rocky1138 11y agoI've been using this method for months if not years. I haven't noticed anything unusual about browsing speed, except that it's increased due to less ads.
- bcook 11y agoI highly doubt it. I use AdAway for Android, and my current (/system)/etc/hosts file is 58626 lines with no noticeable lag on my Nexus 7 2012 and my Nexus 9. I would assume local IO would usually beat network IO.
- GhotiFish 11y agoyou're getting downvoted, but I remember this issue cropping up for windows XP boxes. Other Operating systems and more modern versions of windows cope with large hosts lists more competently.
- bloaf 11y agoThe problem isn't completely solved, though. https://www.reddit.com/r/Windows10/comments/401h2o/hosts_file_update_is_extremely_slow/ https://www.reddit.com/r/Windows10/comments/401h2o/hosts_fil... In windows 10, the DNS Client does something that is O(n^2)
- skewart 11y agoIsn't the O(n^2) operation described in that thread happening only when the hosts file gets updated, and not with every DNS lookup? I would imagine even sequentially searching a local list of 350,000 entries, like the post describes, would still be extremely fast in the context of loading a web page. But, that said, there can be a huge difference between how one might think things should work and what actually happens.
- kup0 11y agoYeah maybe it's mostly specific to Windows. Wouldn't surprise me if that's the case. I was speaking from a Windows perspective (I should have specified).