Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: bftree

on:
push:
branches:
- main
pull_request:
branches: [main]

jobs:
check-fmt-build:
runs-on: ubuntu-22.04
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
- run: rustup component add rustfmt clippy
- run: cargo install -f cargo-fuzz
# Temporarily allow warnings due to spdk feature disabled in benchmark.
- run: cargo clippy --features "metrics-rt, tracing"
- run: cargo clippy --features "metrics-rt-debug-all, tracing"
- run: cargo clippy --features "metrics-rt-debug-timer, tracing"
- run: cargo fmt --all -- --check
- run: cd benchmark && cargo clippy
- run: cd benchmark && cargo clippy --features "metrics-rt"
- run: cd benchmark && cargo clippy --features "metrics-rt-debug-all"
- run: cd benchmark && cargo clippy --features "metrics-rt-debug-timer"
- run: cd fuzz && cargo clippy
- run: cd fuzz && cargo fmt --all -- --check
- run: cd fuzz && cargo build

test_sans:
needs: check-fmt-build
runs-on: ubuntu-22.04
timeout-minutes: 60
env:
RUST_BACKTRACE: 1
steps:
- uses: actions/checkout@v3
- run: rustup component add rust-src
- run: rustup toolchain install nightly --component rust-src
- run: sudo apt update && sudo apt install -y llvm-dev
- run: echo "PATH=/usr/lib/llvm-14/bin:$PATH" >> $GITHUB_ENV
- run: cargo test
- run: >
env ASAN_OPTIONS="detect_odr_violation=0" RUSTFLAGS="-Z sanitizer=address"
cargo +nightly test -Zbuild-std --target x86_64-unknown-linux-gnu --tests
# Temporarily disabled
# I believe it is a bug elsewhere, not from us.
# - run: >
# env RUSTFLAGS="-Z sanitizer=memory"
# cargo test -Zbuild-std --target x86_64-unknown-linux-gnu --tests
- run: >
env RUST_BACKTRACE=1
cargo test --features "shuttle" --release shuttle_bf_tree_concurrent_operations
- run: >
env RUST_BACKTRACE=1
cargo test --features "shuttle" --release shuttle_cpr_snapshot_disk
- run: >
env RUST_BACKTRACE=1
cargo test --features "shuttle" --release shuttle_cpr_snapshot_cache_only
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bf-tree"
version = "0.5.3"
version = "0.5.4"
edition = "2021"
license = "MIT"
description = "Bf-Tree is a modern read-write-optimized concurrent larger-than-memory range index in Rust from Microsoft Research."
Expand Down
55 changes: 11 additions & 44 deletions benchmark/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 7 additions & 38 deletions fuzz/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1179,9 +1179,9 @@ impl CPRSnapShotMgr {
recovery_snapshot_vfs.read(*offset, &mut inner_node_page_buffer);
let inner_node = InnerNodeBuilder::new().build_from_slice(&inner_node_page_buffer);
if unsafe { (*inner_node).is_root() } {
println!("Here");
root_cnt += 1;
}
InnerNode::free_node(inner_node);
}
assert_eq!(root_cnt, 1, "Root count in inner mapping: {}", root_cnt);

Expand Down Expand Up @@ -2076,7 +2076,7 @@ mod tests {
let mut runner = shuttle::PortfolioRunner::new(true, shuttle_config);
let available_cores = std::thread::available_parallelism().unwrap().get().min(4);
for _ in 0..available_cores {
runner.add(shuttle::scheduler::PctScheduler::new(5, 400));
runner.add(shuttle::scheduler::PctScheduler::new(10, 1000));
}

runner.run(|| {
Expand Down Expand Up @@ -2203,7 +2203,7 @@ mod tests {
let mut runner = shuttle::PortfolioRunner::new(true, shuttle_config);
let available_cores = std::thread::available_parallelism().unwrap().get().min(4);
for _ in 0..available_cores {
runner.add(shuttle::scheduler::PctScheduler::new(5, 400));
runner.add(shuttle::scheduler::PctScheduler::new(10, 100));
}

runner.run(|| {
Expand Down
2 changes: 1 addition & 1 deletion src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::{
fs::{MemoryVfs, StdVfs, VfsImpl},
mini_page_op::{LeafEntrySLocked, LeafEntryXLocked},
nodes::{LeafNode, PageID},
snapshot::{CPRSnapShotMgr},
snapshot::CPRSnapShotMgr,
utils::{rw_lock::RwLock, MappingTable},
Config, StorageBackend,
};
Expand Down
24 changes: 20 additions & 4 deletions src/tests/concurrent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@ use shuttle::rand::{thread_rng, Rng};
#[cfg(not(feature = "shuttle"))]
use rand::Rng;

macro_rules! rand_range {
($rng:expr, $range:expr) => {{
#[cfg(feature = "shuttle")]
{
$rng.gen_range($range)
}
#[cfg(not(feature = "shuttle"))]
{
$rng.random_range($range)
}
}};
}

fn make_key(key: u32, len: usize) -> Vec<u8> {
let bytes = key.to_ne_bytes();
bytes.into_iter().cycle().take(len).collect::<Vec<_>>()
Expand Down Expand Up @@ -58,22 +71,25 @@ fn concurrent_ops() {
let handle = thread::spawn(move || {
let mut buffer = vec![0u8; 4096];

#[cfg(feature = "shuttle")]
let mut rng = thread_rng();
#[cfg(not(feature = "shuttle"))]
let mut rng = rand::rng();
let current_tid = thread::current().id();
black_box(current_tid);

for op_n in 0..config.op_cnt_per_thread {
black_box(op_n);
match rng.random_range(0..OP_RANGE) {
match rand_range!(rng, 0..OP_RANGE) {
0..=1 => {
// insert
let key = rng.random_range(0..config.key_range);
let key = rand_range!(rng, 0..config.key_range);
let kv = make_key(key, config.key_len);
let _unused = tree_clone.insert(&kv, &kv);
}
2 => {
// read
let key = rng.random_range(0..config.key_range);
let key = rand_range!(rng, 0..config.key_range);
let kv = make_key(key, config.key_len);
let cnt = tree_clone.read(&kv, &mut buffer);

Expand All @@ -86,7 +102,7 @@ fn concurrent_ops() {
}
3 => {
// delete
let key = rng.random_range(0..config.key_range);
let key = rand_range!(rng, 0..config.key_range);
let kv = make_key(key, config.key_len);
tree_clone.delete(&kv);
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/mapping_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl<T> Default for MappingTable<T> {
impl<T> Drop for MappingTable<T> {
fn drop(&mut self) {
let mut states = self.states.lock().unwrap();
let initialized_records = states.next_id - 1;
let initialized_records = states.next_id;
for i in 0..initialized_records {
let batch_id = self.get_batch_id(i);
let record_id = self.get_record_id(i);
Expand Down
Loading
Loading