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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ Recent 720-second local comparison on the machine above:
| --- | ---: | ---: | ---: | ---: | ---: | ---: |
| KiteSQL LMDB | 73638 | 0.001s | 0.001s | 0.001s | 0.002s | 0.001s |
| KiteSQL RocksDB | 39051 | 0.001s | 0.001s | 0.002s | 0.009s | 0.001s |
| SQLite balanced | 39835 | 0.001s | 0.001s | 0.001s | 0.001s | 0.001s |
| SQLite practical | 37911 | 0.001s | 0.001s | 0.001s | 0.001s | 0.001s |
| SQLite balanced | 56788 | 0.001s | 0.001s | 0.001s | 0.001s | 0.001s |
| SQLite practical | 44049 | 0.001s | 0.001s | 0.001s | 0.001s | 0.001s |

The detailed raw outputs are recorded in [tpcc/README.md](tpcc/README.md).
#### 👉[check more](tpcc/README.md)
Expand Down
77 changes: 37 additions & 40 deletions tpcc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,11 @@ Local 720-second comparison on the machine above:
| --- | ---: | ---: | ---: | ---: | ---: | ---: |
| KiteSQL LMDB | 73638 | 0.001s | 0.001s | 0.001s | 0.002s | 0.001s |
| KiteSQL RocksDB | 39051 | 0.001s | 0.001s | 0.002s | 0.009s | 0.001s |
| SQLite balanced | 39835 | 0.001s | 0.001s | 0.001s | 0.001s | 0.001s |
| SQLite practical | 37911 | 0.001s | 0.001s | 0.001s | 0.001s | 0.001s |
| SQLite balanced | 56788 | 0.001s | 0.001s | 0.001s | 0.001s | 0.001s |
| SQLite practical | 44049 | 0.001s | 0.001s | 0.001s | 0.001s | 0.001s |

- All rows are from fresh 720-second reruns with `--num-ware 1` and the default `--max-retry 5`.
- SQLite rows use the `balanced` and `practical` profiles respectively.
- Raw logs for this run were generated under `tpcc/results/2026-06-20_12-16-15/`.

### KiteSQL LMDB
```shell
Expand Down Expand Up @@ -189,11 +188,11 @@ Transaction Summary (elapsed 720.0s)
+--------------+---------+------+---------+-------+
| Transaction | Success | Late | Failure | Total |
+--------------+---------+------+---------+-------+
| New-Order | 478016 | 0 | 4738 | 482754 |
| Payment | 477993 | 0 | 0 | 477993 |
| Order-Status | 47800 | 0 | 0 | 47800 |
| Delivery | 47799 | 0 | 0 | 47799 |
| Stock-Level | 47799 | 0 | 0 | 47799 |
| New-Order | 681461 | 0 | 6997 | 688458 |
| Payment | 681435 | 0 | 0 | 681435 |
| Order-Status | 68143 | 0 | 0 | 68143 |
| Delivery | 68144 | 0 | 0 | 68144 |
| Stock-Level | 68144 | 0 | 0 | 68144 |
+--------------+---------+------+---------+-------+
<Constraint Check> (all must be [OK])
[transaction percentage]
Expand All @@ -213,37 +212,34 @@ Transaction Summary (elapsed 720.0s)

1.New-Order

0.001, 472255
0.002, 5697
0.003, 64
0.001, 681310
0.002, 151

2.Payment

0.001, 477992
0.002, 1
0.001, 681435

3.Order-Status

0.001, 47800
0.001, 68143

4.Delivery

0.001, 46716
0.002, 1070
0.003, 13
0.001, 68121
0.002, 23

5.Stock-Level

0.001, 47799
0.001, 68144

<90th Percentile RT (MaxRT)>
New-Order : 0.001 (0.003)
New-Order : 0.001 (0.001)
Payment : 0.001 (0.001)
Order-Status : 0.001 (0.001)
Delivery : 0.001 (0.003)
Order-Status : 0.001 (0.000)
Delivery : 0.001 (0.001)
Stock-Level : 0.001 (0.000)
<TpmC>
39835 Tpmc
56788 Tpmc
```

