Skip to content

Commit

Permalink
perf(505): Track the number of rows in each table (#525)
Browse files Browse the repository at this point in the history
Closes #505.
  • Loading branch information
joshua-spacetime authored Nov 6, 2023
1 parent 0a4c2f1 commit 250115b
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 18 deletions.
31 changes: 15 additions & 16 deletions crates/core/src/db/commit_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,33 +111,32 @@ impl CommitLog {
let mut unwritten_commit = self.unwritten_commit.lock().unwrap();
let mut writes = Vec::with_capacity(tx_data.records.len());

let rows_inserted = &DB_METRICS.rdb_num_rows_inserted;
let rows_deleted = &DB_METRICS.rdb_num_rows_deleted;
let txn_type = &ctx.txn_type();
let db = &ctx.database();
let reducer = &ctx.reducer_name().unwrap_or_default();

for record in &tx_data.records {
let table_id: u32 = record.table_id.into();

let operation = match record.op {
TxOp::Insert(_) => {
// Increment rows inserted metric
let metric = rows_inserted.with_label_values(
&ctx.txn_type(),
&ctx.database(),
ctx.reducer_name().unwrap_or_default(),
&table_id,
);
metric.inc();
DB_METRICS
.rdb_num_rows_inserted
.with_label_values(txn_type, db, reducer, &table_id)
.inc();
// Increment table rows gauge
DB_METRICS.rdb_num_table_rows.with_label_values(db, &table_id).inc();
Operation::Insert
}
TxOp::Delete => {
// Increment rows deleted metric
let metric = rows_deleted.with_label_values(
&ctx.txn_type(),
&ctx.database(),
ctx.reducer_name().unwrap_or_default(),
&table_id,
);
metric.inc();
DB_METRICS
.rdb_num_rows_deleted
.with_label_values(txn_type, db, reducer, &table_id)
.inc();
// Decrement table rows gauge
DB_METRICS.rdb_num_table_rows.with_label_values(db, &table_id).dec();
Operation::Delete
}
};
Expand Down
42 changes: 42 additions & 0 deletions crates/core/src/db/datastore/locking_tx_datastore/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,12 @@ impl Inner {
}

fn bootstrap_system_table(&mut self, schema: TableSchema) -> Result<(), DBError> {
// Reset the row count metric for this system table
DB_METRICS
.rdb_num_table_rows
.with_label_values(&self.database_address, &schema.table_id.into())
.set(0);

let table_id = schema.table_id;

// Insert the table row into st_tables, creating st_tables if it's missing
Expand All @@ -380,6 +386,12 @@ impl Inner {
let data_key = row.to_data_key();
st_tables.rows.insert(RowId(data_key), row);

// Increment row count for st_tables
DB_METRICS
.rdb_num_table_rows
.with_label_values(&self.database_address, &ST_TABLES_ID.into())
.inc();

// Insert the columns into st_columns
let first_col_id = schema.columns.first().unwrap().col_id;
for (i, col) in schema.columns.into_iter().enumerate() {
Expand All @@ -399,6 +411,11 @@ impl Inner {
self.committed_state
.get_or_create_table(ST_COLUMNS_ID, &ST_COLUMNS_ROW_TYPE, &st_columns_schema());
st_columns.rows.insert(RowId(data_key), row);
// Increment row count for st_columns
DB_METRICS
.rdb_num_table_rows
.with_label_values(&self.database_address, &ST_COLUMNS_ID.into())
.inc();
}

// If any columns are auto incrementing, we need to create a sequence
Expand Down Expand Up @@ -435,6 +452,11 @@ impl Inner {
let row = ProductValue::from(row);
let data_key = row.to_data_key();
st_sequences.rows.insert(RowId(data_key), row);
// Increment row count for st_sequences
DB_METRICS
.rdb_num_table_rows
.with_label_values(&self.database_address, &ST_SEQUENCES_ID.into())
.inc();
}
}

Expand Down Expand Up @@ -463,6 +485,12 @@ impl Inner {
let data_key = row.to_data_key();
st_constraints.rows.insert(RowId(data_key), row);

// Increment row count for st_constraints
DB_METRICS
.rdb_num_table_rows
.with_label_values(&self.database_address, &ST_CONSTRAINTS_ID.into())
.inc();

//Check if add an index:
match constraint.kind {
x if x.is_unique() => IndexSchema {
Expand Down Expand Up @@ -498,6 +526,12 @@ impl Inner {
let row = ProductValue::from(row);
let data_key = row.to_data_key();
st_indexes.rows.insert(RowId(data_key), row);

// Increment row count for st_indexes
DB_METRICS
.rdb_num_table_rows
.with_label_values(&self.database_address, &ST_INDEXES_ID.into())
.inc();
}

Ok(())
Expand Down Expand Up @@ -1640,6 +1674,10 @@ impl Locking {
match write.operation {
Operation::Delete => {
Self::table_rows(&mut inner, table_id, schema, row_type).remove(&RowId(write.data_key));
DB_METRICS
.rdb_num_table_rows
.with_label_values(&inner.database_address, &table_id.into())
.dec();
}
Operation::Insert => {
let product_value = match write.data_key {
Expand All @@ -1657,6 +1695,10 @@ impl Locking {
};
Self::table_rows(&mut inner, table_id, schema, row_type)
.insert(RowId(write.data_key), product_value);
DB_METRICS
.rdb_num_table_rows
.with_label_values(&inner.database_address, &table_id.into())
.inc();
}
}
}
Expand Down
7 changes: 6 additions & 1 deletion crates/core/src/db/db_metrics/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{execution_context::TransactionType, host::AbiCall, util::typed_prometheus::metrics_group};
use once_cell::sync::Lazy;
use prometheus::{Histogram, HistogramVec, IntCounterVec};
use prometheus::{Histogram, HistogramVec, IntCounterVec, IntGaugeVec};
use spacetimedb_lib::Address;

metrics_group!(
Expand Down Expand Up @@ -56,6 +56,11 @@ metrics_group!(
#[labels(db: Address, reducer: str)]
pub scheduled_reducer_delay_sec: HistogramVec,

#[name = spacetime_num_table_rows]
#[help = "The number of rows in a table"]
#[labels(db: Address, table_id: u32)]
pub rdb_num_table_rows: IntGaugeVec,

#[name = spacetime_num_rows_inserted_cumulative]
#[help = "The cumulative number of rows inserted into a table"]
#[labels(txn_type: TransactionType, db: Address, reducer: str, table_id: u32)]
Expand Down
7 changes: 6 additions & 1 deletion crates/core/src/db/relational_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,12 @@ impl RelationalDB {
.rdb_drop_table_time
.with_label_values(&table_id.0)
.start_timer();
self.inner.drop_table_mut_tx(tx, table_id)
self.inner.drop_table_mut_tx(tx, table_id).map(|_| {
DB_METRICS
.rdb_num_table_rows
.with_label_values(&self.address, &table_id.into())
.set(0)
})
}

/// Rename a table.
Expand Down

1 comment on commit 250115b

@github-actions
Copy link

@github-actions github-actions bot commented on 250115b Nov 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark results

Benchmark Report

Legend:

  • load: number of rows pre-loaded into the database
  • count: number of rows touched by the transaction
  • index types:
    • unique: a single index on the id column
    • non_unique: no indexes
    • multi_index: non-unique index on every column
  • schemas:
    • person(id: u32, name: String, age: u64)
    • location(id: u32, x: u64, y: u64)

All throughputs are single-threaded.

Empty transaction

db on disk new latency old latency new throughput old throughput
sqlite 💿 437.6±1.37ns 424.9±1.31ns - -
sqlite 🧠 425.7±1.25ns 420.9±1.16ns - -
stdb_module 💿 17.6±1.00µs 17.0±0.37µs - -
stdb_module 🧠 18.8±1.46µs 17.3±0.91µs - -
stdb_raw 💿 712.5±1.72ns 722.2±5.07ns - -
stdb_raw 🧠 710.9±2.41ns 716.2±1.12ns - -

Single-row insertions

db on disk schema index type load new latency old latency new throughput old throughput
sqlite 💿 location multi_index 0 14.6±0.77µs 14.8±1.76µs 66.7 Ktx/sec 65.8 Ktx/sec
sqlite 💿 location multi_index 1000 15.9±0.10µs 15.7±0.13µs 61.6 Ktx/sec 62.1 Ktx/sec
sqlite 💿 location non_unique 0 7.4±0.54µs 7.1±0.57µs 131.9 Ktx/sec 138.0 Ktx/sec
sqlite 💿 location non_unique 1000 7.0±0.04µs 6.9±0.04µs 138.6 Ktx/sec 141.4 Ktx/sec
sqlite 💿 location unique 0 7.6±0.35µs 7.1±1.20µs 127.8 Ktx/sec 137.2 Ktx/sec
sqlite 💿 location unique 1000 7.1±0.05µs 6.9±0.03µs 138.3 Ktx/sec 141.3 Ktx/sec
sqlite 💿 person multi_index 0 14.5±0.06µs 14.3±0.29µs 67.4 Ktx/sec 68.4 Ktx/sec
sqlite 💿 person multi_index 1000 16.3±0.11µs 16.2±0.16µs 60.0 Ktx/sec 60.3 Ktx/sec
sqlite 💿 person non_unique 0 7.5±0.12µs 7.2±0.40µs 131.1 Ktx/sec 135.9 Ktx/sec
sqlite 💿 person non_unique 1000 7.3±0.04µs 7.3±0.07µs 133.4 Ktx/sec 134.3 Ktx/sec
sqlite 💿 person unique 0 7.4±0.04µs 7.2±0.49µs 132.0 Ktx/sec 136.1 Ktx/sec
sqlite 💿 person unique 1000 7.3±0.04µs 7.3±0.15µs 133.8 Ktx/sec 134.3 Ktx/sec
sqlite 🧠 location multi_index 0 4.0±0.15µs 4.0±0.01µs 242.4 Ktx/sec 243.5 Ktx/sec
sqlite 🧠 location multi_index 1000 5.1±0.03µs 5.3±0.04µs 190.7 Ktx/sec 185.7 Ktx/sec
sqlite 🧠 location non_unique 0 1859.5±5.94ns 1844.5±3.16ns 525.2 Ktx/sec 529.4 Ktx/sec
sqlite 🧠 location non_unique 1000 1938.7±7.71ns 1859.3±32.62ns 503.7 Ktx/sec 525.2 Ktx/sec
sqlite 🧠 location unique 0 1850.6±6.20ns 1816.0±5.37ns 527.7 Ktx/sec 537.8 Ktx/sec
sqlite 🧠 location unique 1000 1959.4±10.97ns 1915.6±16.80ns 498.4 Ktx/sec 509.8 Ktx/sec
sqlite 🧠 person multi_index 0 3.7±0.01µs 3.6±0.01µs 266.4 Ktx/sec 268.4 Ktx/sec
sqlite 🧠 person multi_index 1000 5.5±0.05µs 5.5±0.03µs 179.1 Ktx/sec 177.3 Ktx/sec
sqlite 🧠 person non_unique 0 1932.8±4.68ns 1908.1±3.42ns 505.3 Ktx/sec 511.8 Ktx/sec
sqlite 🧠 person non_unique 1000 2.0±0.02µs 1990.8±22.33ns 481.3 Ktx/sec 490.5 Ktx/sec
sqlite 🧠 person unique 0 1917.9±4.85ns 1893.0±3.55ns 509.2 Ktx/sec 515.9 Ktx/sec
sqlite 🧠 person unique 1000 2.1±0.02µs 2.0±0.01µs 473.0 Ktx/sec 479.4 Ktx/sec
stdb_module 💿 location multi_index 0 53.3±6.23µs 54.7±5.52µs 18.3 Ktx/sec 17.9 Ktx/sec
stdb_module 💿 location multi_index 1000 110.0±7.12µs 161.5±7.36µs 8.9 Ktx/sec 6.0 Ktx/sec
stdb_module 💿 location non_unique 0 48.0±4.34µs 46.3±3.56µs 20.3 Ktx/sec 21.1 Ktx/sec
stdb_module 💿 location non_unique 1000 237.1±82.28µs 241.4±84.90µs 4.1 Ktx/sec 4.0 Ktx/sec
stdb_module 💿 location unique 0 49.1±5.33µs 48.9±5.89µs 19.9 Ktx/sec 20.0 Ktx/sec
stdb_module 💿 location unique 1000 108.2±63.95µs 101.5±5.00µs 9.0 Ktx/sec 9.6 Ktx/sec
stdb_module 💿 person multi_index 0 66.7±6.00µs 63.2±5.44µs 14.6 Ktx/sec 15.4 Ktx/sec
stdb_module 💿 person multi_index 1000 164.5±19.63µs 221.3±29.70µs 5.9 Ktx/sec 4.4 Ktx/sec
stdb_module 💿 person non_unique 0 48.8±4.31µs 46.8±5.01µs 20.0 Ktx/sec 20.9 Ktx/sec
stdb_module 💿 person non_unique 1000 196.5±18.31µs 156.9±38.21µs 5.0 Ktx/sec 6.2 Ktx/sec
stdb_module 💿 person unique 0 56.5±6.17µs 56.9±6.75µs 17.3 Ktx/sec 17.1 Ktx/sec
stdb_module 💿 person unique 1000 118.1±56.85µs 188.3±93.65µs 8.3 Ktx/sec 5.2 Ktx/sec
stdb_module 🧠 location multi_index 0 34.9±2.84µs 36.3±4.13µs 28.0 Ktx/sec 26.9 Ktx/sec
stdb_module 🧠 location multi_index 1000 137.1±10.16µs 110.9±4.77µs 7.1 Ktx/sec 8.8 Ktx/sec
stdb_module 🧠 location non_unique 0 34.1±3.46µs 32.0±3.45µs 28.6 Ktx/sec 30.5 Ktx/sec
stdb_module 🧠 location non_unique 1000 186.6±7.31µs 162.2±13.00µs 5.2 Ktx/sec 6.0 Ktx/sec
stdb_module 🧠 location unique 0 33.4±2.83µs 34.5±3.75µs 29.3 Ktx/sec 28.3 Ktx/sec
stdb_module 🧠 location unique 1000 105.9±11.74µs 166.9±45.22µs 9.2 Ktx/sec 5.9 Ktx/sec
stdb_module 🧠 person multi_index 0 49.4±4.96µs 47.1±4.59µs 19.7 Ktx/sec 20.7 Ktx/sec
stdb_module 🧠 person multi_index 1000 254.5±2.93µs 249.1±69.91µs 3.8 Ktx/sec 3.9 Ktx/sec
stdb_module 🧠 person non_unique 0 32.5±3.23µs 34.2±2.49µs 30.0 Ktx/sec 28.5 Ktx/sec
stdb_module 🧠 person non_unique 1000 314.7±4.54µs 252.3±11.44µs 3.1 Ktx/sec 3.9 Ktx/sec
stdb_module 🧠 person unique 0 40.4±4.84µs 39.7±3.31µs 24.2 Ktx/sec 24.6 Ktx/sec
stdb_module 🧠 person unique 1000 228.6±18.89µs 106.5±6.98µs 4.3 Ktx/sec 9.2 Ktx/sec
stdb_raw 💿 location multi_index 0 7.3±0.02µs 7.0±0.03µs 134.6 Ktx/sec 138.6 Ktx/sec
stdb_raw 💿 location multi_index 1000 33.6±236.37µs 34.8±249.40µs 29.1 Ktx/sec 28.1 Ktx/sec
stdb_raw 💿 location non_unique 0 4.9±0.01µs 4.7±0.01µs 200.9 Ktx/sec 209.1 Ktx/sec
stdb_raw 💿 location non_unique 1000 16.9±105.65µs 6.2±0.17µs 57.8 Ktx/sec 158.2 Ktx/sec
stdb_raw 💿 location unique 0 6.3±0.27µs 6.0±0.01µs 155.7 Ktx/sec 164.0 Ktx/sec
stdb_raw 💿 location unique 1000 26.2±177.03µs 22.9±145.44µs 37.2 Ktx/sec 42.7 Ktx/sec
stdb_raw 💿 person multi_index 0 11.0±0.44µs 10.8±0.86µs 88.4 Ktx/sec 90.5 Ktx/sec
stdb_raw 💿 person multi_index 1000 14.3±0.24µs 14.1±0.18µs 68.5 Ktx/sec 69.3 Ktx/sec
stdb_raw 💿 person non_unique 0 5.5±0.05µs 5.2±0.31µs 177.8 Ktx/sec 187.1 Ktx/sec
stdb_raw 💿 person non_unique 1000 7.2±0.75µs 24.1±171.18µs 135.4 Ktx/sec 40.5 Ktx/sec
stdb_raw 💿 person unique 0 7.9±0.04µs 7.6±0.40µs 124.0 Ktx/sec 128.2 Ktx/sec
stdb_raw 💿 person unique 1000 10.3±0.15µs 10.3±0.22µs 94.8 Ktx/sec 94.9 Ktx/sec
stdb_raw 🧠 location multi_index 0 4.2±0.01µs 4.1±0.01µs 233.6 Ktx/sec 235.5 Ktx/sec
stdb_raw 🧠 location multi_index 1000 5.7±0.04µs 5.8±0.11µs 171.0 Ktx/sec 168.9 Ktx/sec
stdb_raw 🧠 location non_unique 0 1931.7±9.26ns 1938.0±5.58ns 505.5 Ktx/sec 503.9 Ktx/sec
stdb_raw 🧠 location non_unique 1000 2.4±0.01µs 2.4±0.02µs 402.1 Ktx/sec 402.5 Ktx/sec
stdb_raw 🧠 location unique 0 3.1±0.01µs 3.2±0.00µs 310.8 Ktx/sec 306.0 Ktx/sec
stdb_raw 🧠 location unique 1000 4.5±0.02µs 4.4±0.06µs 218.7 Ktx/sec 220.8 Ktx/sec
stdb_raw 🧠 person multi_index 0 7.8±0.01µs 7.8±0.01µs 124.8 Ktx/sec 125.1 Ktx/sec
stdb_raw 🧠 person multi_index 1000 9.8±0.08µs 9.9±0.07µs 99.4 Ktx/sec 99.0 Ktx/sec
stdb_raw 🧠 person non_unique 0 2.5±0.01µs 2.5±0.00µs 393.1 Ktx/sec 397.2 Ktx/sec
stdb_raw 🧠 person non_unique 1000 3.2±0.02µs 3.2±0.02µs 308.9 Ktx/sec 301.4 Ktx/sec
stdb_raw 🧠 person unique 0 4.7±0.01µs 4.7±0.01µs 205.8 Ktx/sec 207.7 Ktx/sec
stdb_raw 🧠 person unique 1000 6.2±0.03µs 6.2±0.05µs 156.8 Ktx/sec 157.0 Ktx/sec

Multi-row insertions

db on disk schema index type load count new latency old latency new throughput old throughput
sqlite 💿 location multi_index 0 100 131.3±3.53µs 129.9±3.59µs 7.4 Ktx/sec 7.5 Ktx/sec
sqlite 💿 location multi_index 1000 100 203.1±1.65µs 202.0±1.37µs 4.8 Ktx/sec 4.8 Ktx/sec
sqlite 💿 location non_unique 0 100 48.9±1.16µs 49.8±1.04µs 20.0 Ktx/sec 19.6 Ktx/sec
sqlite 💿 location non_unique 1000 100 51.8±0.30µs 53.6±0.32µs 18.9 Ktx/sec 18.2 Ktx/sec
sqlite 💿 location unique 0 100 50.1±0.38µs 52.1±1.47µs 19.5 Ktx/sec 18.8 Ktx/sec
sqlite 💿 location unique 1000 100 56.3±0.49µs 57.7±2.19µs 17.4 Ktx/sec 16.9 Ktx/sec
sqlite 💿 person multi_index 0 100 118.0±2.29µs 116.1±0.25µs 8.3 Ktx/sec 8.4 Ktx/sec
sqlite 💿 person multi_index 1000 100 235.0±2.06µs 230.8±0.44µs 4.2 Ktx/sec 4.2 Ktx/sec
sqlite 💿 person non_unique 0 100 48.3±4.87µs 46.6±1.29µs 20.2 Ktx/sec 20.9 Ktx/sec
sqlite 💿 person non_unique 1000 100 58.5±0.19µs 60.7±0.25µs 16.7 Ktx/sec 16.1 Ktx/sec
sqlite 💿 person unique 0 100 49.5±2.99µs 50.9±5.15µs 19.7 Ktx/sec 19.2 Ktx/sec
sqlite 💿 person unique 1000 100 55.1±8.97µs 57.2±0.34µs 17.7 Ktx/sec 17.1 Ktx/sec
sqlite 🧠 location multi_index 0 100 119.0±0.39µs 118.5±0.42µs 8.2 Ktx/sec 8.2 Ktx/sec
sqlite 🧠 location multi_index 1000 100 170.9±0.35µs 169.3±0.34µs 5.7 Ktx/sec 5.8 Ktx/sec
sqlite 🧠 location non_unique 0 100 42.7±0.45µs 42.6±0.41µs 22.9 Ktx/sec 22.9 Ktx/sec
sqlite 🧠 location non_unique 1000 100 44.2±0.39µs 44.6±0.37µs 22.1 Ktx/sec 21.9 Ktx/sec
sqlite 🧠 location unique 0 100 44.7±0.43µs 44.9±0.43µs 21.9 Ktx/sec 21.8 Ktx/sec
sqlite 🧠 location unique 1000 100 47.5±0.48µs 48.2±0.25µs 20.5 Ktx/sec 20.2 Ktx/sec
sqlite 🧠 person multi_index 0 100 105.8±0.42µs 104.8±0.24µs 9.2 Ktx/sec 9.3 Ktx/sec
sqlite 🧠 person multi_index 1000 100 189.5±0.30µs 187.4±0.32µs 5.2 Ktx/sec 5.2 Ktx/sec
sqlite 🧠 person non_unique 0 100 41.5±0.30µs 41.2±0.33µs 23.5 Ktx/sec 23.7 Ktx/sec
sqlite 🧠 person non_unique 1000 100 44.4±0.20µs 45.1±0.29µs 22.0 Ktx/sec 21.7 Ktx/sec
sqlite 🧠 person unique 0 100 42.0±0.43µs 43.8±0.36µs 23.2 Ktx/sec 22.3 Ktx/sec
sqlite 🧠 person unique 1000 100 46.4±0.35µs 47.9±0.45µs 21.1 Ktx/sec 20.4 Ktx/sec
stdb_module 💿 location multi_index 0 100 772.1±200.62µs 799.0±165.77µs 1295 tx/sec 1251 tx/sec
stdb_module 💿 location multi_index 1000 100 847.9±27.50µs 1254.6±78.03µs 1179 tx/sec 797 tx/sec
stdb_module 💿 location non_unique 0 100 630.8±1.91µs 515.8±99.00µs 1585 tx/sec 1938 tx/sec
stdb_module 💿 location non_unique 1000 100 522.3±47.20µs 591.0±38.41µs 1914 tx/sec 1692 tx/sec
stdb_module 💿 location unique 0 100 621.1±84.58µs 805.2±136.62µs 1609 tx/sec 1241 tx/sec
stdb_module 💿 location unique 1000 100 576.7±10.10µs 618.3±73.16µs 1733 tx/sec 1617 tx/sec
stdb_module 💿 person multi_index 0 100 1152.2±134.65µs 1026.1±100.33µs 867 tx/sec 974 tx/sec
stdb_module 💿 person multi_index 1000 100 1298.9±58.57µs 1242.7±21.12µs 769 tx/sec 804 tx/sec
stdb_module 💿 person non_unique 0 100 764.6±8.33µs 589.7±106.27µs 1307 tx/sec 1695 tx/sec
stdb_module 💿 person non_unique 1000 100 1024.7±156.53µs 1019.3±12.02µs 975 tx/sec 981 tx/sec
stdb_module 💿 person unique 0 100 706.8±85.93µs 747.7±26.67µs 1414 tx/sec 1337 tx/sec
stdb_module 💿 person unique 1000 100 1182.1±89.23µs 814.0±38.56µs 845 tx/sec 1228 tx/sec
stdb_module 🧠 location multi_index 0 100 653.7±124.25µs 608.6±119.05µs 1529 tx/sec 1643 tx/sec
stdb_module 🧠 location multi_index 1000 100 879.7±75.92µs 888.3±28.01µs 1136 tx/sec 1125 tx/sec
stdb_module 🧠 location non_unique 0 100 381.9±20.51µs 375.0±23.12µs 2.6 Ktx/sec 2.6 Ktx/sec
stdb_module 🧠 location non_unique 1000 100 439.3±28.87µs 390.4±6.82µs 2.2 Ktx/sec 2.5 Ktx/sec
stdb_module 🧠 location unique 0 100 419.9±4.49µs 476.9±91.10µs 2.3 Ktx/sec 2.0 Ktx/sec
stdb_module 🧠 location unique 1000 100 453.5±63.69µs 591.3±10.43µs 2.2 Ktx/sec 1691 tx/sec
stdb_module 🧠 person multi_index 0 100 816.8±1.75µs 818.5±18.80µs 1224 tx/sec 1221 tx/sec
stdb_module 🧠 person multi_index 1000 100 916.0±30.84µs 1146.6±9.74µs 1091 tx/sec 872 tx/sec
stdb_module 🧠 person non_unique 0 100 408.7±1.31µs 389.7±18.95µs 2.4 Ktx/sec 2.5 Ktx/sec
stdb_module 🧠 person non_unique 1000 100 532.0±9.21µs 407.3±67.41µs 1879 tx/sec 2.4 Ktx/sec
stdb_module 🧠 person unique 0 100 637.7±1.80µs 638.5±10.59µs 1568 tx/sec 1566 tx/sec
stdb_module 🧠 person unique 1000 100 827.6±11.07µs 825.4±22.19µs 1208 tx/sec 1211 tx/sec
stdb_raw 💿 location multi_index 0 100 400.0±12.34µs 384.1±1.84µs 2.4 Ktx/sec 2.5 Ktx/sec
stdb_raw 💿 location multi_index 1000 100 445.0±206.07µs 430.2±208.10µs 2.2 Ktx/sec 2.3 Ktx/sec
stdb_raw 💿 location non_unique 0 100 170.3±0.20µs 157.0±0.50µs 5.7 Ktx/sec 6.2 Ktx/sec
stdb_raw 💿 location non_unique 1000 100 172.6±1.02µs 171.3±112.71µs 5.7 Ktx/sec 5.7 Ktx/sec
stdb_raw 💿 location unique 0 100 296.8±0.59µs 280.2±0.36µs 3.3 Ktx/sec 3.5 Ktx/sec
stdb_raw 💿 location unique 1000 100 317.4±1.24µs 299.0±1.15µs 3.1 Ktx/sec 3.3 Ktx/sec
stdb_raw 💿 person multi_index 0 100 724.8±1.54µs 706.5±0.75µs 1379 tx/sec 1415 tx/sec
stdb_raw 💿 person multi_index 1000 100 792.7±387.37µs 736.1±3.10µs 1261 tx/sec 1358 tx/sec
stdb_raw 💿 person non_unique 0 100 227.0±2.19µs 214.5±0.17µs 4.3 Ktx/sec 4.6 Ktx/sec
stdb_raw 💿 person non_unique 1000 100 230.1±0.53µs 232.4±153.59µs 4.2 Ktx/sec 4.2 Ktx/sec
stdb_raw 💿 person unique 0 100 440.6±1.42µs 423.5±0.97µs 2.2 Ktx/sec 2.3 Ktx/sec
stdb_raw 💿 person unique 1000 100 484.7±259.61µs 442.6±1.13µs 2.0 Ktx/sec 2.2 Ktx/sec
stdb_raw 🧠 location multi_index 0 100 304.0±2.59µs 301.6±0.43µs 3.2 Ktx/sec 3.2 Ktx/sec
stdb_raw 🧠 location multi_index 1000 100 329.3±0.56µs 324.4±0.79µs 3.0 Ktx/sec 3.0 Ktx/sec
stdb_raw 🧠 location non_unique 0 100 73.9±0.14µs 75.1±0.12µs 13.2 Ktx/sec 13.0 Ktx/sec
stdb_raw 🧠 location non_unique 1000 100 74.9±0.34µs 76.4±0.10µs 13.0 Ktx/sec 12.8 Ktx/sec
stdb_raw 🧠 location unique 0 100 201.2±0.28µs 196.8±0.23µs 4.9 Ktx/sec 5.0 Ktx/sec
stdb_raw 🧠 location unique 1000 100 219.9±0.42µs 215.8±0.94µs 4.4 Ktx/sec 4.5 Ktx/sec
stdb_raw 🧠 person multi_index 0 100 621.5±0.77µs 617.6±0.43µs 1609 tx/sec 1619 tx/sec
stdb_raw 🧠 person multi_index 1000 100 651.6±0.68µs 645.9±1.12µs 1534 tx/sec 1548 tx/sec
stdb_raw 🧠 person non_unique 0 100 125.9±0.36µs 127.4±0.19µs 7.8 Ktx/sec 7.7 Ktx/sec
stdb_raw 🧠 person non_unique 1000 100 128.5±0.33µs 130.0±0.20µs 7.6 Ktx/sec 7.5 Ktx/sec
stdb_raw 🧠 person unique 0 100 337.3±0.34µs 336.3±0.35µs 2.9 Ktx/sec 2.9 Ktx/sec
stdb_raw 🧠 person unique 1000 100 357.7±0.62µs 355.3±0.72µs 2.7 Ktx/sec 2.7 Ktx/sec

Full table iterate

db on disk schema index type new latency old latency new throughput old throughput
sqlite 💿 location unique 8.9±0.15µs 8.8±0.09µs 109.5 Ktx/sec 111.6 Ktx/sec
sqlite 💿 person unique 9.4±0.08µs 9.3±0.12µs 104.4 Ktx/sec 104.9 Ktx/sec
sqlite 🧠 location unique 7.8±0.15µs 7.6±0.08µs 125.8 Ktx/sec 129.2 Ktx/sec
sqlite 🧠 person unique 8.1±0.08µs 8.2±0.14µs 121.0 Ktx/sec 119.8 Ktx/sec
stdb_module 💿 location unique 43.9±8.88µs 47.4±5.56µs 22.3 Ktx/sec 20.6 Ktx/sec
stdb_module 💿 person unique 57.9±11.27µs 59.5±11.02µs 16.9 Ktx/sec 16.4 Ktx/sec
stdb_module 🧠 location unique 48.1±4.79µs 49.1±3.94µs 20.3 Ktx/sec 19.9 Ktx/sec
stdb_module 🧠 person unique 60.0±10.59µs 62.4±9.23µs 16.3 Ktx/sec 15.6 Ktx/sec
stdb_raw 💿 location unique 9.1±0.01µs 9.0±0.02µs 107.1 Ktx/sec 107.9 Ktx/sec
stdb_raw 💿 person unique 9.2±0.43µs 9.0±0.03µs 105.9 Ktx/sec 107.9 Ktx/sec
stdb_raw 🧠 location unique 9.1±0.03µs 9.1±0.03µs 107.0 Ktx/sec 107.9 Ktx/sec
stdb_raw 🧠 person unique 9.1±0.01µs 9.0±0.03µs 107.1 Ktx/sec 107.9 Ktx/sec

Find unique key

db on disk key type load new latency old latency new throughput old throughput
sqlite 💿 u32 1000 2.4±0.02µs 2.3±0.01µs 410.6 Ktx/sec 423.0 Ktx/sec
sqlite 🧠 u32 1000 1136.3±16.45ns 1127.1±4.98ns 859.4 Ktx/sec 866.4 Ktx/sec
stdb_module 💿 u32 1000 25.1±2.05µs 24.4±1.64µs 39.0 Ktx/sec 40.1 Ktx/sec
stdb_module 🧠 u32 1000 23.9±1.18µs 24.6±2.00µs 40.9 Ktx/sec 39.6 Ktx/sec
stdb_raw 💿 u32 1000 1920.0±15.26ns 1936.7±2.50ns 508.6 Ktx/sec 504.2 Ktx/sec
stdb_raw 🧠 u32 1000 1906.7±3.60ns 1923.6±16.02ns 512.2 Ktx/sec 507.7 Ktx/sec

Filter

db on disk key type index strategy load count new latency old latency new throughput old throughput
sqlite 💿 string indexed 1000 10 5.6±0.02µs 5.7±0.02µs 174.5 Ktx/sec 172.3 Ktx/sec
sqlite 💿 string non_indexed 1000 10 49.3±0.25µs 52.2±0.84µs 19.8 Ktx/sec 18.7 Ktx/sec
sqlite 💿 u64 indexed 1000 10 5.4±0.01µs 5.4±0.05µs 180.2 Ktx/sec 179.9 Ktx/sec
sqlite 💿 u64 non_indexed 1000 10 33.2±0.39µs 33.0±0.15µs 29.4 Ktx/sec 29.6 Ktx/sec
sqlite 🧠 string indexed 1000 10 4.1±0.02µs 4.2±0.02µs 235.7 Ktx/sec 230.7 Ktx/sec
sqlite 🧠 string non_indexed 1000 10 47.9±0.26µs 50.6±0.56µs 20.4 Ktx/sec 19.3 Ktx/sec
sqlite 🧠 u64 indexed 1000 10 4.0±0.02µs 4.0±0.02µs 245.5 Ktx/sec 244.1 Ktx/sec
sqlite 🧠 u64 non_indexed 1000 10 32.0±0.09µs 32.0±0.14µs 30.6 Ktx/sec 30.5 Ktx/sec
stdb_module 💿 string indexed 1000 10 35.3±3.47µs 36.2±2.68µs 27.7 Ktx/sec 27.0 Ktx/sec
stdb_module 💿 string non_indexed 1000 10 175.4±6.47µs 168.5±1.61µs 5.6 Ktx/sec 5.8 Ktx/sec
stdb_module 💿 u64 indexed 1000 10 33.4±2.09µs 33.5±3.02µs 29.3 Ktx/sec 29.2 Ktx/sec
stdb_module 💿 u64 non_indexed 1000 10 147.8±23.29µs 145.5±18.56µs 6.6 Ktx/sec 6.7 Ktx/sec
stdb_module 🧠 string indexed 1000 10 37.0±2.61µs 36.5±2.49µs 26.4 Ktx/sec 26.7 Ktx/sec
stdb_module 🧠 string non_indexed 1000 10 163.0±2.12µs 168.9±4.30µs 6.0 Ktx/sec 5.8 Ktx/sec
stdb_module 🧠 u64 indexed 1000 10 31.2±3.21µs 32.5±1.72µs 31.3 Ktx/sec 30.1 Ktx/sec
stdb_module 🧠 u64 non_indexed 1000 10 134.2±6.87µs 134.6±0.88µs 7.3 Ktx/sec 7.3 Ktx/sec
stdb_raw 💿 string indexed 1000 10 4.4±0.05µs 4.5±0.01µs 220.0 Ktx/sec 216.7 Ktx/sec
stdb_raw 💿 string non_indexed 1000 10 139.4±0.56µs 138.2±0.62µs 7.0 Ktx/sec 7.1 Ktx/sec
stdb_raw 💿 u64 indexed 1000 10 4.3±0.01µs 4.4±0.01µs 228.8 Ktx/sec 222.7 Ktx/sec
stdb_raw 💿 u64 non_indexed 1000 10 117.5±1.47µs 114.9±0.16µs 8.3 Ktx/sec 8.5 Ktx/sec
stdb_raw 🧠 string indexed 1000 10 4.4±0.01µs 4.5±0.01µs 221.2 Ktx/sec 217.3 Ktx/sec
stdb_raw 🧠 string non_indexed 1000 10 136.5±0.42µs 137.7±0.21µs 7.2 Ktx/sec 7.1 Ktx/sec
stdb_raw 🧠 u64 indexed 1000 10 4.3±0.01µs 4.4±0.01µs 229.0 Ktx/sec 223.9 Ktx/sec
stdb_raw 🧠 u64 non_indexed 1000 10 117.0±0.39µs 114.4±0.22µs 8.4 Ktx/sec 8.5 Ktx/sec

Serialize

schema format count new latency old latency new throughput old throughput
location bsatn 100 1789.4±32.68ns 1855.2±40.47ns 53.3 Mtx/sec 51.4 Mtx/sec
location json 100 3.1±0.00µs 3.3±0.03µs 30.5 Mtx/sec 28.8 Mtx/sec
location product_value 100 572.3±0.99ns 579.0±1.82ns 166.6 Mtx/sec 164.7 Mtx/sec
person bsatn 100 2.5±0.02µs 2.7±0.04µs 37.4 Mtx/sec 35.0 Mtx/sec
person json 100 4.8±0.03µs 4.9±0.03µs 19.8 Mtx/sec 19.5 Mtx/sec
person product_value 100 1028.5±1.36ns 1005.8±1.18ns 92.7 Mtx/sec 94.8 Mtx/sec

Module: invoke with large arguments

arg size new latency old latency new throughput old throughput
64KiB 79.9±3.92µs 76.5±13.34µs - -

Module: print bulk

line count new latency old latency new throughput old throughput
1 22.6±1.63µs 23.6±1.76µs - -
100 197.1±1.43µs 206.1±4.91µs - -
1000 1840.7±70.11µs 2.1±1.15ms - -

Remaining benchmarks

name new latency old latency new throughput old throughput

Please sign in to comment.