Skip to content
Open
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
9 changes: 6 additions & 3 deletions benches/op_ser_benches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@ fn rw_pareto(txn: Txn, mut vars: (f64, TVar<LTable<String, String>>)) {
if vars.0 < 0.8_f64 {
txn.begin(|t: &mut Txn| {
t.read(&vars.1);
});
})
.unwrap();
} else {
txn.begin(|t: &mut Txn| {
let mut x = t.read(&vars.1);
x.insert("RoboCop".into(), "Annihilation".into());
t.write(&mut vars.1, x.clone());
});
})
.unwrap();
}
}

Expand Down Expand Up @@ -81,7 +83,8 @@ fn pure_write(txn: Txn, mut vars: TVar<LTable<String, String>>) {
let mut x = t.read(&vars);
x.insert("RoboCop".into(), "Annihilation".into());
t.write(&mut vars, x.clone());
});
})
.unwrap();
}

fn bench_pure_write(c: &mut Criterion) {
Expand Down
2 changes: 1 addition & 1 deletion benches/zonemap_benches.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use criterion::{criterion_group, criterion_main, BatchSize, BenchmarkId, Criterion, Throughput};
use criterion::{criterion_group, criterion_main, BatchSize, Criterion};
use lever::index::zonemap::ZoneMap;

fn bench_zonemap_selected(c: &mut Criterion) {
Expand Down
6 changes: 4 additions & 2 deletions examples/basic_txn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ fn main() {
let mut churned = t.read(&customers);
churned += 1;
t.write(&mut customers, churned);
});
})
.unwrap();

println!(
"I have {} customers right now. I gained 1.",
Expand All @@ -37,7 +38,8 @@ fn main() {
let mut churned = *customers;
churned -= 123_000;
t.write(&mut customers, churned);
});
})
.unwrap();

