Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch key hash to xxh3 #478

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

flyingmutant
Copy link
Contributor

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

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
```
@hrissan hrissan marked this pull request as ready for review May 27, 2023 19:22
@hrissan hrissan requested a review from a team as a code owner May 27, 2023 19:22
@hrissan
Copy link
Contributor

hrissan commented May 27, 2023

Возможно стоит в хэш включить сразу новые поля. 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

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.

2 participants