aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Anthony Knyszek <mknyszek@google.com>2024-04-05 22:08:02 +0000
committerMichael Knyszek <mknyszek@google.com>2024-04-22 18:14:15 +0000
commit79065f0a5eb48534142ed01d569e742b60a13f34 (patch)
treee416f4af4774ef989ad3e0665af039c4fc2f6f5f
parenta088e230d4e7892b15851babe161bbd1766738a1 (diff)
downloadgo-79065f0a5eb48534142ed01d569e742b60a13f34.tar.gz
go-79065f0a5eb48534142ed01d569e742b60a13f34.zip
net/netip: use the unique package instead of internal/intern
This change replaces net/netip's use of the internal/intern package with the new unique package. Below are the benchmark results for the package. Lots of things get faster, but some things get slower. The single-core performance of unique.Make is expected to be a tad slower than internal/intern, but is vastly more scalable. No benchmark in this package currently demonstrates this, however. │ before.bench │ after.bench │ │ sec/op │ sec/op vs base │ IPNextPrev-48 85.66n ± ∞ ¹ 85.61n ± ∞ ¹ ~ (p=0.690 n=5) BinaryMarshalRoundTrip/ipv4-48 16.12n ± ∞ ¹ 15.84n ± ∞ ¹ -1.74% (p=0.008 n=5) BinaryMarshalRoundTrip/ipv6-48 33.14n ± ∞ ¹ 32.49n ± ∞ ¹ -1.96% (p=0.016 n=5) BinaryMarshalRoundTrip/ipv6+zone-48 88.84n ± ∞ ¹ 101.50n ± ∞ ¹ +14.25% (p=0.008 n=5) StdIPv4-48 126.6n ± ∞ ¹ 157.2n ± ∞ ¹ +24.17% (p=0.008 n=5) IPv4-48 101.2n ± ∞ ¹ 101.0n ± ∞ ¹ ~ (p=0.452 n=5) IPv4_inline-48 131.7n ± ∞ ¹ 101.2n ± ∞ ¹ -23.16% (p=0.008 n=5) StdIPv6-48 180.6n ± ∞ ¹ 178.7n ± ∞ ¹ -1.05% (p=0.040 n=5) IPv6-48 136.7n ± ∞ ¹ 137.4n ± ∞ ¹ ~ (p=0.135 n=5) IPv4Contains-48 4.650n ± ∞ ¹ 5.287n ± ∞ ¹ +13.70% (p=0.008 n=5) IPv6Contains-48 5.284n ± ∞ ¹ 5.290n ± ∞ ¹ ~ (p=0.540 n=5) ParseAddr/v4-48 23.94n ± ∞ ¹ 23.62n ± ∞ ¹ ~ (p=0.841 n=5) ParseAddr/v6-48 84.95n ± ∞ ¹ 80.64n ± ∞ ¹ -5.07% (p=0.008 n=5) ParseAddr/v6_ellipsis-48 51.54n ± ∞ ¹ 51.62n ± ∞ ¹ ~ (p=1.000 n=5) ParseAddr/v6_v4-48 55.85n ± ∞ ¹ 56.56n ± ∞ ¹ +1.27% (p=0.008 n=5) ParseAddr/v6_zone-48 110.0n ± ∞ ¹ 124.6n ± ∞ ¹ +13.27% (p=0.008 n=5) StdParseIP/v4-48 54.05n ± ∞ ¹ 53.74n ± ∞ ¹ -0.57% (p=0.016 n=5) StdParseIP/v6-48 111.6n ± ∞ ¹ 111.7n ± ∞ ¹ ~ (p=0.651 n=5) StdParseIP/v6_ellipsis-48 81.81n ± ∞ ¹ 82.15n ± ∞ ¹ +0.42% (p=0.008 n=5) StdParseIP/v6_v4-48 89.36n ± ∞ ¹ 90.72n ± ∞ ¹ +1.52% (p=0.008 n=5) StdParseIP/v6_zone-48 138.7n ± ∞ ¹ 150.7n ± ∞ ¹ +8.65% (p=0.008 n=5) AddrString/v4-48 36.43n ± ∞ ¹ 36.33n ± ∞ ¹ ~ (p=0.508 n=5) AddrString/v6-48 106.1n ± ∞ ¹ 102.5n ± ∞ ¹ -3.39% (p=0.008 n=5) AddrString/v6_ellipsis-48 93.93n ± ∞ ¹ 92.87n ± ∞ ¹ -1.13% (p=0.008 n=5) AddrString/v6_v4-48 43.09n ± ∞ ¹ 43.33n ± ∞ ¹ ~ (p=0.111 n=5) AddrString/v6_zone-48 91.15n ± ∞ ¹ 89.22n ± ∞ ¹ -2.12% (p=0.008 n=5) IPStringExpanded/v4-48 37.99n ± ∞ ¹ 37.77n ± ∞ ¹ -0.58% (p=0.032 n=5) IPStringExpanded/v6-48 63.59n ± ∞ ¹ 63.58n ± ∞ ¹ ~ (p=0.690 n=5) IPStringExpanded/v6_ellipsis-48 64.33n ± ∞ ¹ 63.50n ± ∞ ¹ -1.29% (p=0.024 n=5) IPStringExpanded/v6_v4-48 64.79n ± ∞ ¹ 63.08n ± ∞ ¹ -2.64% (p=0.008 n=5) IPStringExpanded/v6_zone-48 111.7n ± ∞ ¹ 109.7n ± ∞ ¹ -1.79% (p=0.016 n=5) AddrMarshalText/v4-48 34.45n ± ∞ ¹ 34.04n ± ∞ ¹ ~ (p=0.151 n=5) AddrMarshalText/v6-48 105.2n ± ∞ ¹ 102.6n ± ∞ ¹ -2.47% (p=0.008 n=5) AddrMarshalText/v6_ellipsis-48 99.69n ± ∞ ¹ 98.56n ± ∞ ¹ ~ (p=0.151 n=5) AddrMarshalText/v6_v4-48 48.22n ± ∞ ¹ 47.33n ± ∞ ¹ ~ (p=0.151 n=5) AddrMarshalText/v6_zone-48 98.55n ± ∞ ¹ 94.82n ± ∞ ¹ -3.78% (p=0.008 n=5) AddrPortString/v4-48 59.03n ± ∞ ¹ 50.09n ± ∞ ¹ -15.14% (p=0.008 n=5) AddrPortString/v6-48 118.2n ± ∞ ¹ 113.3n ± ∞ ¹ -4.15% (p=0.008 n=5) AddrPortString/v6_ellipsis-48 110.1n ± ∞ ¹ 107.3n ± ∞ ¹ -2.54% (p=0.008 n=5) AddrPortString/v6_v4-48 66.48n ± ∞ ¹ 58.80n ± ∞ ¹ -11.55% (p=0.008 n=5) AddrPortString/v6_zone-48 106.7n ± ∞ ¹ 104.9n ± ∞ ¹ -1.69% (p=0.008 n=5) AddrPortMarshalText/v4-48 56.67n ± ∞ ¹ 54.19n ± ∞ ¹ -4.38% (p=0.008 n=5) AddrPortMarshalText/v6-48 125.1n ± ∞ ¹ 122.1n ± ∞ ¹ -2.40% (p=0.008 n=5) AddrPortMarshalText/v6_ellipsis-48 120.1n ± ∞ ¹ 118.0n ± ∞ ¹ -1.75% (p=0.024 n=5) AddrPortMarshalText/v6_v4-48 71.53n ± ∞ ¹ 70.25n ± ∞ ¹ ~ (p=0.548 n=5) AddrPortMarshalText/v6_zone-48 116.4n ± ∞ ¹ 114.0n ± ∞ ¹ -2.06% (p=0.016 n=5) PrefixMasking/IPv4_/32-48 5.259n ± ∞ ¹ 5.289n ± ∞ ¹ +0.57% (p=0.016 n=5) PrefixMasking/IPv4_/17-48 5.286n ± ∞ ¹ 5.284n ± ∞ ¹ ~ (p=0.937 n=5) PrefixMasking/IPv4_/0-48 5.266n ± ∞ ¹ 5.280n ± ∞ ¹ ~ (p=0.151 n=5) PrefixMasking/IPv6_/128-48 5.271n ± ∞ ¹ 5.284n ± ∞ ¹ ~ (p=0.151 n=5) PrefixMasking/IPv6_/65-48 5.256n ± ∞ ¹ 5.282n ± ∞ ¹ ~ (p=0.317 n=5) PrefixMasking/IPv6_/0-48 5.253n ± ∞ ¹ 5.284n ± ∞ ¹ ~ (p=0.095 n=5) PrefixMasking/IPv6_zone_/128-48 5.274n ± ∞ ¹ 5.284n ± ∞ ¹ ~ (p=0.222 n=5) PrefixMasking/IPv6_zone_/65-48 5.280n ± ∞ ¹ 5.291n ± ∞ ¹ ~ (p=0.095 n=5) PrefixMasking/IPv6_zone_/0-48 5.283n ± ∞ ¹ 5.292n ± ∞ ¹ ~ (p=0.095 n=5) PrefixMarshalText-48 44.60n ± ∞ ¹ 44.81n ± ∞ ¹ ~ (p=1.000 n=5) ParseAddrPort/v4-48 46.40n ± ∞ ¹ 41.27n ± ∞ ¹ -11.06% (p=0.008 n=5) ParseAddrPort/v6-48 106.90n ± ∞ ¹ 99.29n ± ∞ ¹ -7.12% (p=0.008 n=5) ParseAddrPort/v6_ellipsis-48 77.10n ± ∞ ¹ 69.98n ± ∞ ¹ -9.23% (p=0.008 n=5) ParseAddrPort/v6_v4-48 71.82n ± ∞ ¹ 74.97n ± ∞ ¹ +4.39% (p=0.008 n=5) ParseAddrPort/v6_zone-48 130.0n ± ∞ ¹ 148.5n ± ∞ ¹ +14.23% (p=0.008 n=5) As16-48 7.446n ± ∞ ¹ 7.437n ± ∞ ¹ ~ (p=0.286 n=5) geomean 45.52n 45.18n -0.76% ¹ need >= 6 samples for confidence interval at level 0.95 │ before.bench │ after.bench │ │ B/op │ B/op vs base │ StdIPv4-48 16.00 ± ∞ ¹ 16.00 ± ∞ ¹ ~ (p=1.000 n=5) ² IPv4-48 0.000 ± ∞ ¹ 0.000 ± ∞ ¹ ~ (p=1.000 n=5) ² IPv4_inline-48 0.000 ± ∞ ¹ 0.000 ± ∞ ¹ ~ (p=1.000 n=5) ² StdIPv6-48 16.00 ± ∞ ¹ 16.00 ± ∞ ¹ ~ (p=1.000 n=5) ² IPv6-48 0.000 ± ∞ ¹ 0.000 ± ∞ ¹ ~ (p=1.000 n=5) ² IPv4Contains-48 0.000 ± ∞ ¹ 0.000 ± ∞ ¹ ~ (p=1.000 n=5) ² IPv6Contains-48 0.000 ± ∞ ¹ 0.000 ± ∞ ¹ ~ (p=1.000 n=5) ² ParseAddr/v4-48 0.000 ± ∞ ¹ 0.000 ± ∞ ¹ ~ (p=1.000 n=5) ² ParseAddr/v6-48 0.000 ± ∞ ¹ 0.000 ± ∞ ¹ ~ (p=1.000 n=5) ² ParseAddr/v6_ellipsis-48 0.000 ± ∞ ¹ 0.000 ± ∞ ¹ ~ (p=1.000 n=5) ² ParseAddr/v6_v4-48 0.000 ± ∞ ¹ 0.000 ± ∞ ¹ ~ (p=1.000 n=5) ² ParseAddr/v6_zone-48 0.000 ± ∞ ¹ 0.000 ± ∞ ¹ ~ (p=1.000 n=5) ² StdParseIP/v4-48 16.00 ± ∞ ¹ 16.00 ± ∞ ¹ ~ (p=1.000 n=5) ² StdParseIP/v6-48 16.00 ± ∞ ¹ 16.00 ± ∞ ¹ ~ (p=1.000 n=5) ² StdParseIP/v6_ellipsis-48 16.00 ± ∞ ¹ 16.00 ± ∞ ¹ ~ (p=1.000 n=5) ² StdParseIP/v6_v4-48 16.00 ± ∞ ¹ 16.00 ± ∞ ¹ ~ (p=1.000 n=5) ² StdParseIP/v6_zone-48 16.00 ± ∞ ¹ 16.00 ± ∞ ¹ ~ (p=1.000 n=5) ² AddrString/v4-48 16.00 ± ∞ ¹ 16.00 ± ∞ ¹ ~ (p=1.000 n=5) ² AddrString/v6-48 48.00 ± ∞ ¹ 48.00 ± ∞ ¹ ~ (p=1.000 n=5) ² AddrString/v6_ellipsis-48 24.00 ± ∞ ¹ 24.00 ± ∞ ¹ ~ (p=1.000 n=5) ² AddrString/v6_v4-48 24.00 ± ∞ ¹ 24.00 ± ∞ ¹ ~ (p=1.000 n=5) ² AddrString/v6_zone-48 24.00 ± ∞ ¹ 24.00 ± ∞ ¹ ~ (p=1.000 n=5) ² IPStringExpanded/v4-48 16.00 ± ∞ ¹ 16.00 ± ∞ ¹ ~ (p=1.000 n=5) ² IPStringExpanded/v6-48 48.00 ± ∞ ¹ 48.00 ± ∞ ¹ ~ (p=1.000 n=5) ² IPStringExpanded/v6_ellipsis-48 48.00 ± ∞ ¹ 48.00 ± ∞ ¹ ~ (p=1.000 n=5) ² IPStringExpanded/v6_v4-48 48.00 ± ∞ ¹ 48.00 ± ∞ ¹ ~ (p=1.000 n=5) ² IPStringExpanded/v6_zone-48 128.0 ± ∞ ¹ 128.0 ± ∞ ¹ ~ (p=1.000 n=5) ² AddrMarshalText/v4-48 16.00 ± ∞ ¹ 16.00 ± ∞ ¹ ~ (p=1.000 n=5) ² AddrMarshalText/v6-48 48.00 ± ∞ ¹ 48.00 ± ∞ ¹ ~ (p=1.000 n=5) ² AddrMarshalText/v6_ellipsis-48 48.00 ± ∞ ¹ 48.00 ± ∞ ¹ ~ (p=1.000 n=5) ² AddrMarshalText/v6_v4-48 32.00 ± ∞ ¹ 32.00 ± ∞ ¹ ~ (p=1.000 n=5) ² AddrMarshalText/v6_zone-48 48.00 ± ∞ ¹ 48.00 ± ∞ ¹ ~ (p=1.000 n=5) ² AddrPortString/v4-48 24.00 ± ∞ ¹ 24.00 ± ∞ ¹ ~ (p=1.000 n=5) ² AddrPortString/v6-48 48.00 ± ∞ ¹ 48.00 ± ∞ ¹ ~ (p=1.000 n=5) ² AddrPortString/v6_ellipsis-48 32.00 ± ∞ ¹ 32.00 ± ∞ ¹ ~ (p=1.000 n=5) ² AddrPortString/v6_v4-48 32.00 ± ∞ ¹ 32.00 ± ∞ ¹ ~ (p=1.000 n=5) ² AddrPortString/v6_zone-48 32.00 ± ∞ ¹ 32.00 ± ∞ ¹ ~ (p=1.000 n=5) ² AddrPortMarshalText/v4-48 24.00 ± ∞ ¹ 24.00 ± ∞ ¹ ~ (p=1.000 n=5) ² AddrPortMarshalText/v6-48 64.00 ± ∞ ¹ 64.00 ± ∞ ¹ ~ (p=1.000 n=5) ² AddrPortMarshalText/v6_ellipsis-48 64.00 ± ∞ ¹ 64.00 ± ∞ ¹ ~ (p=1.000 n=5) ² AddrPortMarshalText/v6_v4-48 64.00 ± ∞ ¹ 64.00 ± ∞ ¹ ~ (p=1.000 n=5) ² AddrPortMarshalText/v6_zone-48 64.00 ± ∞ ¹ 64.00 ± ∞ ¹ ~ (p=1.000 n=5) ² PrefixMasking/IPv4_/32-48 0.000 ± ∞ ¹ 0.000 ± ∞ ¹ ~ (p=1.000 n=5) ² PrefixMasking/IPv4_/17-48 0.000 ± ∞ ¹ 0.000 ± ∞ ¹ ~ (p=1.000 n=5) ² PrefixMasking/IPv4_/0-48 0.000 ± ∞ ¹ 0.000 ± ∞ ¹ ~ (p=1.000 n=5) ² PrefixMasking/IPv6_/128-48 0.000 ± ∞ ¹ 0.000 ± ∞ ¹ ~ (p=1.000 n=5) ² PrefixMasking/IPv6_/65-48 0.000 ± ∞ ¹ 0.000 ± ∞ ¹ ~ (p=1.000 n=5) ² PrefixMasking/IPv6_/0-48 0.000 ± ∞ ¹ 0.000 ± ∞ ¹ ~ (p=1.000 n=5) ² PrefixMasking/IPv6_zone_/128-48 0.000 ± ∞ ¹ 0.000 ± ∞ ¹ ~ (p=1.000 n=5) ² PrefixMasking/IPv6_zone_/65-48 0.000 ± ∞ ¹ 0.000 ± ∞ ¹ ~ (p=1.000 n=5) ² PrefixMasking/IPv6_zone_/0-48 0.000 ± ∞ ¹ 0.000 ± ∞ ¹ ~ (p=1.000 n=5) ² PrefixMarshalText-48 24.00 ± ∞ ¹ 24.00 ± ∞ ¹ ~ (p=1.000 n=5) ² ParseAddrPort/v4-48 0.000 ± ∞ ¹ 0.000 ± ∞ ¹ ~ (p=1.000 n=5) ² ParseAddrPort/v6-48 0.000 ± ∞ ¹ 0.000 ± ∞ ¹ ~ (p=1.000 n=5) ² ParseAddrPort/v6_ellipsis-48 0.000 ± ∞ ¹ 0.000 ± ∞ ¹ ~ (p=1.000 n=5) ² ParseAddrPort/v6_v4-48 0.000 ± ∞ ¹ 0.000 ± ∞ ¹ ~ (p=1.000 n=5) ² ParseAddrPort/v6_zone-48 0.000 ± ∞ ¹ 0.000 ± ∞ ¹ ~ (p=1.000 n=5) ² geomean ³ +0.00% ³ ¹ need >= 6 samples for confidence interval at level 0.95 ² all samples are equal ³ summaries must be >0 to compute geomean │ before.bench │ after.bench │ │ allocs/op │ allocs/op vs base │ StdIPv4-48 1.000 ± ∞ ¹ 1.000 ± ∞ ¹ ~ (p=1.000 n=5) ² IPv4-48 0.000 ± ∞ ¹ 0.000 ± ∞ ¹ ~ (p=1.000 n=5) ² IPv4_inline-48 0.000 ± ∞ ¹ 0.000 ± ∞ ¹ ~ (p=1.000 n=5) ² StdIPv6-48 1.000 ± ∞ ¹ 1.000 ± ∞ ¹ ~ (p=1.000 n=5) ² IPv6-48 0.000 ± ∞ ¹ 0.000 ± ∞ ¹ ~ (p=1.000 n=5) ² IPv4Contains-48 0.000 ± ∞ ¹ 0.000 ± ∞ ¹ ~ (p=1.000 n=5) ² IPv6Contains-48 0.000 ± ∞ ¹ 0.000 ± ∞ ¹ ~ (p=1.000 n=5) ² ParseAddr/v4-48 0.000 ± ∞ ¹ 0.000 ± ∞ ¹ ~ (p=1.000 n=5) ² ParseAddr/v6-48 0.000 ± ∞ ¹ 0.000 ± ∞ ¹ ~ (p=1.000 n=5) ² ParseAddr/v6_ellipsis-48 0.000 ± ∞ ¹ 0.000 ± ∞ ¹ ~ (p=1.000 n=5) ² ParseAddr/v6_v4-48 0.000 ± ∞ ¹ 0.000 ± ∞ ¹ ~ (p=1.000 n=5) ² ParseAddr/v6_zone-48 0.000 ± ∞ ¹ 0.000 ± ∞ ¹ ~ (p=1.000 n=5) ² StdParseIP/v4-48 1.000 ± ∞ ¹ 1.000 ± ∞ ¹ ~ (p=1.000 n=5) ² StdParseIP/v6-48 1.000 ± ∞ ¹ 1.000 ± ∞ ¹ ~ (p=1.000 n=5) ² StdParseIP/v6_ellipsis-48 1.000 ± ∞ ¹ 1.000 ± ∞ ¹ ~ (p=1.000 n=5) ² StdParseIP/v6_v4-48 1.000 ± ∞ ¹ 1.000 ± ∞ ¹ ~ (p=1.000 n=5) ² StdParseIP/v6_zone-48 1.000 ± ∞ ¹ 1.000 ± ∞ ¹ ~ (p=1.000 n=5) ² AddrString/v4-48 1.000 ± ∞ ¹ 1.000 ± ∞ ¹ ~ (p=1.000 n=5) ² AddrString/v6-48 1.000 ± ∞ ¹ 1.000 ± ∞ ¹ ~ (p=1.000 n=5) ² AddrString/v6_ellipsis-48 1.000 ± ∞ ¹ 1.000 ± ∞ ¹ ~ (p=1.000 n=5) ² AddrString/v6_v4-48 1.000 ± ∞ ¹ 1.000 ± ∞ ¹ ~ (p=1.000 n=5) ² AddrString/v6_zone-48 1.000 ± ∞ ¹ 1.000 ± ∞ ¹ ~ (p=1.000 n=5) ² IPStringExpanded/v4-48 1.000 ± ∞ ¹ 1.000 ± ∞ ¹ ~ (p=1.000 n=5) ² IPStringExpanded/v6-48 1.000 ± ∞ ¹ 1.000 ± ∞ ¹ ~ (p=1.000 n=5) ² IPStringExpanded/v6_ellipsis-48 1.000 ± ∞ ¹ 1.000 ± ∞ ¹ ~ (p=1.000 n=5) ² IPStringExpanded/v6_v4-48 1.000 ± ∞ ¹ 1.000 ± ∞ ¹ ~ (p=1.000 n=5) ² IPStringExpanded/v6_zone-48 2.000 ± ∞ ¹ 2.000 ± ∞ ¹ ~ (p=1.000 n=5) ² AddrMarshalText/v4-48 1.000 ± ∞ ¹ 1.000 ± ∞ ¹ ~ (p=1.000 n=5) ² AddrMarshalText/v6-48 1.000 ± ∞ ¹ 1.000 ± ∞ ¹ ~ (p=1.000 n=5) ² AddrMarshalText/v6_ellipsis-48 1.000 ± ∞ ¹ 1.000 ± ∞ ¹ ~ (p=1.000 n=5) ² AddrMarshalText/v6_v4-48 1.000 ± ∞ ¹ 1.000 ± ∞ ¹ ~ (p=1.000 n=5) ² AddrMarshalText/v6_zone-48 1.000 ± ∞ ¹ 1.000 ± ∞ ¹ ~ (p=1.000 n=5) ² AddrPortString/v4-48 1.000 ± ∞ ¹ 1.000 ± ∞ ¹ ~ (p=1.000 n=5) ² AddrPortString/v6-48 1.000 ± ∞ ¹ 1.000 ± ∞ ¹ ~ (p=1.000 n=5) ² AddrPortString/v6_ellipsis-48 1.000 ± ∞ ¹ 1.000 ± ∞ ¹ ~ (p=1.000 n=5) ² AddrPortString/v6_v4-48 1.000 ± ∞ ¹ 1.000 ± ∞ ¹ ~ (p=1.000 n=5) ² AddrPortString/v6_zone-48 1.000 ± ∞ ¹ 1.000 ± ∞ ¹ ~ (p=1.000 n=5) ² AddrPortMarshalText/v4-48 1.000 ± ∞ ¹ 1.000 ± ∞ ¹ ~ (p=1.000 n=5) ² AddrPortMarshalText/v6-48 1.000 ± ∞ ¹ 1.000 ± ∞ ¹ ~ (p=1.000 n=5) ² AddrPortMarshalText/v6_ellipsis-48 1.000 ± ∞ ¹ 1.000 ± ∞ ¹ ~ (p=1.000 n=5) ² AddrPortMarshalText/v6_v4-48 1.000 ± ∞ ¹ 1.000 ± ∞ ¹ ~ (p=1.000 n=5) ² AddrPortMarshalText/v6_zone-48 1.000 ± ∞ ¹ 1.000 ± ∞ ¹ ~ (p=1.000 n=5) ² PrefixMasking/IPv4_/32-48 0.000 ± ∞ ¹ 0.000 ± ∞ ¹ ~ (p=1.000 n=5) ² PrefixMasking/IPv4_/17-48 0.000 ± ∞ ¹ 0.000 ± ∞ ¹ ~ (p=1.000 n=5) ² PrefixMasking/IPv4_/0-48 0.000 ± ∞ ¹ 0.000 ± ∞ ¹ ~ (p=1.000 n=5) ² PrefixMasking/IPv6_/128-48 0.000 ± ∞ ¹ 0.000 ± ∞ ¹ ~ (p=1.000 n=5) ² PrefixMasking/IPv6_/65-48 0.000 ± ∞ ¹ 0.000 ± ∞ ¹ ~ (p=1.000 n=5) ² PrefixMasking/IPv6_/0-48 0.000 ± ∞ ¹ 0.000 ± ∞ ¹ ~ (p=1.000 n=5) ² PrefixMasking/IPv6_zone_/128-48 0.000 ± ∞ ¹ 0.000 ± ∞ ¹ ~ (p=1.000 n=5) ² PrefixMasking/IPv6_zone_/65-48 0.000 ± ∞ ¹ 0.000 ± ∞ ¹ ~ (p=1.000 n=5) ² PrefixMasking/IPv6_zone_/0-48 0.000 ± ∞ ¹ 0.000 ± ∞ ¹ ~ (p=1.000 n=5) ² PrefixMarshalText-48 1.000 ± ∞ ¹ 1.000 ± ∞ ¹ ~ (p=1.000 n=5) ² ParseAddrPort/v4-48 0.000 ± ∞ ¹ 0.000 ± ∞ ¹ ~ (p=1.000 n=5) ² ParseAddrPort/v6-48 0.000 ± ∞ ¹ 0.000 ± ∞ ¹ ~ (p=1.000 n=5) ² ParseAddrPort/v6_ellipsis-48 0.000 ± ∞ ¹ 0.000 ± ∞ ¹ ~ (p=1.000 n=5) ² ParseAddrPort/v6_v4-48 0.000 ± ∞ ¹ 0.000 ± ∞ ¹ ~ (p=1.000 n=5) ² ParseAddrPort/v6_zone-48 0.000 ± ∞ ¹ 0.000 ± ∞ ¹ ~ (p=1.000 n=5) ² geomean ³ +0.00% ³ ¹ need >= 6 samples for confidence interval at level 0.95 ² all samples are equal ³ summaries must be >0 to compute geomean Change-Id: Ieec7d1f0836f3ee93a33653aee9b0c0fc77f399d Reviewed-on: https://go-review.googlesource.com/c/go/+/577035 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com>
-rw-r--r--src/go/build/deps_test.go2
-rw-r--r--src/net/netip/export_test.go6
-rw-r--r--src/net/netip/netip.go31
-rw-r--r--src/net/netip/netip_test.go12
4 files changed, 26 insertions, 25 deletions
diff --git a/src/go/build/deps_test.go b/src/go/build/deps_test.go
index 11b6722e22..1e0b4d6d8b 100644
--- a/src/go/build/deps_test.go
+++ b/src/go/build/deps_test.go
@@ -377,7 +377,7 @@ var depsRules = `
internal/godebug
< internal/intern;
- internal/bytealg, internal/intern, internal/itoa, math/bits, sort, strconv
+ internal/bytealg, internal/itoa, math/bits, sort, strconv, unique
< net/netip;
# net is unavoidable when doing any networking,
diff --git a/src/net/netip/export_test.go b/src/net/netip/export_test.go
index 72347ee01b..4febcad893 100644
--- a/src/net/netip/export_test.go
+++ b/src/net/netip/export_test.go
@@ -4,7 +4,7 @@
package netip
-import "internal/intern"
+import "unique"
var (
Z0 = z0
@@ -14,11 +14,13 @@ var (
type Uint128 = uint128
+type AddrDetail = addrDetail
+
func Mk128(hi, lo uint64) Uint128 {
return uint128{hi, lo}
}
-func MkAddr(u Uint128, z *intern.Value) Addr {
+func MkAddr(u Uint128, z unique.Handle[AddrDetail]) Addr {
return Addr{u, z}
}
diff --git a/src/net/netip/netip.go b/src/net/netip/netip.go
index b613a5c82f..1912561c74 100644
--- a/src/net/netip/netip.go
+++ b/src/net/netip/netip.go
@@ -16,9 +16,9 @@ import (
"errors"
"math"
"strconv"
+ "unique"
"internal/bytealg"
- "internal/intern"
"internal/itoa"
)
@@ -53,22 +53,22 @@ type Addr struct {
// bytewise processing.
addr uint128
- // z is a combination of the address family and the IPv6 zone.
- //
- // nil means invalid IP address (for a zero Addr).
- // z4 means an IPv4 address.
- // z6noz means an IPv6 address without a zone.
- //
- // Otherwise it's the interned zone name string.
- z *intern.Value
+ // Details about the address, wrapped up together and canonicalized.
+ z unique.Handle[addrDetail]
+}
+
+// addrDetail represents the details of an Addr, like address family and IPv6 zone.
+type addrDetail struct {
+ IsV6 bool // IPv4 is false, IPv6 is true.
+ ZoneV6 string // != nil only if IsV6 is true.
}
// z0, z4, and z6noz are sentinel Addr.z values.
// See the Addr type's field docs.
var (
- z0 = (*intern.Value)(nil)
- z4 = new(intern.Value)
- z6noz = new(intern.Value)
+ z0 unique.Handle[addrDetail]
+ z4 = unique.Make(addrDetail{})
+ z6noz = unique.Make(addrDetail{IsV6: true})
)
// IPv6LinkLocalAllNodes returns the IPv6 link-local all nodes multicast
@@ -407,11 +407,10 @@ func (ip Addr) BitLen() int {
// Zone returns ip's IPv6 scoped addressing zone, if any.
func (ip Addr) Zone() string {
- if ip.z == nil {
+ if ip.z == z0 {
return ""
}
- zone, _ := ip.z.Get().(string)
- return zone
+ return ip.z.Value().ZoneV6
}
// Compare returns an integer comparing two IPs.
@@ -496,7 +495,7 @@ func (ip Addr) WithZone(zone string) Addr {
ip.z = z6noz
return ip
}
- ip.z = intern.GetByString(zone)
+ ip.z = unique.Make(addrDetail{IsV6: true, ZoneV6: zone})
return ip
}
diff --git a/src/net/netip/netip_test.go b/src/net/netip/netip_test.go
index e75f07d8c2..a52960038e 100644
--- a/src/net/netip/netip_test.go
+++ b/src/net/netip/netip_test.go
@@ -9,7 +9,6 @@ import (
"encoding/json"
"flag"
"fmt"
- "internal/intern"
"internal/testenv"
"net"
. "net/netip"
@@ -18,6 +17,7 @@ import (
"sort"
"strings"
"testing"
+ "unique"
)
var long = flag.Bool("long", false, "run long tests")
@@ -113,18 +113,18 @@ func TestParseAddr(t *testing.T) {
// IPv6 with a zone specifier.
{
in: "fd7a:115c:a1e0:ab12:4843:cd96:626b:430b%eth0",
- ip: MkAddr(Mk128(0xfd7a115ca1e0ab12, 0x4843cd96626b430b), intern.Get("eth0")),
+ ip: MkAddr(Mk128(0xfd7a115ca1e0ab12, 0x4843cd96626b430b), unique.Make(AddrDetail{IsV6: true, ZoneV6: "eth0"})),
},
// IPv6 with dotted decimal and zone specifier.
{
in: "1:2::ffff:192.168.140.255%eth1",
- ip: MkAddr(Mk128(0x0001000200000000, 0x0000ffffc0a88cff), intern.Get("eth1")),
+ ip: MkAddr(Mk128(0x0001000200000000, 0x0000ffffc0a88cff), unique.Make(AddrDetail{IsV6: true, ZoneV6: "eth1"})),
str: "1:2::ffff:c0a8:8cff%eth1",
},
// 4-in-6 with zone
{
in: "::ffff:192.168.140.255%eth1",
- ip: MkAddr(Mk128(0, 0x0000ffffc0a88cff), intern.Get("eth1")),
+ ip: MkAddr(Mk128(0, 0x0000ffffc0a88cff), unique.Make(AddrDetail{IsV6: true, ZoneV6: "eth1"})),
str: "::ffff:192.168.140.255%eth1",
},
// IPv6 with capital letters.
@@ -1677,7 +1677,7 @@ var parseBenchInputs = []struct {
}
func BenchmarkParseAddr(b *testing.B) {
- sinkInternValue = intern.Get("eth1") // Pin to not benchmark the intern package
+ sinkInternValue = unique.Make(AddrDetail{IsV6: true, ZoneV6: "eth1"}) // Pin to not benchmark the intern package
for _, test := range parseBenchInputs {
b.Run(test.name, func(b *testing.B) {
b.ReportAllocs()
@@ -1962,7 +1962,7 @@ var (
sinkAddrPort AddrPort
sinkPrefix Prefix
sinkPrefixSlice []Prefix
- sinkInternValue *intern.Value
+ sinkInternValue unique.Handle[AddrDetail]
sinkIP16 [16]byte
sinkIP4 [4]byte
sinkBool bool