-
Notifications
You must be signed in to change notification settings - Fork 9.8k
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
update:use google/btree in the genric way #14515
Conversation
server/storage/mvcc/index.go
Outdated
okeyi, _ := ti.tree.Get(keyi) | ||
if okeyi == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okeyi, _ := ti.tree.Get(keyi) | |
if okeyi == nil { | |
okeyi, ok := ti.tree.Get(keyi) | |
if !ok { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have made it by rebase.
Please signoff the commit: Please also compare the performance between |
I would check it. |
fdd9e49
to
e9e5366
Compare
Signed-off-by: wathenjiang <wathenjiang@tencent.com>
e9e5366
to
c53dfc7
Compare
(1) Test on func BenchmarkIndexPut(b *testing.B) {
log := zap.NewNop()
kvindex := newTreeIndex(log)
bytesN := 64
keys := createBytesSlice(bytesN, b.N)
b.ResetTimer()
for i := 1; i < b.N; i++ {
kvindex.Put(keys[i], revision{main: int64(i), sub: int64(i)})
}
} Test result on the master branch:
Test result on this pr:
(2) Test on func BenchmarkIndexGet(b *testing.B) {
log := zap.NewNop()
kvindex := newTreeIndex(log)
bytesN := 64
keys := createBytesSlice(bytesN, b.N)
for i := 1; i < b.N; i++ {
kvindex.Put(keys[i], revision{main: int64(i), sub: int64(i)})
}
b.ResetTimer()
for i := 1; i < b.N; i++ {
kvindex.Get(keys[i], int64(i))
}
} Test result on the master branch:
Test result on this pr:
|
Benchmark Test shows using google/tree in generic way can bring 5%~6% performance improvement. |
Related to #14463 |
Looks good to me, please,
|
05c661e
to
5b3e9ea
Compare
benchmark result: (1) master branch $ go test -bench='BenchmarkIndexPut$' -count=5 goos: darwin goarch: amd64 pkg: go.etcd.io/etcd/server/v3/storage/mvcc cpu: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz BenchmarkIndexPut-12 1000000 2591 ns/op BenchmarkIndexPut-12 1000000 2531 ns/op BenchmarkIndexPut-12 1000000 2536 ns/op BenchmarkIndexPut-12 1000000 2546 ns/op BenchmarkIndexPut-12 1000000 2538 ns/op PASS ok go.etcd.io/etcd/server/v3/storage/mvcc 167.439s $ go test -bench='BenchmarkIndexGet$' -count=5 goos: darwin goarch: amd64 pkg: go.etcd.io/etcd/server/v3/storage/mvcc cpu: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz BenchmarkIndexGet-12 1000000 2021 ns/op BenchmarkIndexGet-12 1000000 2029 ns/op BenchmarkIndexGet-12 1000000 2044 ns/op BenchmarkIndexGet-12 1000000 1973 ns/op BenchmarkIndexGet-12 1000000 2027 ns/op PASS ok go.etcd.io/etcd/server/v3/storage/mvcc 177.815s (2) google/btree in the generic way $ go test -bench='BenchmarkIndexPut$' -count=5 goos: darwin goarch: amd64 pkg: go.etcd.io/etcd/server/v3/storage/mvcc cpu: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz BenchmarkIndexPut-12 1000000 2477 ns/op BenchmarkIndexPut-12 1000000 2380 ns/op BenchmarkIndexPut-12 1000000 2360 ns/op BenchmarkIndexPut-12 1000000 2396 ns/op BenchmarkIndexPut-12 1000000 2382 ns/op PASS ok go.etcd.io/etcd/server/v3/storage/mvcc 165.841s $ go test -bench='BenchmarkIndexGet$' -count=5 goos: darwin goarch: amd64 pkg: go.etcd.io/etcd/server/v3/storage/mvcc cpu: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz BenchmarkIndexGet-12 1000000 1985 ns/op BenchmarkIndexGet-12 1000000 1914 ns/op BenchmarkIndexGet-12 1000000 1900 ns/op BenchmarkIndexGet-12 1000000 1905 ns/op BenchmarkIndexGet-12 1000000 1894 ns/op PASS ok go.etcd.io/etcd/server/v3/storage/mvcc 177.573s Signed-off-by: wathenjiang <wathenjiang@tencent.com>
5b3e9ea
to
319db38
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thank you @spongecaptain
And related to google/btree#45 |
Hi, etcd is very awsome. I learn a lot from etcd. By the way, the above close is a touch by mistake. |
…n etcdserver must be built with go version >= 1.18 etcdserver starts to using generic in etcd-io#14515, so any applications which depend on etcdserver must be built with go version >= 1.18. Signed-off-by: Benjamin Wang <wachao@vmware.com>
…n etcdserver must be built with go version >= 1.18 etcdserver starts to using generic in etcd-io#14515, so any applications which depend on package `go.etcd.io/etcd/server/v3' must be built with go version >= 1.18. Signed-off-by: Benjamin Wang <wachao@vmware.com>
Please note that this is a breaking change. Any applications which depend on 3.6 package Since golang officially supports only two latest minor releases, which means go 1.17 is out of support. So it should be fine. Anyway, I just added a breaking change item to 3.6 changelog. cc @serathius @spzala @ptabor |
@serathius @ahrtr |
Thanks @ptabor for the feedback. In general, With regard to the v3 API compatibility between 3.5 and 3.6, it seems be unrelated to this topic, and I don't think it should be mentioned in the breaking change section. |
…n etcd 3.6 packages must be built with go version >= 1.18 etcdserver starts to using generic in etcd-io#14515, so any applications which depend on package `go.etcd.io/etcd/server/v3' must be built with go version >= 1.18. Most likely we may depends on go 1.18 new features in other packages, i.e. client, pkg, so we just simplify the changelog message to require applications depending on any etcd 3.6 pacakges must be built with go version >= 1.18, although only etcdserver uses go generic for now. Signed-off-by: Benjamin Wang <wachao@vmware.com>
…n etcd 3.6 packages must be built with go version >= 1.18 etcdserver starts to using generic in etcd-io#14515, so any applications which depend on package `go.etcd.io/etcd/server/v3' must be built with go version >= 1.18. Most likely we may depends on go 1.18 new features in other packages, i.e. client, pkg, so we just simplify the changelog message to require applications depending on any etcd 3.6 pacakges must be built with go version >= 1.18, although only etcdserver uses go generic for now. Signed-off-by: Benjamin Wang <wachao@vmware.com>
mvcc: use google/btree in the genric way
As etcd bumped go1.19, using generic instead of cast interface{} to some type has better operation efficiency.
Signed-off-by: wathenjiang wathenjiang@tencent.com