net: IPv4 String method is not efficient and could be improved #24306
Labels
FrozenDueToAge
NeedsFix
The path to resolution is known, but the work has not been done.
Performance
Milestone
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?1.9, 1.10
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?darwin_amd64, linux_amd64
What did you do?
Converted ip.net to human readable string, namely called net.IP.String(). On a scale 1000 IPs, pprof reported it as a one of the most expensive operation.
String representation is often used as a key in map containers, for stringset but pprof will show again that this is a most expensive operation and you will need to provide some custom converter from net.IP to key as a [4]byte or [16]byte.
If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
What did you expect to see?
A better, more efficient implementation
What did you see instead?
A very expensive operation and custom is much more efficient.
The text was updated successfully, but these errors were encountered: