Improving IP Address Storage in Go Programs
A recent blog post by Jeremy UVNS highlights the importance of optimizing memory usage in Go programs. The author shares their experience with storing IP addresses using less memory, reducing the program's footprint from 117MB to 46MB.
The solution involves storing ASN information in an array and using a uint32 to store the index into the array. This approach saved 50MB of memory.
Furthermore, the author discovered that Tailscale's new IP address library for Go addresses similar issues, making it easier to switch to netip.Addr, which further reduced memory usage by 20MB.
Source: https://jvns.ca/blog/2024/10/27/asn-ip-address-memory/