forked from tikv/tikv
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
txn: only wake up waiters when locks are indeed released (tikv#7379)
Signed-off-by: youjiali1995 <zlwgx1023@gmail.com>
- Loading branch information
1 parent
f3d2ba4
commit 2c021d2
Showing
8 changed files
with
188 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright 2020 TiKV Project Authors. Licensed under Apache-2.0. | ||
|
||
use rand::{self, Rng, RngCore}; | ||
use tidb_query_datatype::{ | ||
codec::{datum, table, Datum}, | ||
expr::EvalContext, | ||
}; | ||
use txn_types::Key; | ||
|
||
#[inline] | ||
fn gen_rand_str(len: usize) -> Vec<u8> { | ||
let mut rand_str = vec![0; len]; | ||
rand::thread_rng().fill_bytes(&mut rand_str); | ||
rand_str | ||
} | ||
|
||
#[bench] | ||
fn bench_row_key_gen_hash(b: &mut test::Bencher) { | ||
let id: i64 = rand::thread_rng().gen(); | ||
let row_key = Key::from_raw(&table::encode_row_key(id, id)); | ||
b.iter(|| { | ||
test::black_box(row_key.gen_hash()); | ||
}); | ||
} | ||
|
||
#[bench] | ||
fn bench_index_key_gen_hash(b: &mut test::Bencher) { | ||
let id: i64 = rand::thread_rng().gen(); | ||
let encoded_index_val = datum::encode_key( | ||
&mut EvalContext::default(), | ||
&[Datum::Bytes(gen_rand_str(64))], | ||
) | ||
.unwrap(); | ||
let index_key = Key::from_raw(&table::encode_index_seek_key(id, id, &encoded_index_val)); | ||
b.iter(|| { | ||
test::black_box(index_key.gen_hash()); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
// Copyright 2018 TiKV Project Authors. Licensed under Apache-2.0. | ||
|
||
mod key; | ||
mod scan; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.