CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 82
Performance: single char hash for ubiquitous hostnames in matrix filtering #259
Description
HTTP Switchboard is already significantly more efficient than all popular blockers memory and CPU wise. However this does not mean I should stop looking for further improvement.
Hostnames in liquid-dict.js are indexed using a 6- to 7-character string hash. This works toward reducing memory footprint given that out-of-the box, there are nearly 60,000 distinct hostnames in this dictionary (one dict entry can contains many hostnames).
Since a while, I've been entertaining the idea of hashing into a single (unicode) character, as this would benefit both memory and CPU efficiency, but I needed a prototype to roughly validate the idea.
So I now have a prototype, and it shows that this works, and there is a gain in both CPU and memory footprint (see https://jsperf.com/makekey-concat-vs-join/3 for the CPU aspect).
Current limitation of the new hashing function is that a hostname can't be longer than 255 characters (if it ever become an issue, worst-case is to generate a two-char hash instead of one-char).