-
Notifications
You must be signed in to change notification settings - Fork 10.2k
Use SharedBufReadTxMode
for (*readView) Rev()
and (*readView) FirstRev()
#20411
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
Conversation
Hi @niuyueyang1996. Thanks for your PR. I'm waiting for a etcd-io member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Any performance improvement should be confirmed using benchmarks. I'm concerned here that switching to SharedBufReadTxnMode will reduce write throughput. We need data to confirm impact of this change on all operations. |
This optimization is limited to functions using newHeader, such as lease and auth operations. It will improve write performance for these types of requests. |
/ok-to-test |
Codecov Report❌ Patch coverage is Please upload reports for the commit c6002af to get more accurate results.
Additional details and impacted files
... and 50 files with indirect coverage changes @@ Coverage Diff @@
## main #20411 +/- ##
==========================================
- Coverage 70.09% 69.15% -0.95%
==========================================
Files 399 416 +17
Lines 34099 34707 +608
==========================================
+ Hits 23902 24000 +98
- Misses 8814 9311 +497
- Partials 1383 1396 +13 Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
d7c41e2
to
2184a5d
Compare
Thanks for the contribution! The benchmark result looks impressive. Actually I think we should use Can you please run the benchmark test (i.e. txn-put, range etc) ? etcd/server/storage/mvcc/kv_view.go Lines 26 to 36 in f072712
|
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, probably I did not say it clearly in #20411 (comment). I was saying to change to use |
server/storage/mvcc/kv_view.go
Outdated
type readViewRTxMode struct { | ||
KV | ||
rTxMode ReadTxMode | ||
} | ||
|
||
func ReadViewRTxMode(rv KV, rTxMode ReadTxMode) *readViewRTxMode { | ||
return &readViewRTxMode{ | ||
KV: rv, | ||
rTxMode: rTxMode, | ||
} | ||
} | ||
|
||
func (rv *readViewRTxMode) Rev() int64 { | ||
tr := rv.KV.Read(rv.rTxMode, traceutil.TODO()) | ||
defer tr.End() | ||
return tr.Rev() | ||
} | ||
|
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.
We don't need this change after using SharedBufReadTxMode
for both FirstRev
and Rev
.
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.
+1
ok. I'll make the changes. |
Note, I'm not worried about performance impact on After some thought, I think this could cause speedup in this scenario, because it will be cheaper to just read |
@niuyueyang1996 can you provide benchmark requests before and after the PR so that we know how much performance improvement we've achieved with this PR? thx |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
thx for the report.
|
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
Benchmark Observations: Single-key write scenarios: Concurrent multi-key write scenarios: |
Sorry if I'm asking too much, bit it would really help if you could combine the results into a table and highlight differences. |
benchmark
|
|
Results look good for me. One thing that I don't think |
Agreed. For Kubernetes-like multi-key usage scenarios, we should adopt txn-mixed benchmarking. The benchmark results in this PR suggest potential performance improvements. |
Overall looks good to me.
This PR shouldn't have any impact on the range requests at all. (It's easy to verify. Just to add logs something like below. They aren't called at all). The performance difference might be caused by OS factors, i.e. cache etc. Do you always get the same results? Probably changing the order (i.e. try "after" first, then "before" later) might an opposite result?
Similarly, this PR shouldn't have any impact on write or TXN. Your test result also confirmed this. |
You're absolutely correct. To validate consistency, I rebuilt the binaries twice on bare-metal servers and conducted controlled comparisons. The observed variance remains within the margin of error for standard benchmark fluctuations. |
Please also add a changelog something like below (either in this PR or in a separate PR) under https://github.com/etcd-io/etcd/blob/main/CHANGELOG/CHANGELOG-3.7.md#etcd-server, thx
It's be great if you can also verify the performance improvement on users/role operations. But the benchmark tool doesn't support users/roles, so you will need to improve the tool first. |
It's optional (It's unlikely that users frequently create/remove roles & users in production environment). It's OK to take care of this separately. |
SharedBufReadTxMode
for (*readView) Rev()
and (*readView) FirstRev()
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
thx
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ahrtr, niuyueyang1996, serathius The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
pls squash the commits, thx |
Signed-off-by: niuyueyang <[email protected]>
#20184