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: abstract a general forward scanner #6218
Conversation
Signed-off-by: Yilin Chen <sticnarf@gmail.com>
Signed-off-by: Yilin Chen <sticnarf@gmail.com>
Signed-off-by: Yilin Chen <sticnarf@gmail.com>
/bench +tpch |
Signed-off-by: Yilin Chen <sticnarf@gmail.com>
/test |
Benchmark Report
@@ Benchmark Diff @@
================================================================================
tidb: a94cff903cd1e7f3b050db782da84273ef5592f4
--- tikv: 134c5663340c8e868f23bc2f3273b84168aed862
+++ tikv: 066a950cf6078d7b273e27a76b3cef177da18dc5
pd: 13ea87a019a51d143e4c44365b39c49a87047d72
================================================================================
01.sql duration: 17933.71 ms ± 0.59% (std=62.06) delta: -4.40% (p=0.205)
02.sql duration: 6755.99 ms ± 3.32% (std=122.95) delta: 0.68% (p=0.716)
03.sql duration: 17070.60 ms ± 2.93% (std=282.66) delta: -4.86% (p=0.000)
04.sql duration: 7305.43 ms ± 3.29% (std=136.09) delta: -2.57% (p=0.007)
06.sql duration: 9517.13 ms ± 8.15% (std=331.54) delta: -2.08% (p=0.496)
07.sql duration: 14008.61 ms ± 1.96% (std=153.83) delta: -1.93% (p=0.003)
08.sql duration: 12217.36 ms ± 2.21% (std=176.95) delta: -1.11% (p=0.055)
09.sql duration: 35329.91 ms ± 1.80% (std=350.91) delta: 0.26% (p=0.830)
10.sql duration: 9804.63 ms ± 2.42% (std=130.00) delta: -0.38% (p=0.889)
11.sql duration: 3555.22 ms ± 4.13% (std=77.16) delta: 2.94% (p=0.319)
12.sql duration: 11943.37 ms ± 4.52% (std=271.64) delta: 0.56% (p=0.930)
13.sql duration: 10187.38 ms ± 1.77% (std=125.55) delta: 1.18% (p=0.453)
14.sql duration: 10752.69 ms ± 0.47% (std=31.11) delta: -3.78% (p=0.003)
15.sql duration: 19747.68 ms ± 2.82% (std=346.68) delta: -3.38% (p=0.004)
16.sql duration: 3597.96 ms ± 5.34% (std=112.53) delta: 0.08% (p=0.576)
17.sql duration: 34445.30 ms ± 1.36% (std=250.00) delta: -1.99% (p=0.000)
18.sql duration: 49621.62 ms ± 6.84% (std=1681.65) delta: -0.45% (p=0.265)
19.sql duration: 15204.40 ms ± 3.45% (std=316.35) delta: -1.67% (p=0.070)
20.sql duration: 10860.65 ms ± 4.71% (std=239.24) delta: -2.37% (p=0.151)
21.sql duration: 28671.07 ms ± 1.26% (std=201.60) delta: -1.08% (p=0.005)
22.sql duration: 5295.88 ms ± 3.02% (std=82.92) delta: 1.13% (p=0.590) |
Signed-off-by: Yilin Chen <sticnarf@gmail.com>
…canner Signed-off-by: Yilin Chen <sticnarf@gmail.com>
4d24a24
to
43b750a
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.
Rest LGTM
@@ -140,73 +233,44 @@ impl<S: Snapshot> ForwardScanner<S> { | |||
} | |||
}; | |||
|
|||
// Use `from_encoded_slice` to reserve space for ts, so later we can append ts to | |||
// the key or its clones without reallocation. | |||
// // Use `from_encoded_slice` to reserve space for ts, so later we can append ts to |
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.
Double //
?
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.
Fixed
Signed-off-by: Yilin Chen <sticnarf@gmail.com>
/// Use `ScannerBuilder` to build `BackwardScanner`. | ||
pub struct BackwardScanner<S: Snapshot> { | ||
/// Use `ScannerBuilder` to build `BackwardKvScanner`. | ||
pub struct BackwardKvScanner<S: Snapshot> { |
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.
KV
is better?
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.
According to Rust's naming conventions, acronyms count as one word.
// Even if there is a lock error, we still need to step the cursor for future | ||
// calls. | ||
if result.is_err() { | ||
cursors.move_write_cursor_to_next_user_key(¤t_user_key, statistics)?; |
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.
when encountering conflict lock, now it moves write cursor to next user key no matter whether it has write for current user key.
seems it doesn't follow the previous behavior. It may skip a user key for the latter call?
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.
oh, I misread the code. it will check current_user_key
Signed-off-by: Yilin Chen <sticnarf@gmail.com>
…/tikv into general-forward-scanner
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
@overvenus PTAL |
if self.cfg.omit_value { | ||
return Ok(Some(vec![])); | ||
if cfg.omit_value { | ||
break Some(vec![]); |
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.
This is the first time I know this syntax.
@MyonKeminta PTAL |
/run-all-tests |
/merge |
/run-all-tests |
Signed-off-by: Yilin Chen <sticnarf@gmail.com>
Signed-off-by: Yilin Chen <sticnarf@gmail.com>
* mvcc: abstract a general forward scanner (#6218) Signed-off-by: Yilin Chen <sticnarf@gmail.com> * backup: support incremental backup (#6222) Signed-off-by: Yilin Chen <sticnarf@gmail.com> * adapt to 3.1 Signed-off-by: Yilin Chen <sticnarf@gmail.com> * fix Signed-off-by: Yilin Chen <sticnarf@gmail.com> Co-authored-by: Neil Shen <overvenus@gmail.com>
Signed-off-by: Yilin Chen <sticnarf@gmail.com>
What have you changed?
In order to reduce repeated code for forward scanner, txn entry scanner and delta scanner, we want to reuse the forward scanner code.
I introduce
ScanPolicy
trait to define the behavior when the scanner meets a lock or a key.Now this PR is a work in progress. It's just a refactor of the existing forward scanner.
What is the type of the changes?
How is the PR tested?
Does this PR affect documentation (docs) or should it be mentioned in the release notes?
Does this PR affect
tidb-ansible
?Refer to a related PR or issue link (optional)
Benchmark result if necessary (optional)
Any examples? (optional)