Using less memory to look up I... Note
Julia Evans

Using less memory to look up IP addresses in Mess With DNS

The author of Mess With DNS was experiencing issues with the program running out of memory and getting OOM killed, which led to problems with the backup script. To solve this, the author decided to try to make Mess With DNS use less memory. The program loads a database of IP addresses into memory, which was using around 117MB of memory. The author tried three different approaches to reduce memory usage. The first approach was to use SQLite to store the data on disk, which solved the initial memory goal but had issues with storing IPv6 addresses and was 500 times slower than the original binary search. The second approach was to use a trie, but it used more memory and was slower than the original binary search. The third approach was to make the array use less memory by deduplicating the Name and Country fields, which brought memory usage from 117MB to 65MB, and then switching to netip.Addr instead of net.IP, which saved another 20MB of memory, bringing the total to 46MB. The author was able to save 70MB of memory in total.