statshouse icon indicating copy to clipboard operation
statshouse copied to clipboard

Switch key hash to xxh3

Open flyingmutant opened this issue 2 years ago • 1 comments

Before:

goos: linux
goarch: amd64
pkg: github.com/vkcom/statshouse/internal/data_model
cpu: Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz
BenchmarkKey_Hash-8   	30437109	       37.24 ns/op

After:

goos: linux
goarch: amd64
pkg: github.com/vkcom/statshouse/internal/data_model
cpu: Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz
BenchmarkKey_Hash-8   	100000000	       10.35 ns/op

flyingmutant avatar May 26 '23 17:05 flyingmutant

Возможно стоит в хэш включить сразу новые поля. MoreKeys потом просто обьединится с Keys например. Тогда я смогу поддержать их сразу при вставке, и когда они реально появятся не надо будет ещё раз хэш менять.

Key struct {
	Timestamp uint32
	Metric    int32
	Keys      [format.MaxTags]int32 // Unused keys are set to special 0-value
	MoreKeys  [8]int32
	WideKeys   [4]int64 // _w0 _w1 _w2 _w3
}

SIP hash BenchmarkKey_Hash-8 17547135 34.62 ns/op SIP hash + 8 keys + 4 raw keys BenchmarkKey_Hash-8 17547135 57.40 ns/op

hrissan avatar May 27 '23 19:05 hrissan