### SQLite practical
Expand All @@ -252,11 +248,11 @@ Transaction Summary (elapsed 720.0s)
+--------------+---------+------+---------+-------+
| Transaction | Success | Late | Failure | Total |
+--------------+---------+------+---------+-------+
| New-Order | 454941 | 0 | 4578 | 459519 |
| Payment | 454917 | 0 | 0 | 454917 |
| Order-Status | 45491 | 0 | 0 | 45491 |
| Delivery | 45492 | 0 | 0 | 45492 |
| Stock-Level | 45491 | 0 | 0 | 45491 |
| New-Order | 528594 | 0 | 5563 | 534157 |
| Payment | 528570 | 0 | 0 | 528570 |
| Order-Status | 52857 | 0 | 0 | 52857 |
| Delivery | 52857 | 0 | 0 | 52857 |
| Stock-Level | 52857 | 0 | 0 | 52857 |
+--------------+---------+------+---------+-------+
<Constraint Check> (all must be [OK])
[transaction percentage]
Expand All @@ -276,36 +272,37 @@ Transaction Summary (elapsed 720.0s)

1.New-Order

0.001, 452749
0.002, 2175
0.003, 17
0.001, 528448
0.002, 141
0.003, 5

2.Payment

0.001, 454917
0.001, 528567
0.002, 3

3.Order-Status

0.001, 45491
0.001, 52857

4.Delivery

0.001, 45045
0.002, 442
0.003, 5
0.001, 52831
0.002, 25
0.003, 1

5.Stock-Level

0.001, 45491
0.001, 52857

<90th Percentile RT (MaxRT)>
New-Order : 0.001 (0.002)
Payment : 0.001 (0.001)
Order-Status : 0.001 (0.001)
New-Order : 0.001 (0.003)
Payment : 0.001 (0.002)
Order-Status : 0.001 (0.000)
Delivery : 0.001 (0.003)
Stock-Level : 0.001 (0.000)
<TpmC>
37911 Tpmc
44049 Tpmc
```

## Refer to
Expand Down
88 changes: 60 additions & 28 deletions tpcc/src/backend/dual.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
// limitations under the License.

use super::kitesql_rocksdb::{KiteSqlRocksDbBackend, KiteSqlRocksDbTransaction, KiteSqlTxnResult};
use super::sqlite::{SqliteBackend, SqliteResult, SqliteTransaction};
use super::sqlite::{SqliteBackend, SqlitePreparedStatement, SqliteResult, SqliteTransaction};
use super::{
BackendControl, BackendTransaction, DbParam, PreparedStatement, SimpleExecutor, StatementSpec,
BackendControl, BackendTransaction, DbParam, KiteSqlPreparedStatement, PreparedStatement,
SimpleExecutor, StatementSpec,
};
use crate::{TpccError, STOCK_LEVEL_DISTINCT_SQL, STOCK_LEVEL_DISTINCT_SQLITE};
use kite_sql::types::tuple::Tuple;
Expand All @@ -28,6 +29,18 @@ pub struct DualBackend {
sqlite: SqliteBackend,
}

pub struct DualPreparedStatement<'a> {
kitesql: KiteSqlPreparedStatement,
sqlite: SqlitePreparedStatement<'a>,
spec: StatementSpec,
}

impl PreparedStatement for DualPreparedStatement<'_> {
fn spec(&self) -> &StatementSpec {
&self.spec
}
}

impl DualBackend {
pub fn new(path: &str, rocksdb_stats: bool) -> Result<Self, TpccError> {
Ok(Self {
Expand All @@ -38,6 +51,11 @@ impl DualBackend {
}

impl BackendControl for DualBackend {
type PreparedStatement<'a>
= DualPreparedStatement<'a>
where
Self: 'a;

type Transaction<'a>
= DualTransaction<'a>
where
Expand All @@ -46,8 +64,29 @@ impl BackendControl for DualBackend {
fn prepare_statements(
&self,
specs: &[Vec<StatementSpec>],
) -> Result<Vec<Vec<PreparedStatement>>, TpccError> {
self.kitesql.prepare_statements(specs)
) -> Result<Vec<Vec<Self::PreparedStatement<'_>>>, TpccError> {
let sqlite_specs: Vec<Vec<StatementSpec>> = specs
.iter()
.map(|group| group.iter().map(sqlite_statement_spec).collect())
.collect();
let kitesql_groups = self.kitesql.prepare_statements(specs)?;
let sqlite_groups = self.sqlite.prepare_statements(&sqlite_specs)?;
let mut groups = Vec::with_capacity(kitesql_groups.len());

for (kitesql_group, sqlite_group) in kitesql_groups.into_iter().zip(sqlite_groups) {
let mut group = Vec::with_capacity(kitesql_group.len());
for (kitesql, sqlite) in kitesql_group.into_iter().zip(sqlite_group) {
let spec = kitesql.spec().clone();
group.push(DualPreparedStatement {
kitesql,
sqlite,
spec,
});
}
groups.push(group);
}

Ok(groups)
}

fn new_transaction(&self) -> Result<Self::Transaction<'_>, TpccError> {
Expand Down Expand Up @@ -78,18 +117,17 @@ pub struct DualTransaction<'a> {
}

impl<'a> BackendTransaction for DualTransaction<'a> {
type PreparedStatement = DualPreparedStatement<'a>;

fn query_one(
&mut self,
statement: &PreparedStatement,
statement: &mut Self::PreparedStatement,
params: &[DbParam],
) -> Result<Tuple, TpccError> {
let spec = statement.spec().clone();
let sqlite_stmt = PreparedStatement::Sqlite {
spec: sqlite_statement_spec(&spec),
};
let spec = statement.spec.clone();

let kitesql_iter = self.kitesql.execute_raw(statement, params)?;
let sqlite_iter = self.sqlite.execute_raw(&sqlite_stmt, params)?;
let kitesql_iter = self.kitesql.execute_raw(&mut statement.kitesql, params)?;
let sqlite_iter = self.sqlite.execute_raw(&mut statement.sqlite, params)?;

if is_select_sql(&spec) {
if spec.sql == STOCK_LEVEL_DISTINCT_SQL {
Expand All @@ -114,17 +152,14 @@ impl<'a> BackendTransaction for DualTransaction<'a> {

fn query_nth(
&mut self,
statement: &PreparedStatement,
statement: &mut Self::PreparedStatement,
params: &[DbParam],
n: usize,
) -> Result<Tuple, TpccError> {
let spec = statement.spec().clone();
let sqlite_stmt = PreparedStatement::Sqlite {
spec: sqlite_statement_spec(&spec),
};
let spec = statement.spec.clone();

let kitesql_iter = self.kitesql.execute_raw(statement, params)?;
let sqlite_iter = self.sqlite.execute_raw(&sqlite_stmt, params)?;
let kitesql_iter = self.kitesql.execute_raw(&mut statement.kitesql, params)?;
let sqlite_iter = self.sqlite.execute_raw(&mut statement.sqlite, params)?;

if spec.sql == STOCK_LEVEL_DISTINCT_SQL {
let kitesql_rows = collect_all_rows(kitesql_iter)?;
Expand All @@ -141,16 +176,13 @@ impl<'a> BackendTransaction for DualTransaction<'a> {

fn execute_drain(
&mut self,
statement: &PreparedStatement,
statement: &mut Self::PreparedStatement,
params: &[DbParam],
) -> Result<(), TpccError> {
let spec = statement.spec().clone();
let sqlite_stmt = PreparedStatement::Sqlite {
spec: sqlite_statement_spec(&spec),
};
let spec = statement.spec.clone();

let kitesql_iter = self.kitesql.execute_raw(statement, params)?;
let sqlite_iter = self.sqlite.execute_raw(&sqlite_stmt, params)?;
let kitesql_iter = self.kitesql.execute_raw(&mut statement.kitesql, params)?;
let sqlite_iter = self.sqlite.execute_raw(&mut statement.sqlite, params)?;

if is_select_sql(&spec) {
if spec.sql == STOCK_LEVEL_DISTINCT_SQL {
Expand Down Expand Up @@ -182,7 +214,7 @@ fn normalize_sqlite_sql(sql: &str) -> Option<Cow<'_, str>> {
}
}

fn drain_sqlite_iter(mut iter: SqliteResult<'_>) -> Result<(), TpccError> {
fn drain_sqlite_iter(mut iter: SqliteResult<'_, '_>) -> Result<(), TpccError> {
while let Some(row) = iter.next() {
row?;
}
Expand Down Expand Up @@ -211,7 +243,7 @@ where

fn query_ordered_nth<T: kite_sql::storage::Transaction>(
mut kitesql_iter: KiteSqlTxnResult<'_, T>,
mut sqlite_iter: SqliteResult<'_>,
mut sqlite_iter: SqliteResult<'_, '_>,
sql: &'static str,
n: usize,
) -> Result<Tuple, TpccError> {
Expand Down Expand Up @@ -261,7 +293,7 @@ fn query_ordered_nth<T: kite_sql::storage::Transaction>(

fn drain_and_compare_ordered<T: kite_sql::storage::Transaction>(
mut kitesql_iter: KiteSqlTxnResult<'_, T>,
mut sqlite_iter: SqliteResult<'_>,
mut sqlite_iter: SqliteResult<'_, '_>,
sql: &'static str,
) -> Result<(), TpccError> {
loop {
Expand Down
Loading
Loading