Skip to content

Commit d51fcff

Browse files
committed
Improve metrics dashboard
1 parent eaa3c49 commit d51fcff

54 files changed

Lines changed: 5256 additions & 223 deletions

File tree

Some content is hidden

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

modules/tpcc-metrics/src/lib.rs

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,46 +9,62 @@ pub struct State {
99
pub run_end_ms: u64,
1010
pub measure_start_ms: u64,
1111
pub measure_end_ms: u64,
12+
pub warehouse_count: u64,
13+
}
1214

13-
pub order_count: u64,
15+
#[table(accessor = txn, public)]
16+
pub struct Txn {
17+
#[primary_key]
18+
#[auto_inc]
19+
pub id: u64,
1420
pub measurement_time_ms: u64,
21+
pub latency_ms: u16,
1522
}
1623

1724
#[reducer]
18-
pub fn reset(ctx: &ReducerContext, warmup_duration_ms: u64, measure_start_ms: u64, measure_end_ms: u64) {
25+
pub fn reset(
26+
ctx: &ReducerContext,
27+
warehouse_count: u64,
28+
warmup_duration_ms: u64,
29+
measure_start_ms: u64,
30+
measure_end_ms: u64,
31+
) {
1932
for row in ctx.db.state().iter() {
20-
ctx.db.state().delete(row);
33+
ctx.db.state().id().delete(row.id);
34+
}
35+
36+
for row in ctx.db.txn().iter() {
37+
ctx.db.txn().id().delete(row.id);
2138
}
2239

2340
ctx.db.state().insert(State {
2441
id: 0,
25-
order_count: 0,
26-
measurement_time_ms: 0,
2742
run_start_ms: measure_start_ms - warmup_duration_ms,
2843
run_end_ms: measure_end_ms + warmup_duration_ms,
2944
measure_start_ms,
3045
measure_end_ms,
46+
warehouse_count,
3147
});
3248
}
3349

3450
#[reducer]
3551
pub fn clear_state(ctx: &ReducerContext) {
3652
for row in ctx.db.state().iter() {
37-
ctx.db.state().delete(row);
53+
ctx.db.state().id().delete(row.id);
54+
}
55+
56+
for row in ctx.db.txn().iter() {
57+
ctx.db.txn().id().delete(row.id);
3858
}
3959
}
4060

4161
#[reducer]
42-
pub fn register_completed_order(ctx: &ReducerContext) {
43-
// We intentionally do not check if the current time is within the measurement window,
44-
// this is the driver's reponsibility
45-
62+
pub fn record_txn(ctx: &ReducerContext, latency_ms: u16) {
4663
let current_time_ms = ctx.timestamp.to_duration_since_unix_epoch().unwrap().as_millis() as u64;
4764

48-
let mut state = ctx.db.state().id().find(0).unwrap();
49-
50-
state.order_count += 1;
51-
state.measurement_time_ms = current_time_ms;
52-
53-
ctx.db.state().id().update(state);
65+
ctx.db.txn().insert(Txn {
66+
id: 0,
67+
measurement_time_ms: current_time_ms,
68+
latency_ms,
69+
});
5470
}

0 commit comments

Comments
 (0)