Skip to content

perf: remove allocation in CM sketch - #161

Merged
proost merged 2 commits into
apache:mainfrom
proost:perf-remove-alloc-in-cm-sketch
Aug 1, 2026
Merged

perf: remove allocation in CM sketch#161
proost merged 2 commits into
apache:mainfrom
proost:perf-remove-alloc-in-cm-sketch

Conversation

@proost

@proost proost commented Jul 27, 2026

Copy link
Copy Markdown
Member

we can reduce allocating of slices to on-heap

If run the escape analysis,

count/count_min_sketch.go:97:31: make([]int64, c.numHashes) escapes to heap in (*CountMinSketch).getHashes:

Before:

goos: darwin
goarch: arm64
pkg: github.com/apache/datasketches-go/count
cpu: Apple M4 Pro
BenchmarkCountMinSketch_Update
BenchmarkCountMinSketch_Update-12    	34135192	        32.77 ns/op	      24 B/op	       1 allocs/op
PASS


goos: darwin
goarch: arm64
pkg: github.com/apache/datasketches-go/count
cpu: Apple M4 Pro
BenchmarkCountMinSketch_GetEstimate
BenchmarkCountMinSketch_GetEstimate-12    	34794710	        32.60 ns/op	      24 B/op	       1 allocs/op
PASS

After:

goos: darwin
goarch: arm64
pkg: github.com/apache/datasketches-go/count
cpu: Apple M4 Pro
BenchmarkCountMinSketch_Update
BenchmarkCountMinSketch_Update-12    	45174462	        26.34 ns/op	       0 B/op	       0 allocs/op
PASS

goos: darwin
goarch: arm64
pkg: github.com/apache/datasketches-go/count
cpu: Apple M4 Pro
BenchmarkCountMinSketch_GetEstimate
BenchmarkCountMinSketch_GetEstimate-12    	45396912	        26.71 ns/op	       0 B/op	       0 allocs/op
PASS

@proost proost self-assigned this Jul 27, 2026
@proost
proost merged commit c558cc2 into apache:main Aug 1, 2026
4 of 5 checks passed
@proost
proost deleted the perf-remove-alloc-in-cm-sketch branch August 1, 2026 05:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant