test+perf: parity benchmarks and allocation cuts for x/h3go - #132
Open
justinhwang wants to merge 1 commit into
Open
test+perf: parity benchmarks and allocation cuts for x/h3go#132justinhwang wants to merge 1 commit into
justinhwang wants to merge 1 commit into
Conversation
Coverage Report for CI Build 30594622066Coverage decreased (-0.2%) to 99.764%Details
Uncovered Changes
Coverage Regressions2 previously-covered lines in 1 file lost coverage.
Coverage Stats
💛 - Coveralls |
Add a cgo-vs-pure-Go benchmark suite under x/h3go/paritytest covering every
publicly exposed function and method, each run as "impl=cgo" and "impl=go"
sub-benchmarks so `benchstat -col /impl` reports the per-method delta.
Drive down allocations in the functions the suite flagged as far slower than
the cgo reference, replacing append-growth, per-call disk allocation,
per-level maps, and a pointer-per-arc graph with preallocated/shared buffers
and index-based structures (measured pure-Go before -> after, Apple M3 Max):
- GridDisk: 36 -> 2 allocs, 1610ns -> 837ns (now -18% vs cgo)
- GridDisksUnsafe: 1283 -> 3 allocs, 49.3us -> 22.3us (now -24% vs cgo)
- GridDiskDistances: 30 -> 3 allocs, -35% time
- GridRing(Unsafe): 5 -> 2 allocs, -15% time
- PolygonToCells: 2526 -> 98 allocs, -20% time
- CellsToMultiPolygon: 632 -> 188 allocs, -25% time
- CompactCells: rewritten map-based -> sort-based, 10.8us -> 1.70us
(now -38% vs cgo, was +330%)
Also restore the Class III substrate aperture-7 scaling branch in
faceijk.toVec3 for byte-for-byte fidelity with the C reference (dead code
for H3's own callers, which bump substrate grids to Class II first).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
benchstat -col /impl over the full suite (Apple M3 Max, count=10,
benchtime=100ms). 'go' is this pure-Go package, 'cgo' the v4 reference:
│ cgo │ go │
│ sec/op │ sec/op vs base │
LatLngToCell-16 236.2n ± 7% 223.1n ± 1% -5.55% (p=0.000 n=10)
LatLngToCellString-16 262.8n ± 0% 245.9n ± 1% -6.43% (p=0.000 n=10)
LatLngCell-16 236.2n ± 3% 222.6n ± 1% -5.76% (p=0.000 n=10)
NewLatLng-16 9.533n ± 2% 9.468n ± 1% ~ (p=0.052 n=10)
LatLngString-16 70.71n ± 5% 69.61n ± 2% ~ (p=0.050 n=10)
CellToLatLng-16 150.2n ± 0% 158.8n ± 0% +5.73% (p=0.000 n=10)
CellLatLng-16 150.2n ± 1% 158.1n ± 0% +5.33% (p=0.000 n=10)
CellToString-16 29.70n ± 2% 29.43n ± 1% -0.91% (p=0.006 n=10)
CellString-16 29.48n ± 4% 29.14n ± 0% -1.12% (p=0.003 n=10)
CellMarshalText-16 47.57n ± 0% 46.47n ± 0% -2.32% (p=0.001 n=10)
CellFromString-16 31.97n ± 3% 31.46n ± 2% -1.58% (p=0.011 n=10)
IndexFromString-16 31.71n ± 5% 32.38n ± 2% +2.11% (p=0.024 n=10)
IndexToString-16 30.08n ± 10% 29.11n ± 1% -3.24% (p=0.000 n=10)
Resolution-16 1.936n ± 1% 1.935n ± 4% ~ (p=0.696 n=10)
BaseCellNumberFunc-16 1.934n ± 0% 1.940n ± 3% ~ (p=0.109 n=10)
BaseCellNumber-16 1.921n ± 0% 1.921n ± 3% ~ (p=0.839 n=10)
IsValid-16 2.662n ± 0% 2.461n ± 3% -7.53% (p=0.000 n=10)
IsPentagon-16 1.940n ± 5% 1.910n ± 0% -1.52% (p=0.000 n=10)
IsResClassIII-16 1.891n ± 1% 1.878n ± 1% -0.71% (p=0.000 n=10)
CellIndexDigit-16 30.765n ± 1% 1.936n ± 1% -93.71% (p=0.000 n=10)
NumCells-16 7.825n ± 1% 7.969n ± 4% +1.85% (p=0.009 n=10)
Res0Cells-16 190.8n ± 1% 140.9n ± 1% -26.11% (p=0.000 n=10)
Pentagons-16 254.0n ± 1% 121.8n ± 0% -52.02% (p=0.000 n=10)
Parent-16 37.26n ± 2% 12.25n ± 1% -67.14% (p=0.000 n=10)
ImmediateParent-16 36.41n ± 0% 10.26n ± 1% -71.83% (p=0.000 n=10)
Children-16 1533.5n ± 2% 856.1n ± 1% -44.17% (p=0.000 n=10)
ImmediateChildren-16 106.45n ± 2% 44.43n ± 1% -58.26% (p=0.000 n=10)
CenterChild-16 36.550n ± 4% 8.892n ± 1% -75.67% (p=0.000 n=10)
CellToChildPos-16 41.72n ± 1% 10.33n ± 4% -75.24% (p=0.000 n=10)
ChildPos-16 42.04n ± 1% 10.32n ± 1% -75.45% (p=0.000 n=10)
ChildPosToCellFunc-16 45.41n ± 6% 14.46n ± 1% -68.14% (p=0.000 n=10)
ChildPosToCell-16 44.67n ± 1% 14.91n ± 2% -66.63% (p=0.000 n=10)
CompactCells-16 2.679µ ± 1% 1.636µ ± 0% -38.95% (p=0.000 n=10)
UncompactCells-16 1723.5n ± 4% 853.0n ± 0% -50.50% (p=0.000 n=10)
CellToBoundary-16 484.8n ± 1% 651.1n ± 2% +34.30% (p=0.000 n=10)
CellBoundary-16 485.4n ± 1% 650.9n ± 0% +34.10% (p=0.000 n=10)
CellAreaRads2-16 561.2n ± 1% 819.2n ± 1% +45.96% (p=0.000 n=10)
CellAreaKm2-16 561.1n ± 0% 816.4n ± 0% +45.49% (p=0.000 n=10)
CellAreaM2-16 563.1n ± 1% 825.6n ± 7% +46.61% (p=0.000 n=10)
HexagonAreaAvgKm2-16 35.590n ± 1% 7.878n ± 3% -77.86% (p=0.000 n=10)
HexagonAreaAvgM2-16 35.885n ± 0% 7.792n ± 9% -78.29% (p=0.000 n=10)
EdgeLengthRads-16 287.2n ± 0% 392.5n ± 2% +36.64% (p=0.000 n=10)
EdgeLengthKm-16 289.1n ± 0% 392.1n ± 0% +35.65% (p=0.000 n=10)
EdgeLengthM-16 293.0n ± 4% 394.4n ± 0% +34.60% (p=0.000 n=10)
HexagonEdgeLengthAvgKm-16 35.630n ± 3% 8.010n ± 2% -77.52% (p=0.000 n=10)
HexagonEdgeLengthAvgM-16 35.610n ± 0% 8.108n ± 2% -77.23% (p=0.000 n=10)
GreatCircleDistanceRads-16 30.25n ± 3% 29.84n ± 1% -1.34% (p=0.001 n=10)
GreatCircleDistanceKm-16 30.34n ± 0% 30.32n ± 0% ~ (p=0.697 n=10)
GreatCircleDistanceM-16 30.95n ± 0% 30.93n ± 0% ~ (p=0.445 n=10)
GridDiskFunc-16 1057.5n ± 1% 861.2n ± 1% -18.56% (p=0.000 n=10)
GridDisk-16 1066.5n ± 1% 862.5n ± 0% -19.13% (p=0.000 n=10)
GridDiskDistancesFunc-16 1360.5n ± 2% 899.9n ± 1% -33.86% (p=0.000 n=10)
GridDiskDistances-16 1339.5n ± 0% 893.2n ± 0% -33.32% (p=0.000 n=10)
GridDiskDistancesSafeFunc-16 7.010µ ± 1% 7.603µ ± 1% +8.46% (p=0.000 n=10)
GridDiskDistancesSafe-16 6.963µ ± 2% 7.641µ ± 1% +9.74% (p=0.000 n=10)
GridDiskDistancesUnsafeFunc-16 1344.5n ± 1% 903.6n ± 1% -32.79% (p=0.000 n=10)
GridDiskDistancesUnsafe-16 1343.5n ± 6% 897.5n ± 3% -33.20% (p=0.000 n=10)
GridRingFunc-16 417.1n ± 3% 349.1n ± 3% -16.30% (p=0.000 n=10)
GridRing-16 421.2n ± 5% 347.8n ± 0% -17.41% (p=0.000 n=10)
GridRingUnsafeFunc-16 422.3n ± 1% 347.2n ± 0% -17.77% (p=0.000 n=10)
GridRingUnsafe-16 418.6n ± 1% 347.4n ± 1% -17.01% (p=0.000 n=10)
GridDisksUnsafe-16 29.24µ ± 4% 22.96µ ± 1% -21.47% (p=0.000 n=10)
GridDistanceFunc-16 76.82n ± 1% 146.20n ± 1% +90.32% (p=0.000 n=10)
GridDistance-16 77.68n ± 4% 146.80n ± 1% +88.97% (p=0.000 n=10)
GridPathFunc-16 861.7n ± 1% 960.7n ± 1% +11.48% (p=0.000 n=10)
GridPath-16 856.1n ± 0% 961.3n ± 1% +12.28% (p=0.000 n=10)
IsNeighbor-16 33.255n ± 1% 5.869n ± 3% -82.35% (p=0.000 n=10)
CellToLocalIJ-16 62.25n ± 2% 72.22n ± 4% +16.02% (p=0.000 n=10)
LocalIJToCell-16 145.6n ± 0% 105.5n ± 1% -27.55% (p=0.000 n=10)
IcosahedronFaces-16 139.4n ± 5% 153.1n ± 1% +9.79% (p=0.000 n=10)
CellToVertex-16 37.290n ± 1% 9.367n ± 1% -74.88% (p=0.000 n=10)
CellVertex-16 37.145n ± 1% 9.325n ± 1% -74.90% (p=0.000 n=10)
CellToVertexes-16 77.33n ± 3% 44.19n ± 1% -42.86% (p=0.000 n=10)
CellVertexes-16 76.14n ± 5% 44.09n ± 1% -42.10% (p=0.000 n=10)
VertexToLatLng-16 176.7n ± 1% 215.6n ± 2% +21.98% (p=0.000 n=10)
VertexLatLng-16 176.2n ± 0% 215.8n ± 2% +22.41% (p=0.000 n=10)
IsValidVertexFunc-16 21.960n ± 1% 5.058n ± 1% -76.97% (p=0.000 n=10)
VertexIsValid-16 22.050n ± 1% 4.786n ± 0% -78.29% (p=0.000 n=10)
VertexResolution-16 1.920n ± 0% 1.932n ± 0% +0.65% (p=0.018 n=10)
VertexIndexDigit-16 30.790n ± 2% 1.921n ± 0% -93.76% (p=0.000 n=10)
VertexString-16 29.28n ± 2% 29.27n ± 1% ~ (p=0.781 n=10)
VertexMarshalText-16 45.75n ± 1% 45.01n ± 1% -1.63% (p=0.001 n=10)
VertexFromString-16 32.32n ± 5% 32.18n ± 2% ~ (p=0.839 n=10)
DirectedEdge-16 71.26n ± 6% 46.38n ± 1% -34.91% (p=0.000 n=10)
DirectedEdges-16 58.66n ± 1% 34.05n ± 1% -41.95% (p=0.000 n=10)
DirectedEdgeCells-16 56.19n ± 1% 32.05n ± 1% -42.95% (p=0.000 n=10)
DirectedEdgeOrigin-16 35.470n ± 4% 8.356n ± 2% -76.44% (p=0.000 n=10)
DirectedEdgeDestination-16 40.53n ± 1% 14.55n ± 1% -64.10% (p=0.000 n=10)
DirectedEdgeReverse-16 49.16n ± 1% 22.89n ± 1% -53.45% (p=0.000 n=10)
DirectedEdgeIsValid-16 21.080n ± 2% 3.522n ± 0% -83.29% (p=0.000 n=10)
DirectedEdgeResolution-16 1.936n ± 0% 1.937n ± 1% ~ (p=0.643 n=10)
DirectedEdgeIndexDigit-16 30.615n ± 1% 1.919n ± 1% -93.73% (p=0.000 n=10)
DirectedEdgeBoundary-16 285.8n ± 1% 376.6n ± 1% +31.75% (p=0.000 n=10)
DirectedEdgeString-16 29.61n ± 2% 29.41n ± 2% ~ (p=0.210 n=10)
DirectedEdgeMarshalText-16 46.40n ± 1% 45.12n ± 1% -2.76% (p=0.000 n=10)
DirectedEdgeFromString-16 32.18n ± 5% 32.21n ± 4% ~ (p=0.853 n=10)
PolygonToCells-16 136.7µ ± 0% 188.9µ ± 1% +38.26% (p=0.000 n=10)
GeoPolygonCells-16 136.5µ ± 1% 188.9µ ± 1% +38.37% (p=0.000 n=10)
PolygonToCellsExperimental-16 203.9µ ± 1% 117.8µ ± 0% -42.24% (p=0.000 n=10)
CellsToMultiPolygon-16 26.52µ ± 0% 39.42µ ± 2% +48.65% (p=0.000 n=10)
geomean 116.3n 78.02n -32.92%
│ cgo │ go │
│ B/op │ B/op vs base │
LatLngToCell-16 32.000 ± 0% 8.000 ± 0% -75.00% (p=0.000 n=10)
LatLngToCellString-16 56.00 ± 0% 32.00 ± 0% -42.86% (p=0.000 n=10)
LatLngCell-16 32.000 ± 0% 8.000 ± 0% -75.00% (p=0.000 n=10)
NewLatLng-16 16.00 ± 0% 16.00 ± 0% ~ (p=1.000 n=10) ¹
LatLngString-16 40.00 ± 0% 40.00 ± 0% ~ (p=1.000 n=10) ¹
CellToLatLng-16 32.00 ± 0% 16.00 ± 0% -50.00% (p=0.000 n=10)
CellLatLng-16 32.00 ± 0% 16.00 ± 0% -50.00% (p=0.000 n=10)
CellToString-16 32.00 ± 0% 32.00 ± 0% ~ (p=1.000 n=10) ¹
CellString-16 32.00 ± 0% 32.00 ± 0% ~ (p=1.000 n=10) ¹
CellMarshalText-16 56.00 ± 0% 56.00 ± 0% ~ (p=1.000 n=10) ¹
CellFromString-16 8.000 ± 0% 8.000 ± 0% ~ (p=1.000 n=10) ¹
IndexFromString-16 8.000 ± 0% 8.000 ± 0% ~ (p=1.000 n=10) ¹
IndexToString-16 32.00 ± 0% 32.00 ± 0% ~ (p=1.000 n=10) ¹
Resolution-16 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹
BaseCellNumberFunc-16 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹
BaseCellNumber-16 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹
IsValid-16 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹
IsPentagon-16 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹
IsResClassIII-16 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹
CellIndexDigit-16 4.000 ± 0% 0.000 ± 0% -100.00% (p=0.000 n=10)
NumCells-16 8.000 ± 0% 8.000 ± 0% ~ (p=1.000 n=10) ¹
Res0Cells-16 1.023Ki ± 0% 1.023Ki ± 0% ~ (p=1.000 n=10) ¹
Pentagons-16 120.0 ± 0% 120.0 ± 0% ~ (p=1.000 n=10) ¹
Parent-16 16.000 ± 0% 8.000 ± 0% -50.00% (p=0.000 n=10)
ImmediateParent-16 16.000 ± 0% 8.000 ± 0% -50.00% (p=0.000 n=10)
Children-16 3.031Ki ± 0% 3.023Ki ± 0% -0.26% (p=0.000 n=10)
ImmediateChildren-16 96.00 ± 0% 88.00 ± 0% -8.33% (p=0.000 n=10)
CenterChild-16 16.000 ± 0% 8.000 ± 0% -50.00% (p=0.000 n=10)
CellToChildPos-16 8.000 ± 0% 0.000 ± 0% -100.00% (p=0.000 n=10)
ChildPos-16 8.000 ± 0% 0.000 ± 0% -100.00% (p=0.000 n=10)
ChildPosToCellFunc-16 16.000 ± 0% 8.000 ± 0% -50.00% (p=0.000 n=10)
ChildPosToCell-16 16.000 ± 0% 8.000 ± 0% -50.00% (p=0.000 n=10)
CompactCells-16 3.023Ki ± 0% 3.969Ki ± 0% +31.27% (p=0.000 n=10)
UncompactCells-16 3.031Ki ± 0% 3.023Ki ± 0% -0.26% (p=0.000 n=10)
CellToBoundary-16 296.0 ± 0% 264.0 ± 0% -10.81% (p=0.000 n=10)
CellBoundary-16 296.0 ± 0% 264.0 ± 0% -10.81% (p=0.000 n=10)
CellAreaRads2-16 16.00 ± 0% 248.00 ± 0% +1450.00% (p=0.000 n=10)
CellAreaKm2-16 16.00 ± 0% 248.00 ± 0% +1450.00% (p=0.000 n=10)
CellAreaM2-16 16.00 ± 0% 248.00 ± 0% +1450.00% (p=0.000 n=10)
HexagonAreaAvgKm2-16 16.000 ± 0% 8.000 ± 0% -50.00% (p=0.000 n=10)
HexagonAreaAvgM2-16 16.000 ± 0% 8.000 ± 0% -50.00% (p=0.000 n=10)
EdgeLengthRads-16 16.00 ± 0% 56.00 ± 0% +250.00% (p=0.000 n=10)
EdgeLengthKm-16 16.00 ± 0% 56.00 ± 0% +250.00% (p=0.000 n=10)
EdgeLengthM-16 16.00 ± 0% 56.00 ± 0% +250.00% (p=0.000 n=10)
HexagonEdgeLengthAvgKm-16 16.000 ± 0% 8.000 ± 0% -50.00% (p=0.000 n=10)
HexagonEdgeLengthAvgM-16 16.000 ± 0% 8.000 ± 0% -50.00% (p=0.000 n=10)
GreatCircleDistanceRads-16 8.000 ± 0% 8.000 ± 0% ~ (p=1.000 n=10) ¹
GreatCircleDistanceKm-16 8.000 ± 0% 8.000 ± 0% ~ (p=1.000 n=10) ¹
GreatCircleDistanceM-16 8.000 ± 0% 8.000 ± 0% ~ (p=1.000 n=10) ¹
GridDiskFunc-16 792.0 ± 0% 792.0 ± 0% ~ (p=1.000 n=10) ¹
GridDisk-16 792.0 ± 0% 792.0 ± 0% ~ (p=1.000 n=10) ¹
GridDiskDistancesFunc-16 2048.0 ± 0% 936.0 ± 0% -54.30% (p=0.000 n=10)
GridDiskDistances-16 2048.0 ± 0% 936.0 ± 0% -54.30% (p=0.000 n=10)
GridDiskDistancesSafeFunc-16 2.000Ki ± 0% 8.797Ki ± 0% +339.84% (p=0.000 n=10)
GridDiskDistancesSafe-16 2.000Ki ± 0% 8.797Ki ± 0% +339.84% (p=0.000 n=10)
GridDiskDistancesUnsafeFunc-16 2048.0 ± 0% 936.0 ± 0% -54.30% (p=0.000 n=10)
GridDiskDistancesUnsafe-16 2048.0 ± 0% 936.0 ± 0% -54.30% (p=0.000 n=10)
GridRingFunc-16 264.0 ± 0% 264.0 ± 0% ~ (p=1.000 n=10) ¹
GridRing-16 264.0 ± 0% 264.0 ± 0% ~ (p=1.000 n=10) ¹
GridRingUnsafeFunc-16 264.0 ± 0% 264.0 ± 0% ~ (p=1.000 n=10) ¹
GridRingUnsafe-16 264.0 ± 0% 264.0 ± 0% ~ (p=1.000 n=10) ¹
GridDisksUnsafe-16 19.52Ki ± 0% 19.52Ki ± 0% ~ (p=1.000 n=10) ¹
GridDistanceFunc-16 8.000 ± 0% 0.000 ± 0% -100.00% (p=0.000 n=10)
GridDistance-16 8.000 ± 0% 0.000 ± 0% -100.00% (p=0.000 n=10)
GridPathFunc-16 80.00 ± 0% 72.00 ± 0% -10.00% (p=0.000 n=10)
GridPath-16 80.00 ± 0% 72.00 ± 0% -10.00% (p=0.000 n=10)
IsNeighbor-16 4.000 ± 0% 0.000 ± 0% -100.00% (p=0.000 n=10)
CellToLocalIJ-16 24.00 ± 0% 16.00 ± 0% -33.33% (p=0.000 n=10)
LocalIJToCell-16 24.000 ± 0% 8.000 ± 0% -66.67% (p=0.000 n=10)
IcosahedronFaces-16 56.00 ± 0% 40.00 ± 0% -28.57% (p=0.000 n=10)
CellToVertex-16 16.000 ± 0% 8.000 ± 0% -50.00% (p=0.000 n=10)
CellVertex-16 16.000 ± 0% 8.000 ± 0% -50.00% (p=0.000 n=10)
CellToVertexes-16 72.00 ± 0% 72.00 ± 0% ~ (p=1.000 n=10) ¹
CellVertexes-16 72.00 ± 0% 72.00 ± 0% ~ (p=1.000 n=10) ¹
VertexToLatLng-16 32.00 ± 0% 32.00 ± 0% ~ (p=1.000 n=10) ¹
VertexLatLng-16 32.00 ± 0% 32.00 ± 0% ~ (p=1.000 n=10) ¹
IsValidVertexFunc-16 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹
VertexIsValid-16 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹
VertexResolution-16 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹
VertexIndexDigit-16 4.000 ± 0% 0.000 ± 0% -100.00% (p=0.000 n=10)
VertexString-16 32.00 ± 0% 32.00 ± 0% ~ (p=1.000 n=10) ¹
VertexMarshalText-16 56.00 ± 0% 56.00 ± 0% ~ (p=1.000 n=10) ¹
VertexFromString-16 8.000 ± 0% 8.000 ± 0% ~ (p=1.000 n=10) ¹
DirectedEdge-16 16.000 ± 0% 8.000 ± 0% -50.00% (p=0.000 n=10)
DirectedEdges-16 72.00 ± 0% 72.00 ± 0% ~ (p=1.000 n=10) ¹
DirectedEdgeCells-16 40.00 ± 0% 40.00 ± 0% ~ (p=1.000 n=10) ¹
DirectedEdgeOrigin-16 16.000 ± 0% 8.000 ± 0% -50.00% (p=0.000 n=10)
DirectedEdgeDestination-16 16.000 ± 0% 8.000 ± 0% -50.00% (p=0.000 n=10)
DirectedEdgeReverse-16 16.000 ± 0% 8.000 ± 0% -50.00% (p=0.000 n=10)
DirectedEdgeIsValid-16 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹
DirectedEdgeResolution-16 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹
DirectedEdgeIndexDigit-16 4.000 ± 0% 0.000 ± 0% -100.00% (p=0.000 n=10)
DirectedEdgeBoundary-16 232.00 ± 0% 72.00 ± 0% -68.97% (p=0.000 n=10)
DirectedEdgeString-16 32.00 ± 0% 32.00 ± 0% ~ (p=1.000 n=10) ¹
DirectedEdgeMarshalText-16 56.00 ± 0% 56.00 ± 0% ~ (p=1.000 n=10) ¹
DirectedEdgeFromString-16 8.000 ± 0% 8.000 ± 0% ~ (p=1.000 n=10) ¹
PolygonToCells-16 6.438Ki ± 0% 33.688Ki ± 0% +423.30% (p=0.000 n=10)
GeoPolygonCells-16 6.438Ki ± 0% 33.688Ki ± 0% +423.30% (p=0.000 n=10)
PolygonToCellsExperimental-16 3.188Ki ± 0% 5.023Ki ± 0% +57.60% (p=0.000 n=10)
CellsToMultiPolygon-16 1016.0 ± 0% 36288.0 ± 0% +3471.65% (p=0.000 n=10)
geomean ² ? ² ³
¹ all samples are equal
² summaries must be >0 to compute geomean
³ ratios must be >0 to compute geomean
│ cgo │ go │
│ allocs/op │ allocs/op vs base │
LatLngToCell-16 3.000 ± 0% 1.000 ± 0% -66.67% (p=0.000 n=10)
LatLngToCellString-16 4.000 ± 0% 2.000 ± 0% -50.00% (p=0.000 n=10)
LatLngCell-16 3.000 ± 0% 1.000 ± 0% -66.67% (p=0.000 n=10)
NewLatLng-16 1.000 ± 0% 1.000 ± 0% ~ (p=1.000 n=10) ¹
LatLngString-16 2.000 ± 0% 2.000 ± 0% ~ (p=1.000 n=10) ¹
CellToLatLng-16 2.000 ± 0% 1.000 ± 0% -50.00% (p=0.000 n=10)
CellLatLng-16 2.000 ± 0% 1.000 ± 0% -50.00% (p=0.000 n=10)
CellToString-16 2.000 ± 0% 2.000 ± 0% ~ (p=1.000 n=10) ¹
CellString-16 2.000 ± 0% 2.000 ± 0% ~ (p=1.000 n=10) ¹
CellMarshalText-16 3.000 ± 0% 3.000 ± 0% ~ (p=1.000 n=10) ¹
CellFromString-16 1.000 ± 0% 1.000 ± 0% ~ (p=1.000 n=10) ¹
IndexFromString-16 1.000 ± 0% 1.000 ± 0% ~ (p=1.000 n=10) ¹
IndexToString-16 2.000 ± 0% 2.000 ± 0% ~ (p=1.000 n=10) ¹
Resolution-16 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹
BaseCellNumberFunc-16 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹
BaseCellNumber-16 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹
IsValid-16 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹
IsPentagon-16 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹
IsResClassIII-16 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹
CellIndexDigit-16 1.000 ± 0% 0.000 ± 0% -100.00% (p=0.000 n=10)
NumCells-16 1.000 ± 0% 1.000 ± 0% ~ (p=1.000 n=10) ¹
Res0Cells-16 2.000 ± 0% 2.000 ± 0% ~ (p=1.000 n=10) ¹
Pentagons-16 2.000 ± 0% 2.000 ± 0% ~ (p=1.000 n=10) ¹
Parent-16 2.000 ± 0% 1.000 ± 0% -50.00% (p=0.000 n=10)
ImmediateParent-16 2.000 ± 0% 1.000 ± 0% -50.00% (p=0.000 n=10)
Children-16 3.000 ± 0% 2.000 ± 0% -33.33% (p=0.000 n=10)
ImmediateChildren-16 3.000 ± 0% 2.000 ± 0% -33.33% (p=0.000 n=10)
CenterChild-16 2.000 ± 0% 1.000 ± 0% -50.00% (p=0.000 n=10)
CellToChildPos-16 1.000 ± 0% 0.000 ± 0% -100.00% (p=0.000 n=10)
ChildPos-16 1.000 ± 0% 0.000 ± 0% -100.00% (p=0.000 n=10)
ChildPosToCellFunc-16 2.000 ± 0% 1.000 ± 0% -50.00% (p=0.000 n=10)
ChildPosToCell-16 2.000 ± 0% 1.000 ± 0% -50.00% (p=0.000 n=10)
CompactCells-16 2.000 ± 0% 7.000 ± 0% +250.00% (p=0.000 n=10)
UncompactCells-16 3.000 ± 0% 2.000 ± 0% -33.33% (p=0.000 n=10)
CellToBoundary-16 3.000 ± 0% 5.000 ± 0% +66.67% (p=0.000 n=10)
CellBoundary-16 3.000 ± 0% 5.000 ± 0% +66.67% (p=0.000 n=10)
CellAreaRads2-16 2.000 ± 0% 5.000 ± 0% +150.00% (p=0.000 n=10)
CellAreaKm2-16 2.000 ± 0% 5.000 ± 0% +150.00% (p=0.000 n=10)
CellAreaM2-16 2.000 ± 0% 5.000 ± 0% +150.00% (p=0.000 n=10)
HexagonAreaAvgKm2-16 2.000 ± 0% 1.000 ± 0% -50.00% (p=0.000 n=10)
HexagonAreaAvgM2-16 2.000 ± 0% 1.000 ± 0% -50.00% (p=0.000 n=10)
EdgeLengthRads-16 2.000 ± 0% 3.000 ± 0% +50.00% (p=0.000 n=10)
EdgeLengthKm-16 2.000 ± 0% 3.000 ± 0% +50.00% (p=0.000 n=10)
EdgeLengthM-16 2.000 ± 0% 3.000 ± 0% +50.00% (p=0.000 n=10)
HexagonEdgeLengthAvgKm-16 2.000 ± 0% 1.000 ± 0% -50.00% (p=0.000 n=10)
HexagonEdgeLengthAvgM-16 2.000 ± 0% 1.000 ± 0% -50.00% (p=0.000 n=10)
GreatCircleDistanceRads-16 1.000 ± 0% 1.000 ± 0% ~ (p=1.000 n=10) ¹
GreatCircleDistanceKm-16 1.000 ± 0% 1.000 ± 0% ~ (p=1.000 n=10) ¹
GreatCircleDistanceM-16 1.000 ± 0% 1.000 ± 0% ~ (p=1.000 n=10) ¹
GridDiskFunc-16 2.000 ± 0% 2.000 ± 0% ~ (p=1.000 n=10) ¹
GridDisk-16 2.000 ± 0% 2.000 ± 0% ~ (p=1.000 n=10) ¹
GridDiskDistancesFunc-16 10.000 ± 0% 3.000 ± 0% -70.00% (p=0.000 n=10)
GridDiskDistances-16 10.000 ± 0% 3.000 ± 0% -70.00% (p=0.000 n=10)
GridDiskDistancesSafeFunc-16 10.00 ± 0% 20.00 ± 0% +100.00% (p=0.000 n=10)
GridDiskDistancesSafe-16 10.00 ± 0% 20.00 ± 0% +100.00% (p=0.000 n=10)
GridDiskDistancesUnsafeFunc-16 10.000 ± 0% 3.000 ± 0% -70.00% (p=0.000 n=10)
GridDiskDistancesUnsafe-16 10.000 ± 0% 3.000 ± 0% -70.00% (p=0.000 n=10)
GridRingFunc-16 2.000 ± 0% 2.000 ± 0% ~ (p=1.000 n=10) ¹
GridRing-16 2.000 ± 0% 2.000 ± 0% ~ (p=1.000 n=10) ¹
GridRingUnsafeFunc-16 2.000 ± 0% 2.000 ± 0% ~ (p=1.000 n=10) ¹
GridRingUnsafe-16 2.000 ± 0% 2.000 ± 0% ~ (p=1.000 n=10) ¹
GridDisksUnsafe-16 3.000 ± 0% 3.000 ± 0% ~ (p=1.000 n=10) ¹
GridDistanceFunc-16 1.000 ± 0% 0.000 ± 0% -100.00% (p=0.000 n=10)
GridDistance-16 1.000 ± 0% 0.000 ± 0% -100.00% (p=0.000 n=10)
GridPathFunc-16 3.000 ± 0% 2.000 ± 0% -33.33% (p=0.000 n=10)
GridPath-16 3.000 ± 0% 2.000 ± 0% -33.33% (p=0.000 n=10)
IsNeighbor-16 1.000 ± 0% 0.000 ± 0% -100.00% (p=0.000 n=10)
CellToLocalIJ-16 2.000 ± 0% 1.000 ± 0% -50.00% (p=0.000 n=10)
LocalIJToCell-16 3.000 ± 0% 1.000 ± 0% -66.67% (p=0.000 n=10)
IcosahedronFaces-16 4.000 ± 0% 2.000 ± 0% -50.00% (p=0.000 n=10)
CellToVertex-16 2.000 ± 0% 1.000 ± 0% -50.00% (p=0.000 n=10)
CellVertex-16 2.000 ± 0% 1.000 ± 0% -50.00% (p=0.000 n=10)
CellToVertexes-16 2.000 ± 0% 2.000 ± 0% ~ (p=1.000 n=10) ¹
CellVertexes-16 2.000 ± 0% 2.000 ± 0% ~ (p=1.000 n=10) ¹
VertexToLatLng-16 2.000 ± 0% 2.000 ± 0% ~ (p=1.000 n=10) ¹
VertexLatLng-16 2.000 ± 0% 2.000 ± 0% ~ (p=1.000 n=10) ¹
IsValidVertexFunc-16 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹
VertexIsValid-16 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹
VertexResolution-16 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹
VertexIndexDigit-16 1.000 ± 0% 0.000 ± 0% -100.00% (p=0.000 n=10)
VertexString-16 2.000 ± 0% 2.000 ± 0% ~ (p=1.000 n=10) ¹
VertexMarshalText-16 3.000 ± 0% 3.000 ± 0% ~ (p=1.000 n=10) ¹
VertexFromString-16 1.000 ± 0% 1.000 ± 0% ~ (p=1.000 n=10) ¹
DirectedEdge-16 2.000 ± 0% 1.000 ± 0% -50.00% (p=0.000 n=10)
DirectedEdges-16 2.000 ± 0% 2.000 ± 0% ~ (p=1.000 n=10) ¹
DirectedEdgeCells-16 2.000 ± 0% 2.000 ± 0% ~ (p=1.000 n=10) ¹
DirectedEdgeOrigin-16 2.000 ± 0% 1.000 ± 0% -50.00% (p=0.000 n=10)
DirectedEdgeDestination-16 2.000 ± 0% 1.000 ± 0% -50.00% (p=0.000 n=10)
DirectedEdgeReverse-16 2.000 ± 0% 1.000 ± 0% -50.00% (p=0.000 n=10)
DirectedEdgeIsValid-16 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹
DirectedEdgeResolution-16 0.000 ± 0% 0.000 ± 0% ~ (p=1.000 n=10) ¹
DirectedEdgeIndexDigit-16 1.000 ± 0% 0.000 ± 0% -100.00% (p=0.000 n=10)
DirectedEdgeBoundary-16 3.000 ± 0% 3.000 ± 0% ~ (p=1.000 n=10) ¹
DirectedEdgeString-16 2.000 ± 0% 2.000 ± 0% ~ (p=1.000 n=10) ¹
DirectedEdgeMarshalText-16 3.000 ± 0% 3.000 ± 0% ~ (p=1.000 n=10) ¹
DirectedEdgeFromString-16 1.000 ± 0% 1.000 ± 0% ~ (p=1.000 n=10) ¹
PolygonToCells-16 4.000 ± 0% 98.000 ± 0% +2350.00% (p=0.000 n=10)
GeoPolygonCells-16 4.000 ± 0% 98.000 ± 0% +2350.00% (p=0.000 n=10)
PolygonToCellsExperimental-16 4.000 ± 0% 24.000 ± 0% +500.00% (p=0.000 n=10)
CellsToMultiPolygon-16 5.000 ± 0% 188.000 ± 0% +3660.00% (p=0.000 n=10)
geomean ² ? ² ³
¹ all samples are equal
² summaries must be >0 to compute geomean
³ ratios must be >0 to compute geomean
justinhwang
force-pushed
the
justinhwang/paritytest-benchmarks
branch
from
July 31, 2026 00:49
f5c493f to
88d27e3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a cgo-vs-pure-Go benchmark suite under x/h3go/paritytest covering every publicly exposed function and method, each run as "impl=cgo" and "impl=go" sub-benchmarks so
benchstat -col /implreports the per-method delta.Drive down allocations in the functions the suite flagged as far slower than the cgo reference, replacing append-growth, per-call disk allocation, per-level maps, and a pointer-per-arc graph with preallocated/shared buffers and index-based structures (measured pure-Go before -> after, Apple M3 Max):
(now -38% vs cgo, was +330%)
Also restore the Class III substrate aperture-7 scaling branch in faceijk.toVec3 for byte-for-byte fidelity with the C reference (dead code for H3's own callers, which bump substrate grids to Class II first).
benchstat -col /impl over the full suite (Apple M3 Max, count=10, benchtime=100ms). 'go' is this pure-Go package, 'cgo' the v4 reference: