forked from rust-rocksdb/rust-rocksdb
-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add recycle log configuration (#297)
* add recycle log configuration Signed-off-by: siddontang <siddontang@gmail.com>
- Loading branch information
1 parent
9940d00
commit b3410db
Showing
7 changed files
with
117 additions
and
0 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 |
---|---|---|
|
@@ -11,6 +11,7 @@ exclude = [ | |
".travis.yml", | ||
"deploy.sh", | ||
"tests/**/*", | ||
"benches/**/*", | ||
] | ||
|
||
[features] | ||
|
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,82 @@ | ||
// Copyright 2019 PingCAP, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
use super::rocksdb::{ColumnFamilyOptions, DBOptions, WriteOptions, DB}; | ||
use super::tempdir::TempDir; | ||
|
||
use super::test::Bencher; | ||
|
||
fn run_bench_wal(b: &mut Bencher, name: &str, mut opts: DBOptions, wopts: WriteOptions) { | ||
let path = TempDir::new(name).expect(""); | ||
let path_str = path.path().to_str().unwrap(); | ||
opts.create_if_missing(true); | ||
opts.set_max_background_jobs(6); | ||
opts.set_max_subcompactions(2); | ||
|
||
let mut cf_opts = ColumnFamilyOptions::new(); | ||
cf_opts.set_write_buffer_size(16 * 1024); | ||
cf_opts.set_max_write_buffer_number(10); | ||
|
||
let db = DB::open_cf(opts, path_str, vec![("default", cf_opts)]).unwrap(); | ||
|
||
let value = vec![1; 1024]; | ||
|
||
let mut i = 0; | ||
b.iter(|| { | ||
let key = format!("key_{}", i); | ||
db.put_opt(key.as_bytes(), &value, &wopts).unwrap(); | ||
i += 1; | ||
}); | ||
|
||
drop(db); | ||
} | ||
|
||
fn run_bench_wal_recycle_log(b: &mut Bencher, name: &str, recycled: bool) { | ||
let mut opts = DBOptions::new(); | ||
if recycled { | ||
opts.set_recycle_log_file_num(10); | ||
} | ||
|
||
let mut wopts = WriteOptions::new(); | ||
wopts.set_sync(true); | ||
|
||
run_bench_wal(b, name, opts, wopts); | ||
} | ||
|
||
#[bench] | ||
fn bench_wal_with_recycle_log(b: &mut Bencher) { | ||
run_bench_wal_recycle_log(b, "_rust_rocksdb_wal_with_recycle_log", true); | ||
} | ||
|
||
#[bench] | ||
fn bench_wal_without_recycle_log(b: &mut Bencher) { | ||
run_bench_wal_recycle_log(b, "_rust_rocksdb_wal_without_recycle_log", false); | ||
} | ||
|
||
#[bench] | ||
fn bench_wal_no_sync(b: &mut Bencher) { | ||
let opts = DBOptions::new(); | ||
let mut wopts = WriteOptions::new(); | ||
wopts.set_sync(false); | ||
|
||
run_bench_wal(b, "_rust_rocksdb_wal_no_sync", opts, wopts); | ||
} | ||
|
||
#[bench] | ||
fn bench_wal_disalbe_wal(b: &mut Bencher) { | ||
let opts = DBOptions::new(); | ||
let mut wopts = WriteOptions::new(); | ||
wopts.disable_wal(true); | ||
|
||
run_bench_wal(b, "_rust_rocksdb_wal_disable_wal", opts, wopts); | ||
} |
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,9 @@ | ||
extern crate test; | ||
|
||
extern crate byteorder; | ||
extern crate crc; | ||
extern crate rand; | ||
extern crate rocksdb; | ||
extern crate tempdir; | ||
|
||
mod bench_wal; |
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,17 @@ | ||
// Copyright 2019 PingCAP, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#![feature(test)] | ||
extern crate test; | ||
|
||
mod cases; |
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