println!(
"I have {} customers right now. I think I lost a lot.",
Expand Down
2 changes: 1 addition & 1 deletion examples/lotable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fn main() {
.name(format!("t_{}", thread_no))
.spawn(move || {
let key = format!("{}", thread_no);
lotable.insert(key.clone(), thread_no);
lotable.insert(key.clone(), thread_no).unwrap();
let _ = lotable.get(&key).unwrap();
})
.unwrap();
Expand Down
5 changes: 2 additions & 3 deletions src/htm/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,13 @@ mod lever_hwtxn_test {
#[test]
#[ignore]
fn hwtxn_block_test() {
let mut x = 123;
let x = 123;
std::thread::spawn(move || {
let htm = HTM();
assert_eq!(true, htm.begin().started());
x = x + 1;
let _ = x + 1;
assert_eq!(true, htm.test().in_txn());
htm.abort(&HwTxAbortCode::UserlandAbort);
assert_eq!(false, htm.test().in_txn());
});

std::thread::spawn(move || {
Expand Down
12 changes: 9 additions & 3 deletions src/sync/atomics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,14 @@ impl<T: Sized> AtomicBox<T> {
Arc::into_raw(total) as *mut T
}

fn compare_and_swap(&self, current: *mut T, new: *mut T, order: Ordering) -> *mut T {
self.ptr.compare_and_swap(current, new, order)
fn compare_exchange(
&self,
current: *mut T,
new: *mut T,
success: Ordering,
failure: Ordering,
) -> Result<*mut T, *mut T> {
self.ptr.compare_exchange(current, new, success, failure)
}

fn take(&self) -> Arc<T> {
Expand All @@ -40,7 +46,7 @@ impl<T: Sized> AtomicBox<T> {
continue;
}

if self.compare_and_swap(curr, null, Ordering::AcqRel) == curr {
if self.compare_exchange(curr, null, Ordering::AcqRel, Ordering::AcqRel) == Ok(curr) {
return unsafe { Arc::from_raw(curr) };
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/sync/ttas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ use super::ifaces::LockIface;
use std::fmt;
use std::{
cell::UnsafeCell,
sync::atomic::{spin_loop_hint, AtomicBool, Ordering},
hint::spin_loop,
sync::atomic::{AtomicBool, Ordering},
};
use std::{
marker::PhantomData as marker,
Expand Down Expand Up @@ -149,7 +150,7 @@ where
fn lock(&self) {
'lock: loop {
while let Some(true) = Some(self.acquired.load(Ordering::SeqCst)) {
spin_loop_hint();
spin_loop();
}
if !self.acquired.swap(true, Ordering::SeqCst) {
break 'lock;
Expand Down
34 changes: 17 additions & 17 deletions src/table/hoptable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,19 +330,19 @@ mod hoptable_tests {
#[test]
fn hoptable_inserts() {
let hoptable: HOPTable<String, u64> = HOPTable::new();
hoptable.insert("Saudade0".to_string(), 1);
hoptable.insert("Saudade1".to_string(), 2);
hoptable.insert("Saudade2".to_string(), 3);
hoptable.insert("Saudade3".to_string(), 4);
hoptable.insert("Saudade4".to_string(), 321321);
hoptable.insert("Saudade5".to_string(), 6);

hoptable.insert("123123".to_string(), 10);
hoptable.insert("1231231".to_string(), 11);
hoptable.insert("1231232".to_string(), 12);
hoptable.insert("1231233".to_string(), 13);
hoptable.insert("1231234".to_string(), 14);
hoptable.insert("1231235".to_string(), 15);
hoptable.insert("Saudade0".to_string(), 1).unwrap();
hoptable.insert("Saudade1".to_string(), 2).unwrap();
hoptable.insert("Saudade2".to_string(), 3).unwrap();
hoptable.insert("Saudade3".to_string(), 4).unwrap();
hoptable.insert("Saudade4".to_string(), 321321).unwrap();
hoptable.insert("Saudade5".to_string(), 6).unwrap();

hoptable.insert("123123".to_string(), 10).unwrap();
hoptable.insert("1231231".to_string(), 11).unwrap();
hoptable.insert("1231232".to_string(), 12).unwrap();
hoptable.insert("1231233".to_string(), 13).unwrap();
hoptable.insert("1231234".to_string(), 14).unwrap();
hoptable.insert("1231235".to_string(), 15).unwrap();

hoptable.trial();
assert_eq!(hoptable.get(&"Saudade4".to_string()), Some(321321));
Expand All @@ -351,20 +351,20 @@ mod hoptable_tests {
#[test]
fn hoptable_removes() {
let hoptable: HOPTable<String, u64> = HOPTable::new();
hoptable.insert("Saudade0".to_string(), 1);
hoptable.insert("Saudade0".to_string(), 1).unwrap();
assert_eq!(hoptable.get(&"Saudade0".to_string()), Some(1));

hoptable.remove(&"Saudade0".to_string());
hoptable.remove(&"Saudade0".to_string()).unwrap();
assert_eq!(hoptable.get(&"Saudade0".to_string()), None);
}

#[test]
fn hoptable_upsert() {
let hoptable: HOPTable<String, u64> = HOPTable::new();
hoptable.insert("Saudade0".to_string(), 1);
hoptable.insert("Saudade0".to_string(), 1).unwrap();
assert_eq!(hoptable.get(&"Saudade0".to_string()), Some(1));

hoptable.insert("Saudade0".to_string(), 2);
hoptable.insert("Saudade0".to_string(), 2).unwrap();
assert_eq!(hoptable.get(&"Saudade0".to_string()), Some(2));
}

Expand Down
60 changes: 30 additions & 30 deletions src/table/lotable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,20 +378,20 @@ mod lotable_tests {
#[test]
fn iter_generator() {
let lotable: LOTable<String, u64> = LOTable::new();
lotable.insert("Saudade0".to_string(), 123123);
lotable.insert("Saudade0".to_string(), 123);
lotable.insert("Saudade1".to_string(), 123123);
lotable.insert("Saudade2".to_string(), 123123);
lotable.insert("Saudade3".to_string(), 123123);
lotable.insert("Saudade4".to_string(), 123123);
lotable.insert("Saudade5".to_string(), 123123);

lotable.insert("123123".to_string(), 123123);
lotable.insert("1231231".to_string(), 123123);
lotable.insert("1231232".to_string(), 123123);
lotable.insert("1231233".to_string(), 123123);
lotable.insert("1231234".to_string(), 123123);
lotable.insert("1231235".to_string(), 123123);
lotable.insert("Saudade0".to_string(), 123123).unwrap();
lotable.insert("Saudade0".to_string(), 123).unwrap();
lotable.insert("Saudade1".to_string(), 123123).unwrap();
lotable.insert("Saudade2".to_string(), 123123).unwrap();
lotable.insert("Saudade3".to_string(), 123123).unwrap();
lotable.insert("Saudade4".to_string(), 123123).unwrap();
lotable.insert("Saudade5".to_string(), 123123).unwrap();

lotable.insert("123123".to_string(), 123123).unwrap();
lotable.insert("1231231".to_string(), 123123).unwrap();
lotable.insert("1231232".to_string(), 123123).unwrap();
lotable.insert("1231233".to_string(), 123123).unwrap();
lotable.insert("1231234".to_string(), 123123).unwrap();
lotable.insert("1231235".to_string(), 123123).unwrap();

let res: Vec<(String, u64)> = lotable.iter().collect();
assert_eq!(res.len(), 12);
Expand All @@ -404,20 +404,20 @@ mod lotable_tests {
let lotable: LOTable<String, u64> = LOTable::new();

(0..100).into_iter().for_each(|_i| {
lotable.insert("Saudade0".to_string(), 123123);
lotable.insert("Saudade0".to_string(), 123);
lotable.insert("Saudade1".to_string(), 123123);
lotable.insert("Saudade2".to_string(), 123123);
lotable.insert("Saudade3".to_string(), 123123);
lotable.insert("Saudade4".to_string(), 123123);
lotable.insert("Saudade5".to_string(), 123123);

lotable.insert("123123".to_string(), 123123);
lotable.insert("1231231".to_string(), 123123);
lotable.insert("1231232".to_string(), 123123);
lotable.insert("1231233".to_string(), 123123);
lotable.insert("1231234".to_string(), 123123);
lotable.insert("1231235".to_string(), 123123);
lotable.insert("Saudade0".to_string(), 123123).unwrap();
lotable.insert("Saudade0".to_string(), 123).unwrap();
lotable.insert("Saudade1".to_string(), 123123).unwrap();
lotable.insert("Saudade2".to_string(), 123123).unwrap();
lotable.insert("Saudade3".to_string(), 123123).unwrap();
lotable.insert("Saudade4".to_string(), 123123).unwrap();
lotable.insert("Saudade5".to_string(), 123123).unwrap();

lotable.insert("123123".to_string(), 123123).unwrap();
lotable.insert("1231231".to_string(), 123123).unwrap();
lotable.insert("1231232".to_string(), 123123).unwrap();
lotable.insert("1231233".to_string(), 123123).unwrap();
lotable.insert("1231234".to_string(), 123123).unwrap();
lotable.insert("1231235".to_string(), 123123).unwrap();

let res: Vec<u64> = lotable.values().into_iter().collect();
// dbg!(&res);
Expand All @@ -429,7 +429,7 @@ mod lotable_tests {
assert_eq!(res.len(), 0);

(0..1_000).into_iter().for_each(|i| {
lotable.insert(format!("{}", i), i as u64);
lotable.insert(format!("{}", i), i as u64).unwrap();

let resvals: Vec<u64> = lotable.values().into_iter().collect();
// dbg!(&resvals);
Expand All @@ -441,7 +441,7 @@ mod lotable_tests {
assert_eq!(res.len(), 0);

(0..1_000).into_iter().for_each(|i| {
lotable.insert(format!("{}", i), i as u64);
lotable.insert(format!("{}", i), i as u64).unwrap();

let reskeys: Vec<String> = lotable.keys().into_iter().collect();
// dbg!(&reskeys);
Expand Down
13 changes: 8 additions & 5 deletions src/table/ltable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ mod ltable_tests {
let x = t.read(&tvar);
dbg!(&x);
assert_eq!(x.get("taetigkeit".into()), Some(&String::from("ingenieur")));
});
})
.unwrap();

res = txn
.begin(|t| {
Expand Down Expand Up @@ -214,7 +215,8 @@ mod ltable_tests {
let x = t.read(&tvar);
dbg!(&x);
assert_eq!(x.get("taetigkeit".into()), Some(&String::from("ingenieur")));
});
})
.unwrap();

res = txn
.begin(|t| {
Expand Down Expand Up @@ -346,7 +348,8 @@ mod ltable_tests {
(*alice_accounts[1]).clear();
(*alice_accounts[1]).insert("alice2_init".into(), 50);
(*bob_account).clear();
});
})
.unwrap();
}
}
})
Expand Down Expand Up @@ -402,7 +405,7 @@ mod ltable_tests {
// try to transfer
let withdrawal_account = thread_no % alice_accounts.len();

txn.begin(|t| {
let _ = txn.begin(|t| {
let mut a0 = t.read(&alice_accounts[0]);
let mut a1 = t.read(&alice_accounts[1]);
let mut b = t.read(&bob_account);
Expand Down Expand Up @@ -452,7 +455,7 @@ mod ltable_tests {
);

// reset accounts
txn.begin(|_t| {
let _ = txn.begin(|_t| {
(*alice_accounts[0]).clear();
(*alice_accounts[0]).insert("alice1_init".into(), 50);
(*alice_accounts[1]).clear();
Expand Down
2 changes: 1 addition & 1 deletion src/txn/transact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ mod txn_tests {
}

for t in threads.into_iter() {
t.join().unwrap();
let _ = t.join().unwrap();
}
}

Expand Down
4 changes: 2 additions & 2 deletions tests/lotable_cc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::sync::Arc;
fn lotable_concurrent() {
let lotable = {
let table: LOTable<String, u64> = LOTable::new();
table.insert("data".into(), 1_u64);
table.insert("data".into(), 1_u64).unwrap();
Arc::new(table)
};

Expand All @@ -24,7 +24,7 @@ fn lotable_concurrent() {
} else {
// Writer threads
let data = lotable.get(&"data".to_string()).unwrap();
lotable.insert("data".into(), data + 1);
lotable.insert("data".into(), data + 1).unwrap();
}
})
.unwrap();
Expand Down