-
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
mvcc: bad performance when range prefix with limit in large amount of keys #11057
Comments
My personal take on this:
Ref: |
@maomaozgw Thanks. What you said makes sense to me. Getting all rev pairs from memory index tree when client is only asking a limited number of keys, seems to be wasteful. Another potential concert is sorting provided by range API. Not sure if that will be violated - depends on if currently it trims before sort, or sort before trim. Another related issue: #11001 |
That's another issue, depends on current code, storeTxnRead.Range trims keys before sorted. |
Oh actually it temporarily clears the limit if client specifies sorting: Lines 258 to 263 in c798242
So the code looks like "trim before sort" but there will be no trimming when fetching key-values if sorting is needed. |
cc @YoyinZyc |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 21 days if no further activity occurs. Thank you for your contributions. |
I have a ETCD cluster with 2004938 keys, my application will range all keys from ETCD after started and keep watch key changes with clientv3/mirror, I found that will cost about 5 minutes to sync base data and during syncing the instance connected will found large number of etcd_server_slow_apply_total appeared.
After profiling the ETCD instance, I saw https://github.com/etcd-io/etcd/blob/master/mvcc/index.go#L106 will visit all indexes match the start & end, and most of the data will be dropped.
To resolve the problem, I change the behavior in Revisions to stop iterate after limitation reached when limitation larger than zero, and the sync time in reduce from 5 minutes to 7 seconds in this case.
Is it a good option to add a range option [noTotalCount], which can work with range with limitation to improve the performance of range requests ?
ETCD Version: 3.3.13
The text was updated successfully, but these errors were encountered: