Skip to content

Commit

Permalink
Switch rows to IndexMap (#448)
Browse files Browse the repository at this point in the history
  • Loading branch information
RReverser authored Oct 18, 2023
1 parent 18bab3d commit a817acb
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 49 deletions.
66 changes: 22 additions & 44 deletions crates/core/src/db/datastore/locking_tx_datastore/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,9 @@ impl CommittedState {
}

fn get_or_create_table(&mut self, table_id: TableId, row_type: &ProductType, schema: &TableSchema) -> &mut Table {
self.tables.entry(table_id).or_insert_with(|| Table {
row_type: row_type.clone(),
schema: schema.clone(),
rows: BTreeMap::new(),
indexes: HashMap::new(),
})
self.tables
.entry(table_id)
.or_insert_with(|| Table::new(row_type.clone(), schema.clone()))
}

fn get_table(&mut self, table_id: &TableId) -> Option<&mut Table> {
Expand Down Expand Up @@ -567,15 +564,9 @@ impl Inner {
if self.committed_state.get_table(&table_id).is_none() {
let schema = self.schema_for_table(table_id)?.into_owned();
let row_type = self.row_type_for_table(table_id)?.into_owned();
self.committed_state.tables.insert(
table_id,
Table {
row_type,
schema,
indexes: HashMap::new(),
rows: BTreeMap::new(),
},
);
self.committed_state
.tables
.insert(table_id, Table::new(row_type, schema));
}
}
Ok(())
Expand Down Expand Up @@ -779,15 +770,11 @@ impl Inner {
row_type: ProductType,
schema: TableSchema,
) -> super::Result<()> {
self.tx_state.as_mut().unwrap().insert_tables.insert(
table_id,
Table {
row_type,
schema,
indexes: HashMap::new(),
rows: BTreeMap::new(),
},
);
self.tx_state
.as_mut()
.unwrap()
.insert_tables
.insert(table_id, Table::new(row_type, schema));
Ok(())
}

Expand Down Expand Up @@ -1014,15 +1001,11 @@ impl Inner {
} else {
let row_type = self.row_type_for_table(TableId(index.table_id))?.into_owned();
let schema = self.schema_for_table(TableId(index.table_id))?.into_owned();
self.tx_state.as_mut().unwrap().insert_tables.insert(
TableId(index.table_id),
Table {
row_type,
schema,
indexes: HashMap::new(),
rows: BTreeMap::new(),
},
);
self.tx_state
.as_mut()
.unwrap()
.insert_tables
.insert(TableId(index.table_id), Table::new(row_type, schema));
self.tx_state
.as_mut()
.unwrap()
Expand Down Expand Up @@ -1254,8 +1237,8 @@ impl Inner {
),
)
})
.collect::<HashMap<_, _>>(),
rows: BTreeMap::new(),
.collect(),
rows: Default::default(),
};
self.tx_state.as_mut().unwrap().insert_tables.insert(table_id, table);
self.tx_state.as_ref().unwrap().get_insert_table(&table_id).unwrap()
Expand Down Expand Up @@ -1630,17 +1613,12 @@ impl Locking {
table_id: TableId,
schema: TableSchema,
row_type: ProductType,
) -> &mut BTreeMap<RowId, ProductValue> {
) -> &mut indexmap::IndexMap<RowId, ProductValue> {
&mut inner
.committed_state
.tables
.entry(table_id)
.or_insert_with(|| Table {
row_type,
schema,
indexes: HashMap::new(),
rows: BTreeMap::new(),
})
.or_insert_with(|| Table::new(row_type, schema))
.rows
}

Expand Down Expand Up @@ -1725,10 +1703,10 @@ impl<'a> Iter<'a> {
enum ScanStage<'a> {
Start,
CurrentTx {
iter: std::collections::btree_map::Iter<'a, RowId, ProductValue>,
iter: indexmap::map::Iter<'a, RowId, ProductValue>,
},
Committed {
iter: std::collections::btree_map::Iter<'a, RowId, ProductValue>,
iter: indexmap::map::Iter<'a, RowId, ProductValue>,
},
}

Expand Down
17 changes: 12 additions & 5 deletions crates/core/src/db/datastore/locking_tx_datastore/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,28 @@ use super::{
RowId,
};
use crate::db::datastore::traits::{ColId, TableSchema};
use indexmap::IndexMap;
use nonempty::NonEmpty;
use spacetimedb_sats::{AlgebraicValue, ProductType, ProductValue};
use std::{
collections::{BTreeMap, HashMap},
ops::RangeBounds,
};
use std::{collections::HashMap, ops::RangeBounds};

pub(crate) struct Table {
pub(crate) row_type: ProductType,
pub(crate) schema: TableSchema,
pub(crate) indexes: HashMap<NonEmpty<ColId>, BTreeIndex>,
pub(crate) rows: BTreeMap<RowId, ProductValue>,
pub(crate) rows: IndexMap<RowId, ProductValue>,
}

impl Table {
pub(crate) fn new(row_type: ProductType, schema: TableSchema) -> Self {
Self {
row_type,
schema,
indexes: Default::default(),
rows: Default::default(),
}
}

pub(crate) fn insert_index(&mut self, mut index: BTreeIndex) {
index.build_from_rows(self.scan_rows()).unwrap();
self.indexes.insert(index.cols.clone().map(ColId), index);
Expand Down

1 comment on commit a817acb

@github-actions
Copy link

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 💿 458.1±3.46ns 458.1±8.77ns - -
sqlite 🧠 449.7±5.26ns 457.5±6.57ns - -
stdb_module 💿 15.4±0.56µs 15.6±0.36µs - -
stdb_module 🧠 15.8±0.41µs 15.9±0.44µs - -
stdb_raw 💿 103.9±0.15ns 103.7±0.12ns - -
stdb_raw 🧠 104.0±0.10ns 103.4±0.13ns - -

Single-row insertions

db on disk schema index type load new latency old latency new throughput old throughput
sqlite 💿 location multi_index 0 14.9±1.89µs 14.6±0.07µs 65.4 Ktx/sec 66.7 Ktx/sec
sqlite 💿 location multi_index 1000 15.9±0.09µs 16.0±0.13µs 61.4 Ktx/sec 60.9 Ktx/sec
sqlite 💿 location non_unique 0 7.4±2.57µs 7.4±0.04µs 131.2 Ktx/sec 132.8 Ktx/sec
sqlite 💿 location non_unique 1000 7.2±0.06µs 7.2±0.04µs 136.2 Ktx/sec 135.9 Ktx/sec
sqlite 💿 location unique 0 7.2±0.04µs 7.4±0.33µs 135.6 Ktx/sec 131.5 Ktx/sec
sqlite 💿 location unique 1000 7.2±0.05µs 7.2±0.04µs 135.9 Ktx/sec 135.8 Ktx/sec
sqlite 💿 person multi_index 0 14.4±0.03µs 14.7±0.71µs 67.9 Ktx/sec 66.5 Ktx/sec
sqlite 💿 person multi_index 1000 16.1±0.09µs 16.2±0.13µs 60.8 Ktx/sec 60.3 Ktx/sec
sqlite 💿 person non_unique 0 7.3±0.41µs 7.5±0.35µs 133.4 Ktx/sec 130.5 Ktx/sec
sqlite 💿 person non_unique 1000 7.4±0.05µs 7.4±0.04µs 132.0 Ktx/sec 132.2 Ktx/sec
sqlite 💿 person unique 0 7.3±0.03µs 7.4±0.33µs 134.2 Ktx/sec 131.6 Ktx/sec
sqlite 💿 person unique 1000 7.4±0.05µs 7.4±0.05µs 132.3 Ktx/sec 132.1 Ktx/sec
sqlite 🧠 location multi_index 0 4.1±0.01µs 4.0±0.01µs 236.8 Ktx/sec 241.3 Ktx/sec
sqlite 🧠 location multi_index 1000 5.3±0.02µs 5.2±0.03µs 185.2 Ktx/sec 186.5 Ktx/sec
sqlite 🧠 location non_unique 0 1883.7±5.01ns 1888.8±7.69ns 518.4 Ktx/sec 517.0 Ktx/sec
sqlite 🧠 location non_unique 1000 1920.6±12.43ns 1910.4±9.81ns 508.5 Ktx/sec 511.2 Ktx/sec
sqlite 🧠 location unique 0 1869.3±6.59ns 1880.8±5.27ns 522.4 Ktx/sec 519.2 Ktx/sec
sqlite 🧠 location unique 1000 1960.5±10.81ns 1951.8±7.85ns 498.1 Ktx/sec 500.3 Ktx/sec
sqlite 🧠 person multi_index 0 4.0±0.01µs 4.0±0.01µs 246.9 Ktx/sec 243.3 Ktx/sec
sqlite 🧠 person multi_index 1000 5.6±0.05µs 5.7±0.03µs 174.8 Ktx/sec 171.4 Ktx/sec
sqlite 🧠 person non_unique 0 1961.9±8.79ns 1970.5±6.36ns 497.8 Ktx/sec 495.6 Ktx/sec
sqlite 🧠 person non_unique 1000 2.1±0.02µs 2.1±0.01µs 469.4 Ktx/sec 465.7 Ktx/sec
sqlite 🧠 person unique 0 1943.8±5.62ns 1951.3±5.15ns 502.4 Ktx/sec 500.5 Ktx/sec
sqlite 🧠 person unique 1000 2.1±0.01µs 2.1±0.01µs 460.9 Ktx/sec 456.1 Ktx/sec
stdb_module 💿 location multi_index 0 45.0±3.83µs 35.1±4.62µs 21.7 Ktx/sec 27.9 Ktx/sec
stdb_module 💿 location multi_index 1000 253.3±153.10µs 136.0±55.50µs 3.9 Ktx/sec 7.2 Ktx/sec
stdb_module 💿 location non_unique 0 33.2±3.45µs 35.0±3.03µs 29.4 Ktx/sec 27.9 Ktx/sec
stdb_module 💿 location non_unique 1000 198.5±47.46µs 230.7±3.00µs 4.9 Ktx/sec 4.2 Ktx/sec
stdb_module 💿 location unique 0 40.0±3.88µs 40.4±4.30µs 24.4 Ktx/sec 24.2 Ktx/sec
stdb_module 💿 location unique 1000 399.5±110.01µs 383.8±8.09µs 2.4 Ktx/sec 2.5 Ktx/sec
stdb_module 💿 person multi_index 0 52.7±5.02µs 52.7±6.65µs 18.5 Ktx/sec 18.5 Ktx/sec
stdb_module 💿 person multi_index 1000 296.4±16.38µs 471.2±109.22µs 3.3 Ktx/sec 2.1 Ktx/sec
stdb_module 💿 person non_unique 0 38.8±3.36µs 35.8±3.54µs 25.2 Ktx/sec 27.3 Ktx/sec
stdb_module 💿 person non_unique 1000 130.1±61.61µs 259.0±113.00µs 7.5 Ktx/sec 3.8 Ktx/sec
stdb_module 💿 person unique 0 43.8±4.13µs 44.0±4.17µs 22.3 Ktx/sec 22.2 Ktx/sec
stdb_module 💿 person unique 1000 188.0±68.43µs 435.2±8.06µs 5.2 Ktx/sec 2.2 Ktx/sec
stdb_module 🧠 location multi_index 0 30.7±2.34µs 30.1±2.64µs 31.8 Ktx/sec 32.4 Ktx/sec
stdb_module 🧠 location multi_index 1000 231.1±3.70µs 217.6±15.56µs 4.2 Ktx/sec 4.5 Ktx/sec
stdb_module 🧠 location non_unique 0 26.6±1.93µs 26.0±1.45µs 36.7 Ktx/sec 37.6 Ktx/sec
stdb_module 🧠 location non_unique 1000 261.4±5.34µs 230.1±18.37µs 3.7 Ktx/sec 4.2 Ktx/sec
stdb_module 🧠 location unique 0 29.3±2.44µs 28.9±1.86µs 33.3 Ktx/sec 33.8 Ktx/sec
stdb_module 🧠 location unique 1000 308.1±13.14µs 304.6±20.93µs 3.2 Ktx/sec 3.2 Ktx/sec
stdb_module 🧠 person multi_index 0 39.7±4.02µs 38.1±3.17µs 24.6 Ktx/sec 25.6 Ktx/sec
stdb_module 🧠 person multi_index 1000 320.8±46.02µs 210.5±49.11µs 3.0 Ktx/sec 4.6 Ktx/sec
stdb_module 🧠 person non_unique 0 29.7±2.79µs 28.4±2.90µs 32.9 Ktx/sec 34.4 Ktx/sec
stdb_module 🧠 person non_unique 1000 253.1±30.95µs 247.1±21.15µs 3.9 Ktx/sec 4.0 Ktx/sec
stdb_module 🧠 person unique 0 33.9±3.16µs 34.7±3.07µs 28.8 Ktx/sec 28.2 Ktx/sec
stdb_module 🧠 person unique 1000 324.7±57.41µs 385.1±14.01µs 3.0 Ktx/sec 2.5 Ktx/sec
stdb_raw 💿 location multi_index 0 5.5±0.01µs 5.3±0.01µs 178.5 Ktx/sec 184.3 Ktx/sec
stdb_raw 💿 location multi_index 1000 31.7±0.35µs 33.8±0.51µs 30.8 Ktx/sec 28.9 Ktx/sec
stdb_raw 💿 location non_unique 0 3.6±0.01µs 3.5±0.01µs 272.3 Ktx/sec 277.3 Ktx/sec
stdb_raw 💿 location non_unique 1000 21.4±0.25µs 29.7±79.92µs 45.6 Ktx/sec 32.8 Ktx/sec
stdb_raw 💿 location unique 0 4.4±0.01µs 4.3±0.01µs 221.9 Ktx/sec 224.8 Ktx/sec
stdb_raw 💿 location unique 1000 40.8±148.85µs 39.9±127.80µs 24.0 Ktx/sec 24.5 Ktx/sec
stdb_raw 💿 person multi_index 0 9.3±0.31µs 9.0±0.01µs 105.3 Ktx/sec 108.7 Ktx/sec
stdb_raw 💿 person multi_index 1000 24.7±0.89µs 59.6±350.92µs 39.5 Ktx/sec 16.4 Ktx/sec
stdb_raw 💿 person non_unique 0 4.2±0.22µs 4.1±0.04µs 231.6 Ktx/sec 236.1 Ktx/sec
stdb_raw 💿 person non_unique 1000 12.6±0.13µs 14.2±0.13µs 77.4 Ktx/sec 68.8 Ktx/sec
stdb_raw 💿 person unique 0 6.2±0.03µs 5.9±0.01µs 157.4 Ktx/sec 165.5 Ktx/sec
stdb_raw 💿 person unique 1000 45.4±234.63µs 21.7±0.35µs 21.5 Ktx/sec 45.1 Ktx/sec
stdb_raw 🧠 location multi_index 0 4.4±0.01µs 4.1±0.01µs 219.9 Ktx/sec 237.6 Ktx/sec
stdb_raw 🧠 location multi_index 1000 23.4±0.94µs 29.4±0.79µs 41.8 Ktx/sec 33.2 Ktx/sec
stdb_raw 🧠 location non_unique 0 2.5±0.01µs 2.2±0.01µs 390.8 Ktx/sec 441.5 Ktx/sec
stdb_raw 🧠 location non_unique 1000 15.6±0.06µs 19.4±0.08µs 62.6 Ktx/sec 50.4 Ktx/sec
stdb_raw 🧠 location unique 0 3.2±0.01µs 3.0±0.01µs 309.6 Ktx/sec 322.7 Ktx/sec
stdb_raw 🧠 location unique 1000 21.0±0.08µs 24.5±0.12µs 46.5 Ktx/sec 39.9 Ktx/sec
stdb_raw 🧠 person multi_index 0 7.8±0.01µs 7.6±0.01µs 124.9 Ktx/sec 128.6 Ktx/sec
stdb_raw 🧠 person multi_index 1000 19.8±0.95µs 21.5±1.16µs 49.3 Ktx/sec 45.4 Ktx/sec
stdb_raw 🧠 person non_unique 0 2.8±0.00µs 2.8±0.01µs 342.8 Ktx/sec 345.8 Ktx/sec
stdb_raw 🧠 person non_unique 1000 9.5±0.17µs 12.8±0.17µs 102.6 Ktx/sec 76.2 Ktx/sec
stdb_raw 🧠 person unique 0 4.7±0.01µs 4.7±0.01µs 206.9 Ktx/sec 209.3 Ktx/sec
stdb_raw 🧠 person unique 1000 15.3±0.32µs 17.0±0.57µs 63.7 Ktx/sec 57.5 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 134.2±3.34µs 132.9±2.68µs 7.3 Ktx/sec 7.3 Ktx/sec
sqlite 💿 location multi_index 1000 100 207.1±29.44µs 205.2±3.24µs 4.7 Ktx/sec 4.8 Ktx/sec
sqlite 💿 location non_unique 0 100 50.2±0.37µs 50.2±3.32µs 19.5 Ktx/sec 19.4 Ktx/sec
sqlite 💿 location non_unique 1000 100 54.1±10.67µs 52.0±0.25µs 18.1 Ktx/sec 18.8 Ktx/sec
sqlite 💿 location unique 0 100 51.8±0.89µs 50.7±2.72µs 18.9 Ktx/sec 19.2 Ktx/sec
sqlite 💿 location unique 1000 100 57.4±0.36µs 55.6±0.31µs 17.0 Ktx/sec 17.6 Ktx/sec
sqlite 💿 person multi_index 0 100 120.9±3.05µs 121.1±5.76µs 8.1 Ktx/sec 8.1 Ktx/sec
sqlite 💿 person multi_index 1000 100 234.3±1.82µs 231.9±0.35µs 4.2 Ktx/sec 4.2 Ktx/sec
sqlite 💿 person non_unique 0 100 49.7±0.34µs 50.6±1.16µs 19.6 Ktx/sec 19.3 Ktx/sec
sqlite 💿 person non_unique 1000 100 61.0±0.39µs 62.0±10.46µs 16.0 Ktx/sec 15.7 Ktx/sec
sqlite 💿 person unique 0 100 51.9±2.19µs 50.7±0.33µs 18.8 Ktx/sec 19.3 Ktx/sec
sqlite 💿 person unique 1000 100 57.0±0.52µs 56.3±0.56µs 17.1 Ktx/sec 17.3 Ktx/sec
sqlite 🧠 location multi_index 0 100 121.4±0.42µs 120.3±0.27µs 8.0 Ktx/sec 8.1 Ktx/sec
sqlite 🧠 location multi_index 1000 100 172.4±0.43µs 169.8±0.42µs 5.7 Ktx/sec 5.8 Ktx/sec
sqlite 🧠 location non_unique 0 100 43.5±0.27µs 43.2±0.46µs 22.5 Ktx/sec 22.6 Ktx/sec
sqlite 🧠 location non_unique 1000 100 44.5±0.36µs 43.4±0.26µs 21.9 Ktx/sec 22.5 Ktx/sec
sqlite 🧠 location unique 0 100 45.6±0.35µs 44.3±0.49µs 21.4 Ktx/sec 22.0 Ktx/sec
sqlite 🧠 location unique 1000 100 49.1±0.40µs 47.0±0.26µs 19.9 Ktx/sec 20.8 Ktx/sec
sqlite 🧠 person multi_index 0 100 108.9±0.55µs 109.7±0.47µs 9.0 Ktx/sec 8.9 Ktx/sec
sqlite 🧠 person multi_index 1000 100 190.7±0.41µs 190.9±0.29µs 5.1 Ktx/sec 5.1 Ktx/sec
sqlite 🧠 person non_unique 0 100 44.3±0.42µs 44.1±0.31µs 22.0 Ktx/sec 22.2 Ktx/sec
sqlite 🧠 person non_unique 1000 100 47.4±0.34µs 48.1±0.30µs 20.6 Ktx/sec 20.3 Ktx/sec
sqlite 🧠 person unique 0 100 45.5±0.53µs 44.8±0.31µs 21.4 Ktx/sec 21.8 Ktx/sec
sqlite 🧠 person unique 1000 100 49.8±0.31µs 48.4±0.30µs 19.6 Ktx/sec 20.2 Ktx/sec
stdb_module 💿 location multi_index 0 100 833.9±9.07µs 802.0±33.36µs 1199 tx/sec 1246 tx/sec
stdb_module 💿 location multi_index 1000 100 1073.6±11.94µs 1066.7±8.03µs 931 tx/sec 937 tx/sec
stdb_module 💿 location non_unique 0 100 496.5±6.50µs 426.9±93.74µs 2014 tx/sec 2.3 Ktx/sec
stdb_module 💿 location non_unique 1000 100 692.0±8.65µs 762.7±66.37µs 1445 tx/sec 1311 tx/sec
stdb_module 💿 location unique 0 100 666.1±2.02µs 678.6±8.02µs 1501 tx/sec 1473 tx/sec
stdb_module 💿 location unique 1000 100 869.9±131.53µs 917.8±93.75µs 1149 tx/sec 1089 tx/sec
stdb_module 💿 person multi_index 0 100 1411.3±19.41µs 1520.0±19.35µs 708 tx/sec 657 tx/sec
stdb_module 💿 person multi_index 1000 100 1378.1±147.64µs 1493.1±75.06µs 725 tx/sec 669 tx/sec
stdb_module 💿 person non_unique 0 100 615.4±12.25µs 636.6±28.35µs 1625 tx/sec 1570 tx/sec
stdb_module 💿 person non_unique 1000 100 839.3±24.49µs 850.9±23.67µs 1191 tx/sec 1175 tx/sec
stdb_module 💿 person unique 0 100 965.2±14.04µs 939.8±26.00µs 1036 tx/sec 1064 tx/sec
stdb_module 💿 person unique 1000 100 1249.6±18.75µs 1398.5±87.23µs 800 tx/sec 715 tx/sec
stdb_module 🧠 location multi_index 0 100 434.1±1.88µs 718.2±4.41µs 2.2 Ktx/sec 1392 tx/sec
stdb_module 🧠 location multi_index 1000 100 898.2±2.59µs 921.4±5.43µs 1113 tx/sec 1085 tx/sec
stdb_module 🧠 location non_unique 0 100 380.0±8.61µs 420.1±2.15µs 2.6 Ktx/sec 2.3 Ktx/sec
stdb_module 🧠 location non_unique 1000 100 543.1±9.83µs 635.7±19.99µs 1841 tx/sec 1573 tx/sec
stdb_module 🧠 location unique 0 100 512.1±0.85µs 558.2±1.47µs 1952 tx/sec 1791 tx/sec
stdb_module 🧠 location unique 1000 100 729.2±2.18µs 742.0±19.45µs 1371 tx/sec 1347 tx/sec
stdb_module 🧠 person multi_index 0 100 1445.6±14.30µs 826.2±5.98µs 691 tx/sec 1210 tx/sec
stdb_module 🧠 person multi_index 1000 100 1523.0±164.76µs 1141.4±151.91µs 656 tx/sec 876 tx/sec
stdb_module 🧠 person non_unique 0 100 577.6±11.73µs 420.1±98.20µs 1731 tx/sec 2.3 Ktx/sec
stdb_module 🧠 person non_unique 1000 100 880.9±16.82µs 790.0±12.72µs 1135 tx/sec 1265 tx/sec
stdb_module 🧠 person unique 0 100 862.3±42.67µs 845.3±74.40µs 1159 tx/sec 1183 tx/sec
stdb_module 🧠 person unique 1000 100 1312.5±63.67µs 1152.4±14.87µs 761 tx/sec 867 tx/sec
stdb_raw 💿 location multi_index 0 100 310.6±0.99µs 304.8±0.38µs 3.1 Ktx/sec 3.2 Ktx/sec
stdb_raw 💿 location multi_index 1000 100 380.3±231.39µs 366.9±82.40µs 2.6 Ktx/sec 2.7 Ktx/sec
stdb_raw 💿 location non_unique 0 100 137.9±10.11µs 136.9±0.17µs 7.1 Ktx/sec 7.1 Ktx/sec
stdb_raw 💿 location non_unique 1000 100 151.2±1.01µs 171.2±110.79µs 6.5 Ktx/sec 5.7 Ktx/sec
stdb_raw 💿 location unique 0 100 215.5±0.27µs 214.4±0.33µs 4.5 Ktx/sec 4.6 Ktx/sec
stdb_raw 💿 location unique 1000 100 253.2±1.14µs 267.2±58.35µs 3.9 Ktx/sec 3.7 Ktx/sec
stdb_raw 💿 person multi_index 0 100 675.9±0.46µs 645.3±0.37µs 1479 tx/sec 1549 tx/sec
stdb_raw 💿 person multi_index 1000 100 760.8±324.73µs 698.6±2.60µs 1314 tx/sec 1431 tx/sec
stdb_raw 💿 person non_unique 0 100 188.9±0.29µs 195.0±0.24µs 5.2 Ktx/sec 5.0 Ktx/sec
stdb_raw 💿 person non_unique 1000 100 203.7±0.68µs 233.8±161.81µs 4.8 Ktx/sec 4.2 Ktx/sec
stdb_raw 💿 person unique 0 100 365.0±13.52µs 360.0±1.82µs 2.7 Ktx/sec 2.7 Ktx/sec
stdb_raw 💿 person unique 1000 100 393.9±0.78µs 426.5±258.75µs 2.5 Ktx/sec 2.3 Ktx/sec
stdb_raw 🧠 location multi_index 0 100 320.3±0.93µs 306.8±0.55µs 3.0 Ktx/sec 3.2 Ktx/sec
stdb_raw 🧠 location multi_index 1000 100 353.4±0.49µs 357.0±0.67µs 2.8 Ktx/sec 2.7 Ktx/sec
stdb_raw 🧠 location non_unique 0 100 129.6±0.07µs 135.4±0.10µs 7.5 Ktx/sec 7.2 Ktx/sec
stdb_raw 🧠 location non_unique 1000 100 147.5±0.50µs 156.8±0.46µs 6.6 Ktx/sec 6.2 Ktx/sec
stdb_raw 🧠 location unique 0 100 212.4±0.49µs 210.1±0.20µs 4.6 Ktx/sec 4.6 Ktx/sec
stdb_raw 🧠 location unique 1000 100 246.2±0.62µs 258.7±0.88µs 4.0 Ktx/sec 3.8 Ktx/sec
stdb_raw 🧠 person multi_index 0 100 673.6±0.76µs 643.1±0.58µs 1484 tx/sec 1554 tx/sec
stdb_raw 🧠 person multi_index 1000 100 724.2±1.66µs 685.6±2.01µs 1380 tx/sec 1458 tx/sec
stdb_raw 🧠 person non_unique 0 100 188.6±0.18µs 191.1±0.22µs 5.2 Ktx/sec 5.1 Ktx/sec
stdb_raw 🧠 person non_unique 1000 100 200.0±0.25µs 213.9±0.71µs 4.9 Ktx/sec 4.6 Ktx/sec
stdb_raw 🧠 person unique 0 100 367.9±3.05µs 355.9±0.28µs 2.7 Ktx/sec 2.7 Ktx/sec
stdb_raw 🧠 person unique 1000 100 392.8±0.92µs 397.9±2.29µs 2.5 Ktx/sec 2.5 Ktx/sec

Full table iterate

db on disk schema index type new latency old latency new throughput old throughput
sqlite 💿 location unique 9.1±0.11µs 9.0±0.12µs 106.9 Ktx/sec 108.6 Ktx/sec
sqlite 💿 person unique 9.6±0.09µs 9.3±0.10µs 102.1 Ktx/sec 105.5 Ktx/sec
sqlite 🧠 location unique 7.9±0.13µs 7.7±0.14µs 123.6 Ktx/sec 126.9 Ktx/sec
sqlite 🧠 person unique 8.4±0.08µs 8.2±0.12µs 116.3 Ktx/sec 119.7 Ktx/sec
stdb_module 💿 location unique 44.1±4.80µs 44.9±4.67µs 22.1 Ktx/sec 21.7 Ktx/sec
stdb_module 💿 person unique 56.2±9.55µs 55.0±10.15µs 17.4 Ktx/sec 17.8 Ktx/sec
stdb_module 🧠 location unique 43.7±4.03µs 46.0±3.32µs 22.4 Ktx/sec 21.2 Ktx/sec
stdb_module 🧠 person unique 59.2±8.17µs 60.1±7.36µs 16.5 Ktx/sec 16.3 Ktx/sec
stdb_raw 💿 location unique 10.3±0.01µs 10.5±0.09µs 94.5 Ktx/sec 93.2 Ktx/sec
stdb_raw 💿 person unique 11.1±0.03µs 12.2±0.01µs 88.0 Ktx/sec 80.3 Ktx/sec
stdb_raw 🧠 location unique 10.3±0.00µs 10.4±0.05µs 94.5 Ktx/sec 93.5 Ktx/sec
stdb_raw 🧠 person unique 11.1±0.03µs 12.2±0.02µs 88.1 Ktx/sec 80.3 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.01µs 2.4±0.01µs 405.9 Ktx/sec 405.5 Ktx/sec
sqlite 🧠 u32 1000 1170.9±6.98ns 1176.1±9.94ns 834.0 Ktx/sec 830.4 Ktx/sec
stdb_module 💿 u32 1000 18.6±1.32µs 18.8±1.42µs 52.5 Ktx/sec 52.0 Ktx/sec
stdb_module 🧠 u32 1000 18.3±0.67µs 18.5±1.10µs 53.4 Ktx/sec 52.9 Ktx/sec
stdb_raw 💿 u32 1000 443.8±1.34ns 491.2±1.21ns 2.1 Mtx/sec 1988.1 Ktx/sec
stdb_raw 🧠 u32 1000 441.3±0.85ns 485.1±1.01ns 2.2 Mtx/sec 2013.1 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.8±0.01µs 5.7±0.02µs 169.3 Ktx/sec 172.1 Ktx/sec
sqlite 💿 string non_indexed 1000 10 49.1±0.40µs 49.9±0.61µs 19.9 Ktx/sec 19.6 Ktx/sec
sqlite 💿 u64 indexed 1000 10 5.6±0.02µs 5.5±0.01µs 175.4 Ktx/sec 178.3 Ktx/sec
sqlite 💿 u64 non_indexed 1000 10 33.1±0.15µs 34.1±0.09µs 29.5 Ktx/sec 28.6 Ktx/sec
sqlite 🧠 string indexed 1000 10 4.3±0.02µs 4.2±0.01µs 226.8 Ktx/sec 231.4 Ktx/sec
sqlite 🧠 string non_indexed 1000 10 47.7±0.60µs 48.3±0.42µs 20.5 Ktx/sec 20.2 Ktx/sec
sqlite 🧠 u64 indexed 1000 10 4.1±0.01µs 4.1±0.02µs 238.4 Ktx/sec 240.9 Ktx/sec
sqlite 🧠 u64 non_indexed 1000 10 31.8±0.12µs 31.8±0.09µs 30.7 Ktx/sec 30.7 Ktx/sec
stdb_module 💿 string indexed 1000 10 25.5±2.89µs 26.4±2.70µs 38.3 Ktx/sec 37.0 Ktx/sec
stdb_module 💿 string non_indexed 1000 10 182.0±11.44µs 190.1±2.91µs 5.4 Ktx/sec 5.1 Ktx/sec
stdb_module 💿 u64 indexed 1000 10 20.5±0.94µs 21.1±0.98µs 47.6 Ktx/sec 46.2 Ktx/sec
stdb_module 💿 u64 non_indexed 1000 10 152.5±25.98µs 165.6±6.51µs 6.4 Ktx/sec 5.9 Ktx/sec
stdb_module 🧠 string indexed 1000 10 24.5±2.92µs 25.9±2.46µs 39.9 Ktx/sec 37.8 Ktx/sec
stdb_module 🧠 string non_indexed 1000 10 180.1±4.52µs 187.4±4.32µs 5.4 Ktx/sec 5.2 Ktx/sec
stdb_module 🧠 u64 indexed 1000 10 20.7±1.06µs 21.1±1.04µs 47.1 Ktx/sec 46.2 Ktx/sec
stdb_module 🧠 u64 non_indexed 1000 10 141.7±5.32µs 158.1±4.72µs 6.9 Ktx/sec 6.2 Ktx/sec
stdb_raw 💿 string indexed 1000 10 2.2±0.00µs 2.6±0.00µs 445.1 Ktx/sec 371.5 Ktx/sec
stdb_raw 💿 string non_indexed 1000 10 163.5±0.55µs 173.2±0.73µs 6.0 Ktx/sec 5.6 Ktx/sec
stdb_raw 💿 u64 indexed 1000 10 1741.0±2.07ns 2.2±0.01µs 560.9 Ktx/sec 439.0 Ktx/sec
stdb_raw 💿 u64 non_indexed 1000 10 131.4±0.17µs 135.7±1.88µs 7.4 Ktx/sec 7.2 Ktx/sec
stdb_raw 🧠 string indexed 1000 10 2.2±0.02µs 2.6±0.00µs 445.6 Ktx/sec 372.0 Ktx/sec
stdb_raw 🧠 string non_indexed 1000 10 161.2±1.51µs 172.8±0.56µs 6.1 Ktx/sec 5.7 Ktx/sec
stdb_raw 🧠 u64 indexed 1000 10 1745.6±17.85ns 2.2±0.00µs 559.4 Ktx/sec 437.9 Ktx/sec
stdb_raw 🧠 u64 non_indexed 1000 10 131.9±0.37µs 135.0±0.35µs 7.4 Ktx/sec 7.2 Ktx/sec

Serialize

schema format count new latency old latency new throughput old throughput
location bsatn 100 1738.0±51.73ns 1659.9±116.77ns 54.9 Mtx/sec 57.5 Mtx/sec
location json 100 3.2±0.01µs 3.2±0.09µs 30.0 Mtx/sec 29.5 Mtx/sec
location product_value 100 2.4±0.01µs 2.5±0.01µs 40.1 Mtx/sec 38.4 Mtx/sec
person bsatn 100 2.4±0.02µs 2.4±0.01µs 39.0 Mtx/sec 38.9 Mtx/sec
person json 100 5.1±0.06µs 4.9±0.04µs 18.5 Mtx/sec 19.4 Mtx/sec
person product_value 100 1611.5±5.06ns 1615.2±6.59ns 59.2 Mtx/sec 59.0 Mtx/sec

Module: invoke with large arguments

arg size new latency old latency new throughput old throughput
64KiB 79.1±6.11µs 92.2±9.90µs - -

Module: print bulk

line count new latency old latency new throughput old throughput
1 20.3±1.02µs 20.7±1.30µs - -
100 199.4±1.19µs 200.8±1.68µs - -
1000 1842.6±133.80µs 1815.2±7.83µs - -

Remaining benchmarks

name new latency old latency new throughput old throughput

Please sign in to comment.