Skip to content

Conversation

@proost
Copy link
Contributor

@proost proost commented Dec 10, 2025

Go vs Java benchmark: apache/datasketches-characterization#89

code:

func BenchmarkHashAndScreen(b *testing.B) {
	b.Run("most hashes passes", func(b *testing.B) {
		ht := NewHashtable(10, 10, ResizeX2, 1.0, MaxTheta, DefaultSeed, true)
		b.ReportAllocs()
		b.ResetTimer()
		for i := 0; i < b.N; i++ {
			_, _ = ht.HashInt64AndScreen(int64(i))
		}
	})

	b.Run("hashes exceed theta", func(b *testing.B) {
		ht := NewHashtable(10, 10, ResizeX2, 0.001, 1000, DefaultSeed, true)
		b.ReportAllocs()
		b.ResetTimer()
		for i := 0; i < b.N; i++ {
			_, _ = ht.HashInt64AndScreen(int64(i))
		}
	})
}
  • current code performance:
goos: darwin
goarch: arm64
pkg: github.com/apache/datasketches-go/theta
cpu: Apple M1 Pro
BenchmarkHashAndScreen
BenchmarkHashAndScreen/most_hashes_passes
BenchmarkHashAndScreen/most_hashes_passes-10         	240147729	         5.022 ns/op	       0 B/op	       0 allocs/op
BenchmarkHashAndScreen/hashes_exceed_theta
BenchmarkHashAndScreen/hashes_exceed_theta-10        	 9001977	       132.9 ns/op	      96 B/op	       4 allocs/op
  • changed:
goos: darwin
goarch: arm64
pkg: github.com/apache/datasketches-go/theta
cpu: Apple M1 Pro
BenchmarkHashAndScreen
BenchmarkHashAndScreen/most_hashes_passes
BenchmarkHashAndScreen/most_hashes_passes-10         	241465656	         4.943 ns/op	       0 B/op	       0 allocs/op
BenchmarkHashAndScreen/hashes_exceed_theta
BenchmarkHashAndScreen/hashes_exceed_theta-10        	246932887	         4.860 ns/op	       0 B/op	       0 allocs/op

Sorry for not considering performance in hot path when i wrote code and Thank you for accepting breaking change.

@freakyzoidberg
Copy link
Member

Don't be sorry, thanks for the time you put into this!

@freakyzoidberg freakyzoidberg merged commit a11870f into apache:main Dec 10, 2025
1 check passed
@proost proost deleted the perf-use-sentinel-error branch December 10, 2025 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants