Skip to content

Update CH package version - #36

Merged
LdDl merged 2 commits into
masterfrom
deps
Nov 30, 2025
Merged

LdDl merged 2 commits into
masterfrom
deps

Conversation

@LdDl

@LdDl LdDl commented Nov 30, 2025 •

Copy link
Copy Markdown
Owner

There is breaking changes according to CH:

  1. v1.8.0 - https://github.com/LdDl/ch/releases/tag/v1.8.0
  2. v1.9.0 - https://github.com/LdDl/ch/releases/tag/v1.9.0

Benchmarking (for BenchmarkMapMatcherSRID_4326BIG):

go test -run=^$ -bench=^BenchmarkMapMatcherSRID_4326BIG$ -cpuprofile=cpu_new.prof -benchtime=10s
go tool pprof -text cpu_new.prof
go test -run=^$ -bench=^BenchmarkMapMatcherSRID_4326BIG$ -memprofile=mem_new.prof -benchtime=10s
go tool pprof -text mem_new.prof

Current benchmark:

  1. CPU
Showing nodes accounting for 54s, 92.09% of 58.64s total
Dropped 409 nodes (cum <= 0.29s)
      flat  flat%   sum%        cum   cum%
    12.95s 22.08% 22.08%     46.77s 79.76%  runtime.scanobject
    10.41s 17.75% 39.84%     10.41s 17.75%  runtime.(*mspan).base (inline)
     7.80s 13.30% 53.14%      9.11s 15.54%  runtime.findObject
     4.51s  7.69% 60.83%      4.52s  7.71%  runtime.(*gcBits).bitp (inline)
     3.81s  6.50% 67.33%      3.92s  6.68%  runtime.(*mspan).heapBitsSmallForAddr
     3.06s  5.22% 72.54%      8.78s 14.97%  github.com/LdDl/ch.(*Graph).shortestPath
     1.70s  2.90% 75.44%      1.70s  2.90%  runtime.memclrNoHeapPointers
     1.41s  2.40% 77.85%     18.29s 31.19%  runtime.greyobject
     1.22s  2.08% 79.93%     47.52s 81.04%  runtime.gcDrain
     1.02s  1.74% 81.67%      1.02s  1.74%  runtime.arenaIndex (inline)
     1.01s  1.72% 83.39%      1.01s  1.72%  runtime.markBits.isMarked (inline)
     0.67s  1.14% 84.53%      0.87s  1.48%  runtime.pageIndexOf (inline)
     0.64s  1.09% 85.62%      0.66s  1.13%  runtime.typePointers.next
     0.47s   0.8% 86.43%      0.47s   0.8%  runtime.(*mspan).divideByElemSize (inline)
     0.41s   0.7% 87.12%      0.53s   0.9%  runtime.spanOf (inline)
     0.41s   0.7% 87.82%      1.11s  1.89%  runtime.spanOfUnchecked (inline)
     0.39s  0.67% 88.49%      0.39s  0.67%  runtime.(*gcWork).tryGetFast (inline)
     0.37s  0.63% 89.12%      0.37s  0.63%  runtime.(*lfstack).pop (inline)
     0.35s   0.6% 89.72%      0.35s   0.6%  runtime.typePointers.nextFast (inline)
     0.34s  0.58% 90.30%      4.27s  7.28%  runtime.(*mspan).typePointersOfUnchecked
     0.18s  0.31% 90.60%      0.39s  0.67%  runtime.(*sweepLocked).sweep
     0.16s  0.27% 90.88%      0.72s  1.23%  runtime.sweepone
     0.11s  0.19% 91.06%      0.35s   0.6%  container/heap.down
     0.11s  0.19% 91.25%      0.83s  1.42%  github.com/LdDl/ch.(*Graph).ComputePath
     0.08s  0.14% 91.39%      4.53s  7.73%  runtime.mallocgc
     0.07s  0.12% 91.51%      0.34s  0.58%  runtime.mallocgcSmallScanNoHeader
     0.05s 0.085% 91.59%      4.57s  7.79%  runtime.(*mspan).markBitsForIndex (inline)
     0.05s 0.085% 91.68%      0.52s  0.89%  runtime.(*mspan).objIndex (inline)
     0.04s 0.068% 91.75%      0.35s   0.6%  runtime.getempty
     0.03s 0.051% 91.80%      0.39s  0.67%  container/heap.Pop
     0.03s 0.051% 91.85%      1.65s  2.81%  runtime.gcDrainN
     0.03s 0.051% 91.90%      0.31s  0.53%  runtime.mapassign_fast64
     0.02s 0.034% 91.93%      1.67s  2.85%  runtime.deductAssistCredit
     0.02s 0.034% 91.97%     47.61s 81.19%  runtime.gcBgMarkWorker
     0.02s 0.034% 92.00%      1.65s  2.81%  runtime.memclrNoHeapPointersChunked
     0.01s 0.017% 92.02%      0.78s  1.33%  github.com/LdDl/horizon.(*MapEngine).extractDataFromCSVs
     0.01s 0.017% 92.04%      9.08s 15.48%  github.com/LdDl/horizon.(*MapMatcher).Run
     0.01s 0.017% 92.05%      8.85s 15.09%  github.com/LdDl/horizon.getCachedPath
     0.01s 0.017% 92.07%      0.42s  0.72%  runtime.handoff
     0.01s 0.017% 92.09%      3.76s  6.41%  runtime.makeslice
         0     0% 92.09%      8.81s 15.02%  github.com/LdDl/ch.(*Graph).ShortestPath
         0     0% 92.09%      0.79s  1.35%  github.com/LdDl/horizon.BenchmarkMapMatcherSRID_4326BIG
         0     0% 92.09%      9.08s 15.48%  github.com/LdDl/horizon.BenchmarkMapMatcherSRID_4326BIG.func1
         0     0% 92.09%      0.78s  1.33%  github.com/LdDl/horizon.NewMapMatcherFromFiles
         0     0% 92.09%      0.78s  1.33%  github.com/LdDl/horizon.prepareEngine
         0     0% 92.09%      0.30s  0.51%  github.com/LdDl/horizon/spatial.(*S2Storage).AddEdge
         0     0% 92.09%      0.53s   0.9%  runtime.(*gcWork).balance
         0     0% 92.09%      0.72s  1.23%  runtime.bgsweep
         0     0% 92.09%      1.65s  2.81%  runtime.gcAssistAlloc
         0     0% 92.09%      1.65s  2.81%  runtime.gcAssistAlloc.func2
         0     0% 92.09%      1.65s  2.81%  runtime.gcAssistAlloc1
         0     0% 92.09%     47.52s 81.04%  runtime.gcBgMarkWorker.func2
         0     0% 92.09%     14.23s 24.27%  runtime.gcDrainMarkWorkerDedicated (inline)
         0     0% 92.09%     33.29s 56.77%  runtime.gcDrainMarkWorkerIdle (inline)
         0     0% 92.09%      2.09s  3.56%  runtime.mallocgcLarge
         0     0% 92.09%      0.33s  0.56%  runtime.mcall
         0     0% 92.09%      0.48s  0.82%  runtime.newobject
         0     0% 92.09%      0.31s  0.53%  runtime.park_m
         0     0% 92.09%      0.33s  0.56%  runtime.schedule
         0     0% 92.09%     49.92s 85.13%  runtime.systemstack
         0     0% 92.09%      9.03s 15.40%  testing.(*B).launch
         0     0% 92.09%      0.84s  1.43%  testing.(*B).run1.func1
         0     0% 92.09%      9.87s 16.83%  testing.(*B).runN
  1. Memory:
Showing nodes accounting for 38844.77MB, 98.27% of 39530.52MB total
Dropped 104 nodes (cum <= 197.65MB)
      flat  flat%   sum%        cum   cum%
38702.08MB 97.90% 97.90% 38998.16MB 98.65%  github.com/LdDl/ch.(*Graph).shortestPath
   79.04MB   0.2% 98.10%   212.55MB  0.54%  github.com/LdDl/ch.(*Graph).ComputePath
   25.56MB 0.065% 98.17%   449.26MB  1.14%  github.com/LdDl/horizon.(*MapEngine).extractDataFromCSVs
   25.52MB 0.065% 98.23% 39062.19MB 98.82%  github.com/LdDl/horizon.(*MapMatcher).Run
    7.56MB 0.019% 98.25%   228.59MB  0.58%  github.com/LdDl/horizon/spatial.(*S2Storage).AddEdge
       5MB 0.013% 98.27% 39003.16MB 98.67%  github.com/LdDl/horizon.getCachedPath
         0     0% 98.27% 38998.16MB 98.65%  github.com/LdDl/ch.(*Graph).ShortestPath
         0     0% 98.27%   449.77MB  1.14%  github.com/LdDl/horizon.BenchmarkMapMatcherSRID_4326BIG
         0     0% 98.27% 39062.19MB 98.82%  github.com/LdDl/horizon.BenchmarkMapMatcherSRID_4326BIG.func1
         0     0% 98.27%   449.26MB  1.14%  github.com/LdDl/horizon.NewMapMatcherFromFiles
         0     0% 98.27%   449.26MB  1.14%  github.com/LdDl/horizon.prepareEngine
         0     0% 98.27%   222.03MB  0.56%  github.com/golang/geo/s2.(*RegionCoverer).CellUnion
         0     0% 98.27%   223.53MB  0.57%  github.com/golang/geo/s2.(*RegionCoverer).Covering
         0     0% 98.27%   213.53MB  0.54%  github.com/golang/geo/s2.(*coverer).coveringInternal
         0     0% 98.27% 38919.71MB 98.45%  testing.(*B).launch
         0     0% 98.27%   592.24MB  1.50%  testing.(*B).run1.func1
         0     0% 98.27% 39511.95MB   100%  testing.(*B).runN

