You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@datasketches.apache.org by "proost (via GitHub)" <gi...@apache.org> on 2025/12/10 03:18:01 UTC
[PR] perf: use direct comparison [datasketches-go]
proost opened a new pull request, #70:
URL: https://github.com/apache/datasketches-go/pull/70
previous PR: https://github.com/apache/datasketches-characterization/pull/89
current go version theta sketch performance is bad. one of reasons using `errors.Is`.
generally, go recommends "errors.Is" for error check, but we are using sentinel error. So we can avoid using errors.Is.
benchmark code:
```go
func BenchmarkUpdateSketchErrorHandling(b *testing.B) {
b.Run("UpdateInt64_NewKeys", func(b *testing.B) {
sketch, _ := NewQuickSelectUpdateSketch()
b.ResetTimer()
for i := 0; i < b.N; i++ {
_ = sketch.UpdateInt64(int64(i))
}
})
b.Run("UpdateInt64_DuplicateKeys", func(b *testing.B) {
sketch, _ := NewQuickSelectUpdateSketch()
_ = sketch.UpdateInt64(42)
b.ResetTimer()
for i := 0; i < b.N; i++ {
_ = sketch.UpdateInt64(42)
}
})
}
```
* Current UpdateSketch
```
goos: darwin
goarch: arm64
pkg: github.com/apache/datasketches-go/theta
cpu: Apple M1 Pro
BenchmarkUpdateSketchErrorHandling
BenchmarkUpdateSketchErrorHandling/UpdateInt64_NewKeys
BenchmarkUpdateSketchErrorHandling/UpdateInt64_NewKeys-10 7506458 150.9 ns/op
BenchmarkUpdateSketchErrorHandling/UpdateInt64_DuplicateKeys
BenchmarkUpdateSketchErrorHandling/UpdateInt64_DuplicateKeys-10 165562837 7.287 ns/op
```
* New UpdateSketch
```
BenchmarkUpdateSketchErrorHandling
BenchmarkUpdateSketchErrorHandling/UpdateInt64_NewKeys
BenchmarkUpdateSketchErrorHandling/UpdateInt64_NewKeys-10 7503918 143.6 ns/op
BenchmarkUpdateSketchErrorHandling/UpdateInt64_DuplicateKeys
BenchmarkUpdateSketchErrorHandling/UpdateInt64_DuplicateKeys-10 166055470 7.227 ns/op
```
benchmark code:
```go
func BenchmarkUnionUpdate(b *testing.B) {
b.Run("Update_NewKeys", func(b *testing.B) {
sketches := make([]*QuickSelectUpdateSketch, b.N)
for i := 0; i < b.N; i++ {
sketch, _ := NewQuickSelectUpdateSketch()
sketch.UpdateInt64(int64(i))
sketches[i] = sketch
}
union, _ := NewUnion()
b.ResetTimer()
for i := 0; i < b.N; i++ {
_ = union.Update(sketches[i])
}
})
b.Run("Update_DuplicateKeys", func(b *testing.B) {
sketches := make([]*QuickSelectUpdateSketch, b.N)
for i := 0; i < b.N; i++ {
sketch, _ := NewQuickSelectUpdateSketch()
sketch.UpdateInt64(42)
sketches[i] = sketch
}
union, _ := NewUnion()
b.ResetTimer()
for i := 0; i < b.N; i++ {
_ = union.Update(sketches[i])
}
})
}
```
* Current Union Update
```
goos: darwin
goarch: arm64
pkg: github.com/apache/datasketches-go/theta
cpu: Apple M1 Pro
BenchmarkUnionUpdate
BenchmarkUnionUpdate/Update_NewKeys
BenchmarkUnionUpdate/Update_NewKeys-10 8556276 457.7 ns/op
BenchmarkUnionUpdate/Update_DuplicateKeys
BenchmarkUnionUpdate/Update_DuplicateKeys-10 7176099 443.6 ns/op
```
* New Union Update
```
goos: darwin
goarch: arm64
pkg: github.com/apache/datasketches-go/theta
cpu: Apple M1 Pro
BenchmarkUnionUpdate
BenchmarkUnionUpdate/Update_NewKeys
BenchmarkUnionUpdate/Update_NewKeys-10 8699008 430.7 ns/op
BenchmarkUnionUpdate/Update_DuplicateKeys
BenchmarkUnionUpdate/Update_DuplicateKeys-10 7546215 292.6 ns/op
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@datasketches.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@datasketches.apache.org
For additional commands, e-mail: dev-help@datasketches.apache.org
Re: [PR] perf: use direct comparison [datasketches-go]
Posted by "proost (via GitHub)" <gi...@apache.org>.
proost commented on PR #70:
URL: https://github.com/apache/datasketches-go/pull/70#issuecomment-3635187649
Suggestion:
If breaking change is acceptable, Because we currently not release theta sketch officially, I'd like to change returning format error([like this](https://github.com/apache/datasketches-go/blob/main/theta/hashtable.go#L124)) to sentinel error. Chaning to sentinel error avoids heap allocation when hash exceeds theta.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@datasketches.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@datasketches.apache.org
For additional commands, e-mail: dev-help@datasketches.apache.org
Re: [PR] perf: use direct comparison [datasketches-go]
Posted by "freakyzoidberg (via GitHub)" <gi...@apache.org>.
freakyzoidberg merged PR #70:
URL: https://github.com/apache/datasketches-go/pull/70
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@datasketches.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@datasketches.apache.org
For additional commands, e-mail: dev-help@datasketches.apache.org
Re: [PR] perf: use direct comparison [datasketches-go]
Posted by "freakyzoidberg (via GitHub)" <gi...@apache.org>.
freakyzoidberg commented on PR #70:
URL: https://github.com/apache/datasketches-go/pull/70#issuecomment-3636111920
Thats cool, one of the benefit of not having done an official release yet
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@datasketches.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@datasketches.apache.org
For additional commands, e-mail: dev-help@datasketches.apache.org