Skip to content

Commit fa4473f

Browse files
authored
Feat/tpcc dual (#302)
* refactor: tpcc display & add dual for verification result * fix: stock level distinct case on dual * feat: impl StreamDistinct & elimination plan constant cast * chore: codefmt
1 parent 57a1a06 commit fa4473f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2603
-774
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ sqlite_bench
2424
kite_sql_tpcc
2525
copy.csv
2626

27-
tests/data/row_20000.csv
27+
tests/data/row_20000.csv
28+
tests/data/distinct_rows.csv

AGENT.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ PRs that modify logic but leave obvious test gaps untouched may be rejected.
8888

8989
If something can be written clearly using fewer concepts, do that.
9090

91+
- Prefer incremental fixes: solve the problem at hand with the smallest reasonable change
92+
before introducing new abstractions or generalizations.
93+
9194
---
9295

9396
### 3.2 Low Comments, High Signal

Cargo.lock

Lines changed: 45 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ tokio = { version = "1.36", features = ["full"], optional = true
7171

7272

7373
[target.'cfg(unix)'.dev-dependencies]
74-
pprof = { version = "0.13", features = ["flamegraph", "criterion"] }
74+
pprof = { version = "0.15", features = ["flamegraph", "criterion"] }
7575

7676
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
7777
criterion = { version = "0.5", features = ["html_reports"] }

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ CARGO ?= cargo
33
WASM_PACK ?= wasm-pack
44
SQLLOGIC_PATH ?= tests/slt/**/*.slt
55

6-
.PHONY: test test-wasm test-slt test-all wasm-build check tpcc cargo-check build wasm-examples native-examples fmt clippy
6+
.PHONY: test test-wasm test-slt test-all wasm-build check tpcc tpcc-dual cargo-check build wasm-examples native-examples fmt clippy
77

88
## Run default Rust tests in the current environment (non-WASM).
99
test:
@@ -47,6 +47,10 @@ check: fmt clippy
4747
tpcc:
4848
$(CARGO) run -p tpcc --release
4949

50+
## Execute TPCC while mirroring every statement to an in-memory SQLite instance for validation.
51+
tpcc-dual:
52+
$(CARGO) run -p tpcc --release -- --backend dual --measure-time 60
53+
5054
## Run JavaScript-based Wasm example scripts.
5155
wasm-examples:
5256
node examples/wasm_hello_world.test.mjs

README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ for tuple in iter {
8282
- [transaction](examples/transaction.rs)
8383
8484
## TPC-C
85-
run `cargo run -p tpcc --release` to run tpcc
85+
Run `make tpcc` (or `cargo run -p tpcc --release`) to execute the benchmark against the default KiteSQL storage.
86+
Run `make tpcc-dual` to mirror every TPCC statement to an in-memory SQLite database alongside KiteSQL and assert the two engines return identical results; this target runs for 60 seconds (`--measure-time 60`). Use `cargo run -p tpcc --release -- --backend dual --measure-time <secs>` for a custom duration.
8687
8788
- i9-13900HX
8889
- 32.0 GB
@@ -92,13 +93,13 @@ run `cargo run -p tpcc --release` to run tpcc
9293
All cases have been fully optimized.
9394
```shell
9495
<90th Percentile RT (MaxRT)>
95-
New-Order : 0.002 (0.012)
96-
Payment : 0.001 (0.002)
97-
Order-Status : 0.002 (0.019)
98-
Delivery : 0.001 (0.001)
99-
Stock-Level : 0.002 (0.018)
96+
New-Order : 0.002 (0.006)
97+
Payment : 0.001 (0.019)
98+
Order-Status : 0.001 (0.003)
99+
Delivery : 0.022 (0.038)
100+
Stock-Level : 0.002 (0.005)
100101
<TpmC>
101-
37166 Tpmc
102+
18432 Tpmc
102103
```
103104
#### 👉[check more](tpcc/README.md)
104105

src/db.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,12 @@ fn default_optimizer_pipeline() -> HepOptimizerPipeline {
203203
vec![NormalizationRuleImpl::TopK],
204204
)
205205
.after_batch(
206-
"Eliminate Redundant Sort".to_string(),
206+
"Eliminate Aggregate".to_string(),
207207
HepBatchStrategy::once_topdown(),
208-
vec![NormalizationRuleImpl::EliminateRedundantSort],
208+
vec![
209+
NormalizationRuleImpl::EliminateRedundantSort,
210+
NormalizationRuleImpl::UseStreamDistinct,
211+
],
209212
)
210213
.after_batch(
211214
"Expression Remapper".to_string(),

src/execution/dql/aggregate/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ mod count;
1717
pub mod hash_agg;
1818
mod min_max;
1919
pub mod simple_agg;
20+
pub mod stream_distinct;
2021
mod sum;
2122

2223
use crate::errors::DatabaseError;

0 commit comments

Comments
 (0)