3 ms·
> Rather than determining if the current site has been submitted by querying the Firebase/Algolia APIs with every page you visit, the extension contains regular
by ignoramous 6y ago
> Rather than determining if the current site has been submitted by querying the Firebase/Algolia APIs with every page you visit, the extension contains regularly-updating Bloom filters for all submitted HN stories to preserve user privacy.
Nice!
I built a pi-hole esque stub dns-resolver that uses Bloom Filters generated from hostfiles (60 MiB, 5M entries --> 2 MiB with 1% false positives) and it worked like a charm. At some point, I also looked into Xor Filters which are apparently even lighter and faster but couldn't find a JavaScript implementation for it [0].
I; however, stopped using Bloom Filters because its immutability meant building it over and over again which was a pain. Inverted Bloom Filters [1] or Spectral Bloom Filters [2] might have been useful since they can be updated in-place. Instead, I went for storing hostnames in a Finite State Automata [3], which while not as compact as Bloom Filters, could be updated in-place, are deterministic, and search faster. Likely not a fit for your use-case however.
PinSketches, otoh, might be a fit for accomplishing efficient set reconciliation [4] of the filters you're distributing.
[0] https://github.com/FastFilter/xorfilter#implementations-of-xor-filters-in-other-programming-languages https://github.com/FastFilter/xorfilter#implementations-of-x...
[1] https://www.youtube.com/watch?v=eIs9nJ-JFvA https://www.youtube.com/watch?v=eIs9nJ-JFvA
[2] https://pncnmnp.github.io/blogs/spectral-bloom-filters.html https://pncnmnp.github.io/blogs/spectral-bloom-filters.html
[3] http://stevehanov.ca/blog/?id=115 http://stevehanov.ca/blog/?id=115
[4] https://github.com/sipa/minisketch https://github.com/sipa/minisketch
- jstrieb 6y agoThanks for the links! I am not sure how well Xor Filters would fit here because they're meant to be immutable, whereas the extension has a content script that adds any submissions from /new or the front page to the Bloom filter so you can navigate directly back to the discussion. I had not heard of PinSketches before this, and will definitely look into them. As I mentioned in another comment: the way the project is set up, it should be possible to do a drop-in replacement with a better data structure, should one come along. Thanks!