In-memory Engine: optimize auto evict to reduce latency spike#18130
In-memory Engine: optimize auto evict to reduce latency spike#18130ti-chi-bot[bot] merged 10 commits intotikv:masterfrom
Conversation
Signed-off-by: Neil Shen <overvenus@gmail.com>
Signed-off-by: Neil Shen <overvenus@gmail.com>
Signed-off-by: Neil Shen <overvenus@gmail.com>
Signed-off-by: Neil Shen <overvenus@gmail.com>
Signed-off-by: Neil Shen <overvenus@gmail.com>
glorv
left a comment
There was a problem hiding this comment.
most LGTM, but I think request count only is a very poor metrics for region eviction.
| let is_cop_requests_low = crs.sma_cop_requests_avg | ||
| <= avg_cop_requests / SMA_COP_REQUEST_AVG_FILTER_FACTOR; | ||
|
|
||
| let is_cop_requests_reliable = |
There was a problem hiding this comment.
Does this mean if a region has no reuqest, it can be evicted at all?
There was a problem hiding this comment.
is_cop_requests_low means if a region has a few requests, then it will be an eviction candidate.
is_cop_requests_reliable means an eviction candidate can only be evicted if IME has sampled it three times (by default 30 minutes)
There was a problem hiding this comment.
Could you update the annotations with the above comments or incorporate them into the annotations? This would make the strategy for choosing eviction candidates clearer and easier to understand.
| }); | ||
| } | ||
|
|
||
| crss.sort_by(|a, b| { |
There was a problem hiding this comment.
Ideally, we should cache regions which to most reqeusts * (avg_kv_per_req_before_cache - avg_kv_per_req_after_cache), this can largely reflect the resource usage save after load. Thus, I think QPS or request_count is an even poorer metrics here.
There was a problem hiding this comment.
We can iterative improve the eviction algorithm, after all the master implementation is inaccurate, and this PR can reduce spike as tests show.
| in_gc: AtomicBool::new(source_meta.in_gc.load(Ordering::Relaxed)), | ||
| is_written: AtomicBool::new(source_meta.is_written.load(Ordering::Relaxed)), | ||
| evict_info: None, | ||
| average_cop_requests: Arc::new(Mutex::new(Default::default())), |
There was a problem hiding this comment.
So after region split, all child region's stats will be reset. Better derive the stats data from parent region.
| #[derive(Debug)] | ||
| /// Estimates the smoothed coprocessor request rate over the last hour using a | ||
| /// simple moving average. | ||
| pub(crate) type CopRequestsSMA = Smoother<f64, COP_REQUEST_SMA_RECORD_COUNT, ONE_HOUR_IN_SECS, 0>; |
There was a problem hiding this comment.
| pub(crate) type CopRequestsSMA = Smoother<f64, COP_REQUEST_SMA_RECORD_COUNT, ONE_HOUR_IN_SECS, 0>; | |
| pub(crate) type CopRequestsSma = Smoother<f64, COP_REQUEST_SMA_RECORD_COUNT, ONE_HOUR_IN_SECS, 0>; |
Follow the rust naming convension
Signed-off-by: Neil Shen <overvenus@gmail.com>
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: glorv, LykxSassinator The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
[LGTM Timeline notifier]Timeline:
|
|
/retest |
|
@overvenus: Your PR was out of date, I have automatically updated it for you. If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes. DetailsInstructions 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 ti-community-infra/tichi repository. |
|
/test pull-unit-test |
|
@overvenus: The specified target(s) for The following commands are available to trigger optional jobs: Use DetailsIn response to this:
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. |
|
/test all |
|
@overvenus there is a lint error |
Signed-off-by: Neil Shen <overvenus@gmail.com>
…into ime/fix-auto-load-evict-bounce Signed-off-by: Neil Shen <overvenus@gmail.com>
|
/merge |
|
@overvenus: We have migrated to builtin 👉 Please use
DetailsInstructions 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 ti-community-infra/tichi repository. |
|
In response to a cherrypick label: new pull request created to branch |
#18228) close #18093 Optimize auto evict to minimize coprocessor request latency by avoiding periodic eviction and loading of regions with high MVCC amplification. * Do not evict cached regions when memory has not reached the `stop-load-threshold`. * Replace MVCC amplification-based auto evict strategy with a simple moving average of coprocessor requests. This is because `RegionWriteCfCopDetail` only reflects MVCC amplification in IME, not in RocksDB, making low MVCC amplification a poor indicator for eviction. Signed-off-by: Neil Shen <overvenus@gmail.com> Co-authored-by: Neil Shen <overvenus@gmail.com>
What is changed and how it works?
Issue Number: Close #18093
What's Changed:
Tested with read-only workload.
Left: This PR
Right: nightly 2025-01-13
Related changes
Check List
Tests
Release note