Skip to content

Hacking the Go compiler to efficiently map IPv4 to IPv6

7 relevance
Score Breakdown
technical depth
9
novelty
8
actionability
5
community
5
strategic
5
personal
7

Scored daily by a customisable AI persona to surface the most relevant engineering leadership news.

Deep technical hack on Go compiler for network mapping, relevant to infrastructure.

General vincent.bernat.ch
Hacking the Go compiler to efficiently map IPv4 to IPv6
Summary

netip.Addr features an Unmap() method returning the unwrapped IPv4 contained in an IPv4-mapped IPv6 address : from ::ffff:203.0.113.10 or ::ffff:cb00:710a , it returns 203.0.113.10 . 1 There is no Map() or To6() method for the reverse direction. Such a method is trivial to implement, but Go maintainers have rejected it on the grounds that users should write netip.AddrFrom16(ip.As16()) and let the compiler optimize it. 2 Today, this pattern is eight times slower than a native method. How can we teach the compiler to optimize this sequence?

Author

Vincent Bernat