This PR benchmark (for BenchmarkMapMatcherSRID_4326BIG):

  1. CPU
Showing nodes accounting for 10.20s, 84.30% of 12.10s total
Dropped 249 nodes (cum <= 0.06s)
      flat  flat%   sum%        cum   cum%
     1.33s 10.99% 10.99%      4.50s 37.19%  runtime.scanobject
     1.25s 10.33% 21.32%      3.96s 32.73%  github.com/LdDl/ch.(*QueryPool).directionalSearch
     1.02s  8.43% 29.75%      1.02s  8.43%  runtime.(*mspan).base (inline)
     0.65s  5.37% 35.12%      0.98s  8.10%  container/heap.down
     0.65s  5.37% 40.50%      0.79s  6.53%  runtime.findObject
     0.53s  4.38% 44.88%      0.53s  4.38%  runtime.(*gcBits).bitp (inline)
     0.34s  2.81% 47.69%      0.39s  3.22%  runtime.(*mspan).heapBitsSmallForAddr
     0.28s  2.31% 50.00%      0.28s  2.31%  github.com/LdDl/ch.vertexDistHeap.Less
     0.26s  2.15% 52.15%      0.61s  5.04%  runtime.mapaccess2_fast64
     0.22s  1.82% 53.97%      1.50s 12.40%  github.com/LdDl/ch.(*Graph).ComputePath
     0.19s  1.57% 55.54%      0.19s  1.57%  runtime.memhash64
     0.16s  1.32% 56.86%      0.58s  4.79%  runtime.mapaccess1_fast64
     0.16s  1.32% 58.18%      0.16s  1.32%  runtime.nextFreeFast (inline)
     0.15s  1.24% 59.42%      0.15s  1.24%  internal/runtime/maps.ctrlGroup.matchFull (inline)
     0.14s  1.16% 60.58%      0.20s  1.65%  container/heap.up
     0.14s  1.16% 61.74%      0.14s  1.16%  runtime.memclrNoHeapPointers
     0.12s  0.99% 62.73%      0.12s  0.99%  internal/runtime/maps.(*Map).Used (inline)
     0.12s  0.99% 63.72%      0.12s  0.99%  internal/runtime/maps.h2 (inline)
     0.12s  0.99% 64.71%      1.81s 14.96%  runtime.greyobject
     0.11s  0.91% 65.62%      0.93s  7.69%  runtime.mapassign_fast64
     0.10s  0.83% 66.45%      0.10s  0.83%  internal/runtime/maps.ctrlGroup.matchH2 (inline)
     0.10s  0.83% 67.27%      0.94s  7.77%  runtime.mallocgc
     0.09s  0.74% 68.02%      0.24s  1.98%  internal/runtime/maps.(*table).uncheckedPutSlot
     0.09s  0.74% 68.76%      0.09s  0.74%  runtime.markBits.isMarked (inline)
     0.09s  0.74% 69.50%      0.09s  0.74%  runtime.memmove
     0.09s  0.74% 70.25%      0.09s  0.74%  runtime.typePointers.next
     0.08s  0.66% 70.91%      1.15s  9.50%  container/heap.Pop
     0.08s  0.66% 71.57%      0.08s  0.66%  internal/runtime/maps.(*groupReference).key (inline)
     0.08s  0.66% 72.23%      0.08s  0.66%  internal/runtime/maps.ctrlGroup.matchEmpty (inline)
     0.08s  0.66% 72.89%      0.08s  0.66%  internal/runtime/maps.h1 (inline)
     0.08s  0.66% 73.55%      4.70s 38.84%  runtime.gcDrain
     0.08s  0.66% 74.21%      0.53s  4.38%  runtime.mallocgcSmallNoscan
     0.07s  0.58% 74.79%      0.13s  1.07%  encoding/json.checkValid
     0.07s  0.58% 75.37%      5.53s 45.70%  github.com/LdDl/ch.(*QueryPool).shortestPathCore
     0.07s  0.58% 75.95%      0.27s  2.23%  github.com/LdDl/ch.(*vertexDistHeap).Push
     0.07s  0.58% 76.53%      0.07s  0.58%  internal/runtime/maps.(*groupReference).elem (inline)
     0.07s  0.58% 77.11%      0.07s  0.58%  runtime.arenaIndex (inline)
     0.07s  0.58% 77.69%      0.25s  2.07%  runtime.growslice
     0.06s   0.5% 78.18%      0.18s  1.49%  github.com/LdDl/ch.vertexDistHeap.Swap
     0.06s   0.5% 78.68%      0.07s  0.58%  runtime.spanOf (inline)
     0.06s   0.5% 79.17%      0.12s  0.99%  runtime.spanOfUnchecked (inline)
     0.06s   0.5% 79.67%      0.18s  1.49%  runtime.wbBufFlush1
     0.05s  0.41% 80.08%      0.53s  4.38%  container/heap.Push
     0.05s  0.41% 80.50%      6.14s 50.74%  github.com/LdDl/horizon.(*MapMatcher).Run
     0.05s  0.41% 80.91%      0.52s  4.30%  internal/runtime/maps.(*table).grow
     0.04s  0.33% 81.24%      0.08s  0.66%  internal/runtime/maps.typedmemmove
     0.04s  0.33% 81.57%      0.11s  0.91%  runtime.(*sweepLocked).sweep
     0.03s  0.25% 81.82%      0.19s  1.57%  gcWriteBarrier
     0.03s  0.25% 82.07%      0.15s  1.24%  runtime.(*mcentral).cacheSpan
     0.03s  0.25% 82.31%      0.13s  1.07%  runtime.mapaccess2
     0.02s  0.17% 82.48%      0.08s  0.66%  encoding/csv.(*Reader).readRecord
     0.02s  0.17% 82.64%      5.58s 46.12%  github.com/LdDl/ch.(*QueryPool).shortestPath
     0.02s  0.17% 82.81%      0.75s  6.20%  github.com/LdDl/horizon.(*MapEngine).extractDataFromCSVs
     0.02s  0.17% 82.98%      0.11s  0.91%  github.com/golang/geo/s2.(*Polyline).IntersectsCell
     0.02s  0.17% 83.14%      0.23s  1.90%  runtime.mallocgcSmallScanNoHeader
     0.02s  0.17% 83.31%      0.23s  1.90%  runtime.newarray
     0.02s  0.17% 83.47%      0.40s  3.31%  runtime.newobject
     0.02s  0.17% 83.64%      0.21s  1.74%  runtime.sweepone
     0.01s 0.083% 83.72%      0.26s  2.15%  github.com/LdDl/horizon/spatial.(*S2Storage).SearchInRadius
     0.01s 0.083% 83.80%      0.17s  1.40%  github.com/golang/geo/s2.(*coverer).expandChildren
     0.01s 0.083% 83.88%      0.12s  0.99%  github.com/golang/geo/s2.Cell.DistanceToEdge
     0.01s 0.083% 83.97%      0.18s  1.49%  internal/runtime/maps.(*table).reset
     0.01s 0.083% 84.05%      0.12s  0.99%  runtime.(*mcentral).grow
     0.01s 0.083% 84.13%      0.54s  4.46%  runtime.(*mspan).markBitsForIndex (inline)
     0.01s 0.083% 84.21%      0.40s  3.31%  runtime.(*mspan).typePointersOfUnchecked
     0.01s 0.083% 84.30%      0.07s  0.58%  runtime.heapSetTypeNoHeader (inline)
         0     0% 84.30%      0.08s  0.66%  encoding/csv.(*Reader).Read
         0     0% 84.30%      0.09s  0.74%  encoding/json.(*decodeState).array
         0     0% 84.30%      0.09s  0.74%  encoding/json.(*decodeState).arrayInterface
         0     0% 84.30%      0.07s  0.58%  encoding/json.(*decodeState).literalInterface
         0     0% 84.30%      0.25s  2.07%  encoding/json.(*decodeState).object
         0     0% 84.30%      0.25s  2.07%  encoding/json.(*decodeState).unmarshal
         0     0% 84.30%      0.25s  2.07%  encoding/json.(*decodeState).value
         0     0% 84.30%      0.07s  0.58%  encoding/json.(*decodeState).valueInterface
         0     0% 84.30%      0.32s  2.64%  encoding/json.Unmarshal
         0     0% 84.30%      5.69s 47.02%  github.com/LdDl/ch.(*QueryPool).ShortestPath
         0     0% 84.30%      0.08s  0.66%  github.com/LdDl/horizon.(*MapMatcher).PrepareViterbi
         0     0% 84.30%      0.22s  1.82%  github.com/LdDl/horizon.(*MapMatcher).Run.func1
         0     0% 84.30%      0.75s  6.20%  github.com/LdDl/horizon.BenchmarkMapMatcherSRID_4326BIG
         0     0% 84.30%      6.14s 50.74%  github.com/LdDl/horizon.BenchmarkMapMatcherSRID_4326BIG.func1
         0     0% 84.30%      0.75s  6.20%  github.com/LdDl/horizon.NewMapMatcherFromFiles
         0     0% 84.30%      5.70s 47.11%  github.com/LdDl/horizon.getCachedPath
         0     0% 84.30%      0.75s  6.20%  github.com/LdDl/horizon.prepareEngine
         0     0% 84.30%      0.21s  1.74%  github.com/LdDl/horizon/spatial.(*S2Storage).AddEdge
         0     0% 84.30%      0.28s  2.31%  github.com/LdDl/horizon/spatial.(*S2Storage).FindNearestInRadius
         0     0% 84.30%      0.28s  2.31%  github.com/LdDl/horizon/spatial.(*S2Storage).NearestNeighborsInRadius
         0     0% 84.30%      0.14s  1.16%  github.com/LdDl/viterbi.Viterbi.EvalPathLogProbabilities
         0     0% 84.30%      0.26s  2.15%  github.com/golang/geo/s2.(*RegionCoverer).CellUnion
         0     0% 84.30%      0.26s  2.15%  github.com/golang/geo/s2.(*RegionCoverer).Covering
         0     0% 84.30%      0.17s  1.40%  github.com/golang/geo/s2.(*coverer).addCandidate
         0     0% 84.30%      0.25s  2.07%  github.com/golang/geo/s2.(*coverer).coveringInternal
         0     0% 84.30%      0.15s  1.24%  github.com/golang/geo/s2.(*coverer).initialCandidates
         0     0% 84.30%      0.14s  1.16%  github.com/golang/geo/s2.(*coverer).newCandidate
         0     0% 84.30%      0.21s  1.74%  github.com/paulmach/go%2egeojson.(*Geometry).UnmarshalJSON
         0     0% 84.30%      0.32s  2.64%  github.com/paulmach/go%2egeojson.UnmarshalGeometry
         0     0% 84.30%      0.08s  0.66%  internal/runtime/maps.(*Map).growToTable
         0     0% 84.30%      0.54s  4.46%  internal/runtime/maps.(*table).rehash
         0     0% 84.30%      0.23s  1.90%  internal/runtime/maps.newGroups (inline)
         0     0% 84.30%      0.21s  1.74%  internal/runtime/maps.newTable
         0     0% 84.30%      0.23s  1.90%  internal/runtime/maps.newarray
         0     0% 84.30%      0.22s  1.82%  runtime.(*mcache).nextFree
         0     0% 84.30%      0.22s  1.82%  runtime.(*mcache).refill
         0     0% 84.30%      0.12s  0.99%  runtime.(*mheap).alloc
         0     0% 84.30%      0.12s  0.99%  runtime.(*mheap).alloc.func1
         0     0% 84.30%      0.12s  0.99%  runtime.(*mheap).allocSpan
         0     0% 84.30%      0.20s  1.65%  runtime.bgsweep
         0     0% 84.30%      0.07s  0.58%  runtime.findRunnable
         0     0% 84.30%      4.71s 38.93%  runtime.gcBgMarkWorker
         0     0% 84.30%      4.70s 38.84%  runtime.gcBgMarkWorker.func2
         0     0% 84.30%      1.64s 13.55%  runtime.gcDrainMarkWorkerDedicated (inline)
         0     0% 84.30%      3.06s 25.29%  runtime.gcDrainMarkWorkerIdle (inline)
         0     0% 84.30%      0.18s  1.49%  runtime.makeslice
         0     0% 84.30%      0.07s  0.58%  runtime.mcall
         0     0% 84.30%      0.07s  0.58%  runtime.park_m
         0     0% 84.30%      0.07s  0.58%  runtime.schedule
         0     0% 84.30%      5.09s 42.07%  runtime.systemstack
         0     0% 84.30%      0.18s  1.49%  runtime.wbBufFlush
         0     0% 84.30%      0.18s  1.49%  runtime.wbBufFlush.func1
         0     0% 84.30%      6.14s 50.74%  testing.(*B).launch
         0     0% 84.30%      0.76s  6.28%  testing.(*B).run1.func1
         0     0% 84.30%      6.90s 57.02%  testing.(*B).runN
  1. Memory:
Showing nodes accounting for 3075.82MB, 94.42% of 3257.44MB total
Dropped 80 nodes (cum <= 16.29MB)
      flat  flat%   sum%        cum   cum%
 1215.05MB 37.30% 37.30%  1554.72MB 47.73%  github.com/LdDl/ch.(*QueryPool).directionalSearch
  844.92MB 25.94% 63.24%   844.92MB 25.94%  github.com/LdDl/ch.(*Graph).ComputePath
  342.16MB 10.50% 73.74%   342.16MB 10.50%  github.com/LdDl/ch.(*vertexDistHeap).Push
  253.54MB  7.78% 81.53%   253.54MB  7.78%  github.com/golang/geo/s2.NewEdgeCrosser
  118.58MB  3.64% 85.17%  2763.31MB 84.83%  github.com/LdDl/horizon.(*MapMatcher).Run
   80.05MB  2.46% 87.62%    80.05MB  2.46%  github.com/LdDl/ch.(*QueryPool).acquireState
   27.38MB  0.84% 88.46%    27.38MB  0.84%  github.com/LdDl/ch.(*Graph).CreateVertex
   23.57MB  0.72% 89.19%   443.81MB 13.62%  github.com/LdDl/horizon.(*MapEngine).extractDataFromCSVs
   22.50MB  0.69% 89.88%    92.01MB  2.82%  encoding/json.Unmarshal
   20.01MB  0.61% 90.49%    20.01MB  0.61%  reflect.mapassign_faststr0
   19.50MB   0.6% 91.09%   208.03MB  6.39%  github.com/golang/geo/s2.(*coverer).newCandidate
   19.01MB  0.58% 91.68%  2507.20MB 76.97%  github.com/LdDl/horizon.getCachedPath
      19MB  0.58% 92.26%       19MB  0.58%  encoding/csv.(*Reader).readRecord
      17MB  0.52% 92.78%   109.01MB  3.35%  github.com/paulmach/go%2egeojson.UnmarshalGeometry
      13MB   0.4% 93.18%    91.02MB  2.79%  github.com/LdDl/horizon/spatial.(*S2Storage).SearchInRadius
    9.50MB  0.29% 93.47%    23.50MB  0.72%  encoding/json.(*decodeState).arrayInterface
    6.53MB   0.2% 93.67%   233.06MB  7.15%  github.com/LdDl/horizon/spatial.(*S2Storage).AddEdge
       6MB  0.18% 93.86%  2408.14MB 73.93%  github.com/LdDl/ch.(*QueryPool).shortestPath
    4.50MB  0.14% 93.99%   106.02MB  3.25%  github.com/LdDl/horizon/spatial.(*S2Storage).NearestNeighborsInRadius
    3.50MB  0.11% 94.10%    19.50MB   0.6%  encoding/json.(*decodeState).valueInterface
       3MB 0.092% 94.19%    37.61MB  1.15%  github.com/LdDl/horizon.(*MapMatcher).PrepareViterbi
       2MB 0.061% 94.26%   208.53MB  6.40%  github.com/golang/geo/s2.(*coverer).addCandidate
       2MB 0.061% 94.32%   205.53MB  6.31%  github.com/golang/geo/s2.(*coverer).expandChildren
    1.50MB 0.046% 94.36%       25MB  0.77%  encoding/json.(*decodeState).array
       1MB 0.031% 94.39%    78.51MB  2.41%  encoding/json.(*decodeState).object
       1MB 0.031% 94.42%    78.51MB  2.41%  github.com/paulmach/go%2egeojson.(*Geometry).UnmarshalJSON
         0     0% 94.42%   352.17MB 10.81%  container/heap.Push
         0     0% 94.42%       19MB  0.58%  encoding/csv.(*Reader).Read
         0     0% 94.42%    78.51MB  2.41%  encoding/json.(*decodeState).unmarshal
         0     0% 94.42%    78.51MB  2.41%  encoding/json.(*decodeState).value
         0     0% 94.42%  2488.19MB 76.38%  github.com/LdDl/ch.(*QueryPool).ShortestPath
         0     0% 94.42%  2399.64MB 73.67%  github.com/LdDl/ch.(*QueryPool).shortestPathCore
         0     0% 94.42%    42.61MB  1.31%  github.com/LdDl/horizon.(*MapMatcher).Run.func1
         0     0% 94.42%   443.81MB 13.62%  github.com/LdDl/horizon.BenchmarkMapMatcherSRID_4326BIG
         0     0% 94.42%  2763.31MB 84.83%  github.com/LdDl/horizon.BenchmarkMapMatcherSRID_4326BIG.func1
         0     0% 94.42%   443.81MB 13.62%  github.com/LdDl/horizon.NewMapMatcherFromFiles
         0     0% 94.42%   443.81MB 13.62%  github.com/LdDl/horizon.prepareEngine
         0     0% 94.42%   106.02MB  3.25%  github.com/LdDl/horizon/spatial.(*S2Storage).FindNearestInRadius
         0     0% 94.42%   188.53MB  5.79%  github.com/golang/geo/s2.(*Polyline).IntersectsCell
         0     0% 94.42%   238.03MB  7.31%  github.com/golang/geo/s2.(*RegionCoverer).CellUnion
         0     0% 94.42%   239.03MB  7.34%  github.com/golang/geo/s2.(*RegionCoverer).Covering
         0     0% 94.42%   230.03MB  7.06%  github.com/golang/geo/s2.(*coverer).coveringInternal
         0     0% 94.42%    82.01MB  2.52%  github.com/golang/geo/s2.(*coverer).initialCandidates
         0     0% 94.42%    65.01MB  2.00%  github.com/golang/geo/s2.Cell.DistanceToEdge
         0     0% 94.42%   253.54MB  7.78%  github.com/golang/geo/s2.NewChainEdgeCrosser
         0     0% 94.42%    20.01MB  0.61%  reflect.Value.SetMapIndex
         0     0% 94.42%    20.01MB  0.61%  reflect.mapassign_faststr
         0     0% 94.42%  2761.13MB 84.76%  testing.(*B).launch
         0     0% 94.42%   445.98MB 13.69%  testing.(*B).run1.func1
         0     0% 94.42%  3207.11MB 98.46%  testing.(*B).runN

