Commit Graph

185 Commits

Author SHA1 Message Date
Pekka Enberg
ed5e259cfe Switch to parking_lot mutex
It's faster than the standard library mutex.
2023-04-14 12:04:43 +03:00
Pekka Enberg
0f956fa179 Use Criterion's throughput estimation
Iteration time is of course interesting, but let's also use throughput
estimation on MVCC operations such as read(), begin_tx(), etc..
2023-04-14 11:59:36 +03:00
Piotr Sarna
8b798593a1 simplify CI
... since the old script messed up Clippy sometimes
2023-04-14 10:46:08 +02:00
Piotr Sarna
fdbe419789 fix CI (#9)
There was a minor import inconsistency in database/benches
2023-04-14 10:37:30 +02:00
Piotr Sarna
1bb752cab9 add basic CI (#8) 2023-04-14 10:18:37 +02:00
Pekka Enberg
f84f185835 Improve transaction tracing 2023-04-14 11:08:35 +03:00
Piotr Sarna
aebaf623a9 database: apply clippy fixes
They were preexisting, but now all the future patches can
use `clippy --tests` as well.
2023-04-14 09:54:33 +02:00
Piotr Sarna
7622ea5f98 database: add transaction tracing
The tracing is also added to tests, so that the behavior
can be observed:

```
$ cargo test -- --nocapture --test-threads 1
test database::tests::test_dirty_write ... 2023-04-14T07:51:15.919503Z TRACE test_dirty_write: mvcc_rs::database: BEGIN    { id: 0, begin_ts: 0, write_set: {}, read_set: {} }
2023-04-14T07:51:15.919554Z TRACE test_dirty_write: mvcc_rs::database: BEGIN    { id: 1, begin_ts: 1, write_set: {}, read_set: {} }
ok
test database::tests::test_fuzzy_read ... 2023-04-14T07:51:15.919732Z TRACE test_fuzzy_read: mvcc_rs::database: BEGIN    { id: 0, begin_ts: 0, write_set: {}, read_set: {} }
2023-04-14T07:51:15.919762Z TRACE test_fuzzy_read: mvcc_rs::database: COMMIT   { id: 0, begin_ts: 0, write_set: {1}, read_set: {1} }
2023-04-14T07:51:15.919778Z TRACE test_fuzzy_read: mvcc_rs::database: BEGIN    { id: 1, begin_ts: 2, write_set: {}, read_set: {} }
2023-04-14T07:51:15.919793Z TRACE test_fuzzy_read: mvcc_rs::database: BEGIN    { id: 2, begin_ts: 3, write_set: {}, read_set: {} }
2023-04-14T07:51:15.919811Z TRACE test_fuzzy_read: mvcc_rs::database: COMMIT   { id: 2, begin_ts: 3, write_set: {1}, read_set: {} }
ok
test database::tests::test_insert_read ... 2023-04-14T07:51:15.919944Z TRACE test_insert_read: mvcc_rs::database: BEGIN    { id: 0, begin_ts: 0, write_set: {}, read_set: {} }
2023-04-14T07:51:15.919974Z TRACE test_insert_read: mvcc_rs::database: COMMIT   { id: 0, begin_ts: 0, write_set: {1}, read_set: {1} }
2023-04-14T07:51:15.919989Z TRACE test_insert_read: mvcc_rs::database: BEGIN    { id: 1, begin_ts: 2, write_set: {}, read_set: {} }
ok
test database::tests::test_lost_update ... 2023-04-14T07:51:15.920116Z TRACE test_lost_update: mvcc_rs::database: BEGIN    { id: 0, begin_ts: 0, write_set: {}, read_set: {} }
2023-04-14T07:51:15.920146Z TRACE test_lost_update: mvcc_rs::database: COMMIT   { id: 0, begin_ts: 0, write_set: {1}, read_set: {1} }
2023-04-14T07:51:15.920161Z TRACE test_lost_update: mvcc_rs::database: BEGIN    { id: 1, begin_ts: 2, write_set: {}, read_set: {} }
2023-04-14T07:51:15.920178Z TRACE test_lost_update: mvcc_rs::database: BEGIN    { id: 2, begin_ts: 3, write_set: {}, read_set: {} }
2023-04-14T07:51:15.920196Z TRACE test_lost_update: mvcc_rs::database: ROLLBACK { id: 2, begin_ts: 3, write_set: {}, read_set: {} }
2023-04-14T07:51:15.920210Z TRACE test_lost_update: mvcc_rs::database: COMMIT   { id: 1, begin_ts: 2, write_set: {1}, read_set: {} }
2023-04-14T07:51:15.920223Z TRACE test_lost_update: mvcc_rs::database: BEGIN    { id: 3, begin_ts: 6, write_set: {}, read_set: {} }
ok
test database::tests::test_read_nonexistent ... 2023-04-14T07:51:15.920352Z TRACE test_read_nonexistent: mvcc_rs::database: BEGIN    { id: 0, begin_ts: 0, write_set: {}, read_set: {} }
ok
```
2023-04-14 09:53:57 +02:00
Piotr Sarna
9d99090f67 .gitignore: add Cargo.lock
mvcc-rs is considered a library, so let's ignore its Cargo.lock
as per https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
2023-04-14 09:53:57 +02:00
Piotr Sarna
05ee98971b add tracing 2023-04-14 09:30:28 +02:00
Pekka Enberg
bc7269a776 Fix typo 2023-04-13 10:41:01 +03:00
Pekka Enberg
e2fc841479 Move is_write_write_conflict() definition 2023-04-13 10:19:21 +03:00
Pekka Enberg
87ef3e1cd8 Add a comment for is_write_write_conflict() 2023-04-13 10:18:19 +03:00
Pekka Enberg
f51c4ee5a8 Move TxID type definition 2023-04-13 10:14:44 +03:00
Pekka Enberg
b73c11015a Reorder code 2023-04-13 10:13:19 +03:00
Pekka Enberg
204d65ad05 Move clock code to clock.rs 2023-04-13 10:09:23 +03:00
Pekka Enberg
44ba56c5a8 Update README 2023-04-13 10:09:13 +03:00
Pekka Enberg
824669d471 Move code into DatabaseInner
Let's move rest of the code into DatabaseInner like we did for
`rollback_tx` as a code cleanup.
2023-04-13 10:05:09 +03:00
Pekka Enberg
d7ecfc054c Fix lost update anomaly
Fixes #5
2023-04-13 09:57:26 +03:00
Pekka Enberg
eb250e1e83 Wire up flamegraphs to cargo bench 2023-04-12 12:39:14 +03:00
Pekka Enberg
477da5b60a Fix compile error 2023-04-12 12:17:34 +03:00
Pekka Enberg
a52bf9158b Fix delete() TX ID parameter name
Align it with the rest of the code.
2023-04-12 12:12:37 +03:00
Pekka Enberg
77d639fc20 Fix concurrency test
It was accidentally using row ID as transaction ID...
2023-04-12 11:56:22 +03:00
Pekka Enberg
3cecf777cf Assert that we're manipulating an active transaction 2023-04-12 11:55:34 +03:00
Pekka Enberg
22042612d5 Concurrency test
The test is disabled because it triggers an assertion in the MVCC
implementation.
2023-04-12 11:45:15 +03:00
Pekka Enberg
fc93642643 Simple microbenchmarks 2023-04-10 18:22:10 +03:00
Pekka Enberg
02f40c0568 Move MVCC to database.rs
Let's keep lib.rs small and tidy.
2023-04-09 08:55:06 +03:00
Pekka Enberg
8f30c20215 Replace unwrap() with NoSuchTransactionID error 2023-04-09 08:53:03 +03:00
Pekka Enberg
df0cadc02e Clean up LocalClock default trait 2023-04-08 18:37:23 +03:00
Pekka Enberg
df5500e0df Add test case for dirty read on delete
The test fails, btw.
2023-04-08 18:35:45 +03:00
Pekka Enberg
fb60ccd04d Improve test suite 2023-04-08 18:03:49 +03:00
Pekka Enberg
957949a49d Fix delete() on non-existent ID 2023-04-08 18:03:41 +03:00
Pekka Enberg
7a2085c02f Improve lost update test case
Let's verify that first-writer wins. We still need to fix the second
writer commit() to fail.
2023-04-08 16:42:40 +03:00
Pekka Enberg
29fca23417 Add test case for lost updates
We currently never fail commit() operations so the test case is
incomplete. But let's add it as a place-holder.
2023-04-08 16:34:16 +03:00
Pekka Enberg
7a173a8ae2 Initial commit 2023-04-08 15:14:05 +03:00