Skip to content

Commit

Permalink
*: update deps (#196)
Browse files Browse the repository at this point in the history
- make github dependant bot, clippy and rustfmt happy
- use codecov token

Signed-off-by: Jay Lee <[email protected]>
  • Loading branch information
BusyJay authored Apr 16, 2024
1 parent bb041a7 commit 49dc9b5
Show file tree
Hide file tree
Showing 21 changed files with 134 additions and 126 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
name: Setup Cargo Toolchain 🛎️
with:
components: rustfmt, clippy, llvm-tools-preview
toolchain: stable
toolchain: nightly
default: true
- name: Check Code Format 🔧
run: |
Expand All @@ -48,7 +48,9 @@ jobs:
- name: Running Tests With Code Coverage 🚀
run: cargo llvm-cov --all-features --workspace --lcov --output-path lcov.info
- name: Upload Coverage To Codecov ⬆️
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
files: lcov.info
fail_ci_if_error: true
Expand Down
5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,14 @@ parking_lot = "0.11"
prost = "0.8"
proto = { path = "proto" }
rand = "0.7"
rocksdb = { version = "0.15", optional = true }
rocksdb = { version = "0.22", optional = true }
skiplist = { path = "skiplist" }
tempdir = "0.3"
tempfile = "3"
thiserror = "1.0"
yatp = { git = "https://github.com/tikv/yatp.git", rev = "b793461ea4abd202798cda6e20e97a054103f2ad" }

[dev-dependencies]
criterion = "0.3"
tempfile = "3"

[target.'cfg(not(target_env = "msvc"))'.dev-dependencies]
tikv-jemallocator = "0.4.0"
Expand Down
4 changes: 2 additions & 2 deletions agate_bench/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ bytes = "1.0"
clap = "2.33"
indicatif = "0.15"
rand = "0.7"
rocksdb = { version = "0.15", optional = true }
tempdir = "0.3"
rocksdb = { version = "0.22", optional = true }
tempfile = "3.0"
threadpool = "1.8"
yatp = { git = "https://github.com/tikv/yatp.git", rev = "b793461ea4abd202798cda6e20e97a054103f2ad" }

Expand Down
6 changes: 4 additions & 2 deletions benches/bench_iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use bytes::Bytes;
use common::get_table_for_benchmark;
use criterion::{criterion_group, criterion_main, Criterion};
use rand::{thread_rng, Rng};
use tempdir::TempDir;

fn get_test_options() -> AgateOptions {
agatedb::AgateOptions {
Expand All @@ -20,7 +19,10 @@ fn get_test_options() -> AgateOptions {
}

fn bench_iterator(c: &mut Criterion) {
let dir = TempDir::new("agatedb").unwrap();
let dir = tempfile::Builder::new()
.prefix("agatedb")
.tempdir()
.unwrap();
let mut opt = get_test_options();
opt.dir = dir.path().to_path_buf();
opt.value_dir = dir.path().to_path_buf();
Expand Down
37 changes: 24 additions & 13 deletions benches/benches_agate_rocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use common::{
rocks_randread,
};
use criterion::{criterion_group, criterion_main, Criterion};
use tempdir::TempDir;

// We will process `CHUNK_SIZE` items in a thread, and in one certain thread,
// we will process `BATCH_SIZE` items in a transaction or write batch.
Expand All @@ -25,7 +24,10 @@ const SMALL_VALUE_SIZE: usize = 32;
const LARGE_VALUE_SIZE: usize = 4096;

fn bench_agate(c: &mut Criterion) {
let dir = TempDir::new("agatedb-bench-small-value").unwrap();
let dir = tempfile::Builder::new()
.prefix("agatedb-bench-small-value")
.tempdir()
.unwrap();
let dir_path = dir.path();
let mut opts = AgateOptions {
dir: dir_path.to_path_buf(),
Expand All @@ -39,7 +41,7 @@ fn bench_agate(c: &mut Criterion) {
b.iter_custom(|iters| {
let mut total = Duration::new(0, 0);

(0..iters).into_iter().for_each(|_| {
(0..iters).for_each(|_| {
remove_files(dir_path);
let agate = Arc::new(opts.open().unwrap());

Expand All @@ -63,7 +65,7 @@ fn bench_agate(c: &mut Criterion) {
b.iter_custom(|iters| {
let mut total = Duration::new(0, 0);

(0..iters).into_iter().for_each(|_| {
(0..iters).for_each(|_| {
remove_files(dir_path);
let agate = Arc::new(opts.open().unwrap());

Expand Down Expand Up @@ -98,7 +100,10 @@ fn bench_agate(c: &mut Criterion) {
});

dir.close().unwrap();
let dir = TempDir::new("agatedb-bench-large-value").unwrap();
let dir = tempfile::Builder::new()
.prefix("agatedb-bench-large-value")
.tempdir()
.unwrap();
let dir_path = dir.path();
opts.dir = dir_path.to_path_buf();
opts.value_dir = dir_path.to_path_buf();
Expand All @@ -107,7 +112,7 @@ fn bench_agate(c: &mut Criterion) {
b.iter_custom(|iters| {
let mut total = Duration::new(0, 0);

(0..iters).into_iter().for_each(|_| {
(0..iters).for_each(|_| {
remove_files(dir_path);
let agate = Arc::new(opts.open().unwrap());

Expand All @@ -131,7 +136,7 @@ fn bench_agate(c: &mut Criterion) {
b.iter_custom(|iters| {
let mut total = Duration::new(0, 0);

(0..iters).into_iter().for_each(|_| {
(0..iters).for_each(|_| {
remove_files(dir_path);
let agate = Arc::new(opts.open().unwrap());

Expand Down Expand Up @@ -169,7 +174,10 @@ fn bench_agate(c: &mut Criterion) {
}

fn bench_rocks(c: &mut Criterion) {
let dir = TempDir::new("rocks-bench-small-value").unwrap();
let dir = tempfile::Builder::new()
.prefix("rocks-bench-small-value")
.tempdir()
.unwrap();
let dir_path = dir.path();
let mut opts = rocksdb::Options::default();
opts.create_if_missing(true);
Expand All @@ -179,7 +187,7 @@ fn bench_rocks(c: &mut Criterion) {
b.iter_custom(|iters| {
let mut total = Duration::new(0, 0);

(0..iters).into_iter().for_each(|_| {
(0..iters).for_each(|_| {
remove_files(dir_path);
let db = Arc::new(rocksdb::DB::open(&opts, &dir).unwrap());

Expand All @@ -196,7 +204,7 @@ fn bench_rocks(c: &mut Criterion) {
b.iter_custom(|iters| {
let mut total = Duration::new(0, 0);

(0..iters).into_iter().for_each(|_| {
(0..iters).for_each(|_| {
remove_files(dir_path);
let db = Arc::new(rocksdb::DB::open(&opts, &dir).unwrap());

Expand Down Expand Up @@ -229,14 +237,17 @@ fn bench_rocks(c: &mut Criterion) {
});

dir.close().unwrap();
let dir = TempDir::new("rocks-bench-large-value").unwrap();
let dir = tempfile::Builder::new()
.prefix("rocks-bench-large-value")
.tempdir()
.unwrap();
let dir_path = dir.path();

c.bench_function("rocks sequentially populate large value", |b| {
b.iter_custom(|iters| {
let mut total = Duration::new(0, 0);

(0..iters).into_iter().for_each(|_| {
(0..iters).for_each(|_| {
remove_files(dir_path);
let db = Arc::new(rocksdb::DB::open(&opts, &dir).unwrap());

Expand All @@ -253,7 +264,7 @@ fn bench_rocks(c: &mut Criterion) {
b.iter_custom(|iters| {
let mut total = Duration::new(0, 0);

(0..iters).into_iter().for_each(|_| {
(0..iters).for_each(|_| {
remove_files(dir_path);
let db = Arc::new(rocksdb::DB::open(&opts, &dir).unwrap());

Expand Down
9 changes: 6 additions & 3 deletions benches/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use bytes::{Bytes, BytesMut};
use rand::{distributions::Alphanumeric, Rng};
#[cfg(feature = "enable-rocksdb")]
use rocksdb::DB;
use tempdir::TempDir;
use tempfile::TempDir;

pub fn rand_value() -> String {
rand::thread_rng()
Expand Down Expand Up @@ -48,7 +48,10 @@ impl DerefMut for TableGuard {
}

pub fn get_table_for_benchmark(count: usize) -> TableGuard {
let tmp_dir = TempDir::new("agatedb").unwrap();
let tmp_dir = tempfile::Builder::new()
.prefix("agatedb")
.tempdir()
.unwrap();

let agate_opts = AgateOptions {
block_size: 4 * 1024,
Expand Down Expand Up @@ -91,7 +94,7 @@ pub fn unix_time() -> u64 {
}

pub fn remove_files(path: &Path) {
read_dir(path).unwrap().into_iter().for_each(|entry| {
read_dir(path).unwrap().for_each(|entry| {
let entry = entry.unwrap();
remove_file(entry.path()).unwrap();
});
Expand Down
6 changes: 5 additions & 1 deletion skiplist/benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ fn append_ts(key: &mut BytesMut, ts: u64) {
fn random_key(rng: &mut ThreadRng) -> Bytes {
let mut key = BytesMut::with_capacity(16);
unsafe {
rng.fill_bytes(mem::transmute(&mut key.chunk_mut()[..8]));
rng.fill_bytes(
mem::transmute::<&mut [std::mem::MaybeUninit<u8>], &mut [u8]>(
&mut key.spare_capacity_mut()[..8],
),
);
key.advance_mut(8);
}
append_ts(&mut key, 0);
Expand Down
3 changes: 2 additions & 1 deletion skiplist/src/list.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
#![allow(clippy::arc_with_non_send_sync)]

use std::{
mem, ptr,
ptr::NonNull,
sync::{
atomic::{AtomicUsize, Ordering},
Arc,
},
u32,
};

use bytes::Bytes;
Expand Down
10 changes: 5 additions & 5 deletions src/batch.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use crate::Agate;
use crate::{entry::Entry, ops::transaction::Transaction};
use crate::{Error, Result};
use std::sync::Arc;

use bytes::Bytes;
use std::sync::Arc;

use crate::{entry::Entry, ops::transaction::Transaction, Agate, Error, Result};

/// WriteBatch helps write multiple entries to database
pub struct WriteBatch {
Expand Down Expand Up @@ -127,11 +126,12 @@ impl WriteBatch {

#[cfg(test)]
mod tests {
use bytes::Bytes;

use crate::{
db::tests::{generate_test_agate_options, run_agate_test},
AgateOptions,
};
use bytes::Bytes;

fn test_with_options(opts: AgateOptions) {
let key = |i| Bytes::from(format!("{:10}", i));
Expand Down
2 changes: 1 addition & 1 deletion src/bloom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl<'a> Bloom<'a> {
// 0.69 is approximately ln(2)
let k = ((bits_per_key as f64) * 0.69) as u32;
// limit k in [1, 30]
let k = k.min(30).max(1);
let k = k.clamp(1, 30);
// For small len(keys), we set a minimum bloom filter length to avoid high FPR
let nbits = (keys.len() * bits_per_key).max(64);
let nbytes = (nbits + 7) / 8;
Expand Down
2 changes: 1 addition & 1 deletion src/checksum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub fn verify_checksum(data: &[u8], expected: &Checksum) -> Result<()> {
}

mod xxhash {
use std::{ptr, u64};
use std::ptr;

const PRIME1: u64 = 11400714785074694791;
const PRIME2: u64 = 14029467366897019727;
Expand Down
14 changes: 6 additions & 8 deletions src/db/tests.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::path::Path;

use bytes::{Bytes, BytesMut};
use tempdir::TempDir;
use tempfile::tempdir;

use super::*;
Expand Down Expand Up @@ -51,7 +50,7 @@ fn test_ensure_room_for_write() {
let mut opts = AgateOptions::default();
let tmp_dir = tempdir().unwrap();
opts.dir = tmp_dir.path().to_path_buf();
opts.value_dir = opts.dir.clone();
opts.value_dir.clone_from(&opts.dir);

// Wal::zero_next_entry will need MAX_HEADER_SIZE bytes free space.
// So we should put bytes more than value_log_file_size but less than
Expand Down Expand Up @@ -119,13 +118,12 @@ pub fn run_agate_test<F>(opts: Option<AgateOptions>, test_fn: F)
where
F: FnOnce(Arc<Agate>),
{
let tmp_dir = TempDir::new("agatedb").unwrap();
let tmp_dir = tempfile::Builder::new()
.prefix("agatedb")
.tempdir()
.unwrap();

let mut opts = if let Some(opts) = opts {
opts
} else {
AgateOptions::default()
};
let mut opts = opts.unwrap_or_default();

if !opts.in_memory {
opts.dir = tmp_dir.as_ref().to_path_buf();
Expand Down
4 changes: 2 additions & 2 deletions src/format.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{ptr, u64};
use std::ptr;

use bytes::{BufMut, Bytes, BytesMut};

Expand All @@ -10,7 +10,7 @@ pub fn key_with_ts(key: impl Into<BytesMut>, ts: u64) -> Bytes {

/// Append a ts to make this key be the first one within range.
pub fn key_with_ts_first(key: impl Into<BytesMut>) -> Bytes {
key_with_ts(key, std::u64::MAX)
key_with_ts(key, u64::MAX)
}

/// Append a ts to make this key be the last one within range.
Expand Down
6 changes: 3 additions & 3 deletions src/levels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ impl LevelsControllerInner {
// TODO: Check this.
let mut buf = BytesMut::with_capacity(biggest.len() + 8);
buf.put(user_key(biggest));
let right = key_with_ts(buf, std::u64::MAX);
let right = key_with_ts(buf, u64::MAX);
add_range(&mut compact_def.splits, right);
}
}
Expand Down Expand Up @@ -638,7 +638,7 @@ impl LevelsControllerInner {

// Make the output always one file to decreases the L0 table stalls and
// improves the performance.
compact_def.targets.file_size[0] = std::u32::MAX as u64;
compact_def.targets.file_size[0] = u32::MAX as u64;

Ok(())
}
Expand All @@ -664,7 +664,7 @@ impl LevelsControllerInner {
let mut out = vec![];

if !compact_def.drop_prefixes.is_empty() {
out = this_level.tables.clone();
out.clone_from(&this_level.tables);
} else {
let mut kr = KeyRange::default();
// Start from the oldest file first.
Expand Down
Loading

0 comments on commit 49dc9b5

Please sign in to comment.