Summary:

Performance Comparison: ch v1.7.7 → v1.10.0 (QueryPool API)

CPU Profile

Metric OLD (v1.7.7) NEW (v1.10.0)
Duration 10.47s 7.32s
Total CPU samples 58.64s 12.10s
CPU utilization 559% 165%

Where CPU time was spent

Function OLD NEW
runtime.scanobject (GC) 79.76% 37.19%
runtime.gcDrain (GC) 81.04% 38.84%
Actual algorithm work ~15% ~50%

Memory Profile

Metric OLD (v1.7.7) NEW (v1.10.0)
Total allocations 39,530 MB 3,257 MB
shortestPath allocations 38,702 MB (98%) 1,555 MB (48%)

The old Graph.ShortestPath() was allocating ~39 GB during the benchmark, causing the GC to consume ~80% of CPU time. The new QueryPool.ShortestPath() reuses internal state, reducing allocations by 12x and shifting CPU usage from garbage collection to actual SP work.

Since new version of CH has improved ManyToMany query I will consider to make another PR in future to replace current OneToOne query verision

@LdDl
LdDl merged commit 929442b into master Nov 30, 2025
@LdDl LdDl added enhancement New feature or request core labels Nov 30, 2025
@LdDl LdDl self-assigned this Nov 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

⌂ 换网址