Skip to content

Commit

Permalink
lib: Don't panic in RelValueRef::get (#450)
Browse files Browse the repository at this point in the history
There is no guarantee that a named field is in the supplied table
header, nor that it is in the row. Panicking at this location can be
disastrous, while all call sites are inside Result already. So, return
Result.
  • Loading branch information
kim authored Oct 19, 2023
1 parent a817acb commit fca6cf3
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 23 deletions.
8 changes: 4 additions & 4 deletions crates/core/src/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,16 @@ fn join_inner<'a>(
rhs,
header,
move |row| {
let f = row.get(&key_lhs, &key_lhs_header);
let f = row.get(&key_lhs, &key_lhs_header)?;
Ok(f.into())
},
move |row| {
let f = row.get(&key_rhs, &key_rhs_header);
let f = row.get(&key_rhs, &key_rhs_header)?;
Ok(f.into())
},
move |l, r| {
let l = l.get(&col_lhs, &col_lhs_header);
let r = r.get(&col_rhs, &col_rhs_header);
let l = l.get(&col_lhs, &col_lhs_header)?;
let r = r.get(&col_rhs, &col_rhs_header)?;
Ok(l == r)
},
move |l, r| {
Expand Down
2 changes: 2 additions & 0 deletions crates/lib/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ pub enum AuthError {
pub enum RelationError {
#[error("Field `{1}` not found. Must be one of {0}")]
FieldNotFound(Header, FieldName),
#[error("Field `{1}` not found at position {0}")]
FieldNotFoundAtPos(usize, FieldName),
#[error("Field `{0}` fail to infer the type: {1}")]
TypeInference(FieldName, TypeError),
#[error("Field declaration only support `table.field` or `field`. It gets instead `{0}`")]
Expand Down
24 changes: 12 additions & 12 deletions crates/lib/src/relation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,21 +416,21 @@ impl<'a> RelValueRef<'a> {
Self { data }
}

pub fn get(&self, col: &'a FieldExpr, header: &'a Header) -> &'a AlgebraicValue {
match col {
pub fn get(&self, col: &'a FieldExpr, header: &'a Header) -> Result<&'a AlgebraicValue, RelationError> {
let val = match col {
FieldExpr::Name(col) => {
if let Some(pos) = header.column_pos(col) {
if let Some(v) = self.data.elements.get(pos) {
v
} else {
unreachable!("Field `{col}` at pos {pos} not found on row: {:?}", self.data.elements)
}
} else {
unreachable!("Field `{col}` not found on `{}`. Fields:{}", header.table_name, header)
}
let pos = header
.column_pos(col)
.ok_or_else(|| RelationError::FieldNotFound(header.clone(), col.clone()))?;
self.data
.elements
.get(pos)
.ok_or_else(|| RelationError::FieldNotFoundAtPos(pos, col.clone()))?
}
FieldExpr::Value(x) => x,
}
};

Ok(val)
}

pub fn project(&self, cols: &[FieldExpr], header: &'a Header) -> Result<ProductValue, RelationError> {
Expand Down
8 changes: 4 additions & 4 deletions crates/vm/src/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,16 +458,16 @@ pub fn build_query(mut result: Box<IterRows>, query: Vec<Query>) -> Result<Box<I
rhs,
col_lhs_header.extend(&col_rhs_header),
move |row| {
let f = row.get(&key_lhs, &key_lhs_header);
let f = row.get(&key_lhs, &key_lhs_header)?;
Ok(f.into())
},
move |row| {
let f = row.get(&key_rhs, &key_rhs_header);
let f = row.get(&key_rhs, &key_rhs_header)?;
Ok(f.into())
},
move |l, r| {
let l = l.get(&col_lhs, &col_lhs_header);
let r = r.get(&col_rhs, &col_rhs_header);
let l = l.get(&col_lhs, &col_lhs_header)?;
let r = r.get(&col_rhs, &col_rhs_header)?;
Ok(l == r)
},
move |l, r| l.extend(r),
Expand Down
6 changes: 3 additions & 3 deletions crates/vm/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,15 @@ impl ColumnOp {

fn reduce(&self, row: RelValueRef, value: &ColumnOp, header: &Header) -> Result<AlgebraicValue, ErrorLang> {
match value {
ColumnOp::Field(field) => Ok(row.get(field, header).clone()),
ColumnOp::Field(field) => Ok(row.get(field, header)?.clone()),
ColumnOp::Cmp { op, lhs, rhs } => Ok(self.compare_bin_op(row, *op, lhs, rhs, header)?.into()),
}
}

fn reduce_bool(&self, row: RelValueRef, value: &ColumnOp, header: &Header) -> Result<bool, ErrorLang> {
match value {
ColumnOp::Field(field) => {
let field = row.get(field, header);
let field = row.get(field, header)?;

match field.as_bool() {
Some(b) => Ok(*b),
Expand Down Expand Up @@ -156,7 +156,7 @@ impl ColumnOp {
pub fn compare(&self, row: RelValueRef, header: &Header) -> Result<bool, ErrorVm> {
match self {
ColumnOp::Field(field) => {
let lhs = row.get(field, header);
let lhs = row.get(field, header)?;
Ok(*lhs.as_bool().unwrap())
}
ColumnOp::Cmp { op, lhs, rhs } => self.compare_bin_op(row, *op, lhs, rhs, header),
Expand Down

1 comment on commit fca6cf3

@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 💿 448.5±1.38ns 458.1±3.46ns - -
sqlite 🧠 445.0±3.32ns 449.7±5.26ns - -
stdb_module 💿 15.6±0.48µs 15.4±0.56µs - -
stdb_module 🧠 16.2±0.40µs 15.8±0.41µs - -
stdb_raw 💿 99.3±0.97ns 103.9±0.15ns - -
stdb_raw 🧠 98.7±0.83ns 104.0±0.10ns - -

Single-row insertions

db on disk schema index type load new latency old latency new throughput old throughput
sqlite 💿 location multi_index 0 14.5±0.04µs 14.9±1.89µs 67.1 Ktx/sec 65.4 Ktx/sec
sqlite 💿 location multi_index 1000 15.9±0.11µs 15.9±0.09µs 61.6 Ktx/sec 61.4 Ktx/sec
sqlite 💿 location non_unique 0 7.3±0.02µs 7.4±2.57µs 134.4 Ktx/sec 131.2 Ktx/sec
sqlite 💿 location non_unique 1000 7.7±6.92µs 7.2±0.06µs 126.1 Ktx/sec 136.2 Ktx/sec
sqlite 💿 location unique 0 7.3±0.32µs 7.2±0.04µs 134.4 Ktx/sec 135.6 Ktx/sec
sqlite 💿 location unique 1000 7.1±0.04µs 7.2±0.05µs 137.2 Ktx/sec 135.9 Ktx/sec
sqlite 💿 person multi_index 0 14.8±2.14µs 14.4±0.03µs 65.9 Ktx/sec 67.9 Ktx/sec
sqlite 💿 person multi_index 1000 16.2±0.13µs 16.1±0.09µs 60.2 Ktx/sec 60.8 Ktx/sec
sqlite 💿 person non_unique 0 7.3±0.04µs 7.3±0.41µs 133.8 Ktx/sec 133.4 Ktx/sec
sqlite 💿 person non_unique 1000 7.4±0.07µs 7.4±0.05µs 132.8 Ktx/sec 132.0 Ktx/sec
sqlite 💿 person unique 0 7.4±0.91µs 7.3±0.03µs 132.0 Ktx/sec 134.2 Ktx/sec
sqlite 💿 person unique 1000 7.4±0.06µs 7.4±0.05µs 131.6 Ktx/sec 132.3 Ktx/sec
sqlite 🧠 location multi_index 0 4.2±0.01µs 4.1±0.01µs 232.1 Ktx/sec 236.8 Ktx/sec
sqlite 🧠 location multi_index 1000 5.4±0.05µs 5.3±0.02µs 181.4 Ktx/sec 185.2 Ktx/sec
sqlite 🧠 location non_unique 0 1899.8±6.76ns 1883.7±5.01ns 514.0 Ktx/sec 518.4 Ktx/sec
sqlite 🧠 location non_unique 1000 1926.3±6.60ns 1920.6±12.43ns 507.0 Ktx/sec 508.5 Ktx/sec
sqlite 🧠 location unique 0 1883.8±16.21ns 1869.3±6.59ns 518.4 Ktx/sec 522.4 Ktx/sec
sqlite 🧠 location unique 1000 2.0±0.02µs 1960.5±10.81ns 486.4 Ktx/sec 498.1 Ktx/sec
sqlite 🧠 person multi_index 0 4.0±0.01µs 4.0±0.01µs 242.2 Ktx/sec 246.9 Ktx/sec
sqlite 🧠 person multi_index 1000 5.9±0.05µs 5.6±0.05µs 166.3 Ktx/sec 174.8 Ktx/sec
sqlite 🧠 person non_unique 0 1994.5±10.94ns 1961.9±8.79ns 489.6 Ktx/sec 497.8 Ktx/sec
sqlite 🧠 person non_unique 1000 2.1±0.02µs 2.1±0.02µs 463.6 Ktx/sec 469.4 Ktx/sec
sqlite 🧠 person unique 0 1949.1±4.45ns 1943.8±5.62ns 501.0 Ktx/sec 502.4 Ktx/sec
sqlite 🧠 person unique 1000 2.2±0.03µs 2.1±0.01µs 446.7 Ktx/sec 460.9 Ktx/sec
stdb_module 💿 location multi_index 0 45.1±4.62µs 45.0±3.83µs 21.6 Ktx/sec 21.7 Ktx/sec
stdb_module 💿 location multi_index 1000 169.2±68.24µs 253.3±153.10µs 5.8 Ktx/sec 3.9 Ktx/sec
stdb_module 💿 location non_unique 0 35.8±3.97µs 33.2±3.45µs 27.3 Ktx/sec 29.4 Ktx/sec
stdb_module 💿 location non_unique 1000 344.0±5.36µs 198.5±47.46µs 2.8 Ktx/sec 4.9 Ktx/sec
stdb_module 💿 location unique 0 45.4±6.69µs 40.0±3.88µs 21.5 Ktx/sec 24.4 Ktx/sec
stdb_module 💿 location unique 1000 308.4±127.81µs 399.5±110.01µs 3.2 Ktx/sec 2.4 Ktx/sec
stdb_module 💿 person multi_index 0 47.9±6.97µs 52.7±5.02µs 20.4 Ktx/sec 18.5 Ktx/sec
stdb_module 💿 person multi_index 1000 434.3±201.77µs 296.4±16.38µs 2.2 Ktx/sec 3.3 Ktx/sec
stdb_module 💿 person non_unique 0 40.2±5.50µs 38.8±3.36µs 24.3 Ktx/sec 25.2 Ktx/sec
stdb_module 💿 person non_unique 1000 260.5±97.41µs 130.1±61.61µs 3.7 Ktx/sec 7.5 Ktx/sec
stdb_module 💿 person unique 0 44.7±4.32µs 43.8±4.13µs 21.8 Ktx/sec 22.3 Ktx/sec
stdb_module 💿 person unique 1000 322.3±30.64µs 188.0±68.43µs 3.0 Ktx/sec 5.2 Ktx/sec
stdb_module 🧠 location multi_index 0 29.2±2.17µs 30.7±2.34µs 33.4 Ktx/sec 31.8 Ktx/sec
stdb_module 🧠 location multi_index 1000 417.5±67.09µs 231.1±3.70µs 2.3 Ktx/sec 4.2 Ktx/sec
stdb_module 🧠 location non_unique 0 27.4±2.49µs 26.6±1.93µs 35.7 Ktx/sec 36.7 Ktx/sec
stdb_module 🧠 location non_unique 1000 217.9±2.90µs 261.4±5.34µs 4.5 Ktx/sec 3.7 Ktx/sec
stdb_module 🧠 location unique 0 29.9±2.00µs 29.3±2.44µs 32.7 Ktx/sec 33.3 Ktx/sec
stdb_module 🧠 location unique 1000 232.5±6.15µs 308.1±13.14µs 4.2 Ktx/sec 3.2 Ktx/sec
stdb_module 🧠 person multi_index 0 39.0±4.98µs 39.7±4.02µs 25.1 Ktx/sec 24.6 Ktx/sec
stdb_module 🧠 person multi_index 1000 271.9±92.13µs 320.8±46.02µs 3.6 Ktx/sec 3.0 Ktx/sec
stdb_module 🧠 person non_unique 0 28.8±2.47µs 29.7±2.79µs 33.9 Ktx/sec 32.9 Ktx/sec
stdb_module 🧠 person non_unique 1000 228.5±16.21µs 253.1±30.95µs 4.3 Ktx/sec 3.9 Ktx/sec
stdb_module 🧠 person unique 0 33.6±4.17µs 33.9±3.16µs 29.1 Ktx/sec 28.8 Ktx/sec
stdb_module 🧠 person unique 1000 267.3±32.67µs 324.7±57.41µs 3.7 Ktx/sec 3.0 Ktx/sec
stdb_raw 💿 location multi_index 0 5.4±0.02µs 5.5±0.01µs 180.6 Ktx/sec 178.5 Ktx/sec
stdb_raw 💿 location multi_index 1000 50.1±191.83µs 31.7±0.35µs 19.5 Ktx/sec 30.8 Ktx/sec
stdb_raw 💿 location non_unique 0 3.5±0.01µs 3.6±0.01µs 277.5 Ktx/sec 272.3 Ktx/sec
stdb_raw 💿 location non_unique 1000 31.0±96.76µs 21.4±0.25µs 31.5 Ktx/sec 45.6 Ktx/sec
stdb_raw 💿 location unique 0 4.4±0.17µs 4.4±0.01µs 222.7 Ktx/sec 221.9 Ktx/sec
stdb_raw 💿 location unique 1000 37.5±112.82µs 40.8±148.85µs 26.0 Ktx/sec 24.0 Ktx/sec
stdb_raw 💿 person multi_index 0 9.1±0.01µs 9.3±0.31µs 107.6 Ktx/sec 105.3 Ktx/sec
stdb_raw 💿 person multi_index 1000 59.5±349.07µs 24.7±0.89µs 16.4 Ktx/sec 39.5 Ktx/sec
stdb_raw 💿 person non_unique 0 4.1±0.01µs 4.2±0.22µs 236.8 Ktx/sec 231.6 Ktx/sec
stdb_raw 💿 person non_unique 1000 12.5±0.11µs 12.6±0.13µs 78.2 Ktx/sec 77.4 Ktx/sec
stdb_raw 💿 person unique 0 6.0±0.01µs 6.2±0.03µs 162.2 Ktx/sec 157.4 Ktx/sec
stdb_raw 💿 person unique 1000 45.5±234.27µs 45.4±234.63µs 21.4 Ktx/sec 21.5 Ktx/sec
stdb_raw 🧠 location multi_index 0 4.3±0.01µs 4.4±0.01µs 224.5 Ktx/sec 219.9 Ktx/sec
stdb_raw 🧠 location multi_index 1000 23.0±0.96µs 23.4±0.94µs 42.4 Ktx/sec 41.8 Ktx/sec
stdb_raw 🧠 location non_unique 0 2.5±0.01µs 2.5±0.01µs 395.4 Ktx/sec 390.8 Ktx/sec
stdb_raw 🧠 location non_unique 1000 16.2±0.08µs 15.6±0.06µs 60.5 Ktx/sec 62.6 Ktx/sec
stdb_raw 🧠 location unique 0 3.1±0.01µs 3.2±0.01µs 315.4 Ktx/sec 309.6 Ktx/sec
stdb_raw 🧠 location unique 1000 21.4±0.09µs 21.0±0.08µs 45.6 Ktx/sec 46.5 Ktx/sec
stdb_raw 🧠 person multi_index 0 7.7±0.01µs 7.8±0.01µs 126.6 Ktx/sec 124.9 Ktx/sec
stdb_raw 🧠 person multi_index 1000 20.0±0.92µs 19.8±0.95µs 48.8 Ktx/sec 49.3 Ktx/sec
stdb_raw 🧠 person non_unique 0 2.8±0.01µs 2.8±0.00µs 343.6 Ktx/sec 342.8 Ktx/sec
stdb_raw 🧠 person non_unique 1000 9.6±0.12µs 9.5±0.17µs 101.6 Ktx/sec 102.6 Ktx/sec
stdb_raw 🧠 person unique 0 4.7±0.01µs 4.7±0.01µs 206.3 Ktx/sec 206.9 Ktx/sec
stdb_raw 🧠 person unique 1000 15.3±0.34µs 15.3±0.32µs 64.0 Ktx/sec 63.7 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 130.5±5.00µs 134.2±3.34µs 7.5 Ktx/sec 7.3 Ktx/sec
sqlite 💿 location multi_index 1000 100 203.5±1.13µs 207.1±29.44µs 4.8 Ktx/sec 4.7 Ktx/sec
sqlite 💿 location non_unique 0 100 50.6±1.64µs 50.2±0.37µs 19.3 Ktx/sec 19.5 Ktx/sec
sqlite 💿 location non_unique 1000 100 52.8±0.23µs 54.1±10.67µs 18.5 Ktx/sec 18.1 Ktx/sec
sqlite 💿 location unique 0 100 51.9±1.86µs 51.8±0.89µs 18.8 Ktx/sec 18.9 Ktx/sec
sqlite 💿 location unique 1000 100 56.4±0.28µs 57.4±0.36µs 17.3 Ktx/sec 17.0 Ktx/sec
sqlite 💿 person multi_index 0 100 119.6±5.43µs 120.9±3.05µs 8.2 Ktx/sec 8.1 Ktx/sec
sqlite 💿 person multi_index 1000 100 229.2±0.45µs 234.3±1.82µs 4.3 Ktx/sec 4.2 Ktx/sec
sqlite 💿 person non_unique 0 100 50.4±1.55µs 49.7±0.34µs 19.4 Ktx/sec 19.6 Ktx/sec
sqlite 💿 person non_unique 1000 100 63.2±16.73µs 61.0±0.39µs 15.4 Ktx/sec 16.0 Ktx/sec
sqlite 💿 person unique 0 100 52.1±1.36µs 51.9±2.19µs 18.8 Ktx/sec 18.8 Ktx/sec
sqlite 💿 person unique 1000 100 57.5±0.33µs 57.0±0.52µs 17.0 Ktx/sec 17.1 Ktx/sec
sqlite 🧠 location multi_index 0 100 118.2±0.56µs 121.4±0.42µs 8.3 Ktx/sec 8.0 Ktx/sec
sqlite 🧠 location multi_index 1000 100 169.8±0.56µs 172.4±0.43µs 5.8 Ktx/sec 5.7 Ktx/sec
sqlite 🧠 location non_unique 0 100 42.8±0.37µs 43.5±0.27µs 22.8 Ktx/sec 22.5 Ktx/sec
sqlite 🧠 location non_unique 1000 100 44.6±0.39µs 44.5±0.36µs 21.9 Ktx/sec 21.9 Ktx/sec
sqlite 🧠 location unique 0 100 44.0±0.35µs 45.6±0.35µs 22.2 Ktx/sec 21.4 Ktx/sec
sqlite 🧠 location unique 1000 100 48.1±0.24µs 49.1±0.40µs 20.3 Ktx/sec 19.9 Ktx/sec
sqlite 🧠 person multi_index 0 100 107.1±0.44µs 108.9±0.55µs 9.1 Ktx/sec 9.0 Ktx/sec
sqlite 🧠 person multi_index 1000 100 190.2±0.50µs 190.7±0.41µs 5.1 Ktx/sec 5.1 Ktx/sec
sqlite 🧠 person non_unique 0 100 43.7±0.46µs 44.3±0.42µs 22.3 Ktx/sec 22.0 Ktx/sec
sqlite 🧠 person non_unique 1000 100 48.1±0.25µs 47.4±0.34µs 20.3 Ktx/sec 20.6 Ktx/sec
sqlite 🧠 person unique 0 100 44.8±0.27µs 45.5±0.53µs 21.8 Ktx/sec 21.4 Ktx/sec
sqlite 🧠 person unique 1000 100 49.4±0.36µs 49.8±0.31µs 19.8 Ktx/sec 19.6 Ktx/sec
stdb_module 💿 location multi_index 0 100 769.2±21.94µs 833.9±9.07µs 1300 tx/sec 1199 tx/sec
stdb_module 💿 location multi_index 1000 100 1055.2±6.05µs 1073.6±11.94µs 947 tx/sec 931 tx/sec
stdb_module 💿 location non_unique 0 100 464.8±6.72µs 496.5±6.50µs 2.1 Ktx/sec 2014 tx/sec
stdb_module 💿 location non_unique 1000 100 664.2±10.86µs 692.0±8.65µs 1505 tx/sec 1445 tx/sec
stdb_module 💿 location unique 0 100 597.9±10.00µs 666.1±2.02µs 1672 tx/sec 1501 tx/sec
stdb_module 💿 location unique 1000 100 852.4±3.97µs 869.9±131.53µs 1173 tx/sec 1149 tx/sec
stdb_module 💿 person multi_index 0 100 1470.2±78.91µs 1411.3±19.41µs 680 tx/sec 708 tx/sec
stdb_module 💿 person multi_index 1000 100 1763.3±13.34µs 1378.1±147.64µs 567 tx/sec 725 tx/sec
stdb_module 💿 person non_unique 0 100 658.3±2.49µs 615.4±12.25µs 1519 tx/sec 1625 tx/sec
stdb_module 💿 person non_unique 1000 100 887.6±37.70µs 839.3±24.49µs 1126 tx/sec 1191 tx/sec
stdb_module 💿 person unique 0 100 930.4±29.45µs 965.2±14.04µs 1074 tx/sec 1036 tx/sec
stdb_module 💿 person unique 1000 100 1103.7±53.39µs 1249.6±18.75µs 906 tx/sec 800 tx/sec
stdb_module 🧠 location multi_index 0 100 706.8±31.44µs 434.1±1.88µs 1414 tx/sec 2.2 Ktx/sec
stdb_module 🧠 location multi_index 1000 100 915.0±28.69µs 898.2±2.59µs 1092 tx/sec 1113 tx/sec
stdb_module 🧠 location non_unique 0 100 411.9±10.09µs 380.0±8.61µs 2.4 Ktx/sec 2.6 Ktx/sec
stdb_module 🧠 location non_unique 1000 100 631.9±22.92µs 543.1±9.83µs 1582 tx/sec 1841 tx/sec
stdb_module 🧠 location unique 0 100 523.0±25.85µs 512.1±0.85µs 1912 tx/sec 1952 tx/sec
stdb_module 🧠 location unique 1000 100 846.1±22.06µs 729.2±2.18µs 1181 tx/sec 1371 tx/sec
stdb_module 🧠 person multi_index 0 100 1382.0±19.50µs 1445.6±14.30µs 723 tx/sec 691 tx/sec
stdb_module 🧠 person multi_index 1000 100 1779.9±164.56µs 1523.0±164.76µs 561 tx/sec 656 tx/sec
stdb_module 🧠 person non_unique 0 100 565.7±19.98µs 577.6±11.73µs 1767 tx/sec 1731 tx/sec
stdb_module 🧠 person non_unique 1000 100 841.1±52.38µs 880.9±16.82µs 1188 tx/sec 1135 tx/sec
stdb_module 🧠 person unique 0 100 632.6±100.85µs 862.3±42.67µs 1580 tx/sec 1159 tx/sec
stdb_module 🧠 person unique 1000 100 1048.5±109.25µs 1312.5±63.67µs 953 tx/sec 761 tx/sec
stdb_raw 💿 location multi_index 0 100 303.3±9.15µs 310.6±0.99µs 3.2 Ktx/sec 3.1 Ktx/sec
stdb_raw 💿 location multi_index 1000 100 347.9±1.23µs 380.3±231.39µs 2.8 Ktx/sec 2.6 Ktx/sec
stdb_raw 💿 location non_unique 0 100 136.9±4.76µs 137.9±10.11µs 7.1 Ktx/sec 7.1 Ktx/sec
stdb_raw 💿 location non_unique 1000 100 150.0±1.01µs 151.2±1.01µs 6.5 Ktx/sec 6.5 Ktx/sec
stdb_raw 💿 location unique 0 100 208.4±0.91µs 215.5±0.27µs 4.7 Ktx/sec 4.5 Ktx/sec
stdb_raw 💿 location unique 1000 100 260.4±150.24µs 253.2±1.14µs 3.8 Ktx/sec 3.9 Ktx/sec
stdb_raw 💿 person multi_index 0 100 640.4±0.39µs 675.9±0.46µs 1561 tx/sec 1479 tx/sec
stdb_raw 💿 person multi_index 1000 100 701.9±1.60µs 760.8±324.73µs 1424 tx/sec 1314 tx/sec
stdb_raw 💿 person non_unique 0 100 191.6±3.03µs 188.9±0.29µs 5.1 Ktx/sec 5.2 Ktx/sec
stdb_raw 💿 person non_unique 1000 100 217.1±118.92µs 203.7±0.68µs 4.5 Ktx/sec 4.8 Ktx/sec
stdb_raw 💿 person unique 0 100 355.1±0.39µs 365.0±13.52µs 2.8 Ktx/sec 2.7 Ktx/sec
stdb_raw 💿 person unique 1000 100 429.5±330.50µs 393.9±0.78µs 2.3 Ktx/sec 2.5 Ktx/sec
stdb_raw 🧠 location multi_index 0 100 305.4±0.56µs 320.3±0.93µs 3.2 Ktx/sec 3.0 Ktx/sec
stdb_raw 🧠 location multi_index 1000 100 342.2±0.40µs 353.4±0.49µs 2.9 Ktx/sec 2.8 Ktx/sec
stdb_raw 🧠 location non_unique 0 100 129.2±0.15µs 129.6±0.07µs 7.6 Ktx/sec 7.5 Ktx/sec
stdb_raw 🧠 location non_unique 1000 100 147.1±0.16µs 147.5±0.50µs 6.6 Ktx/sec 6.6 Ktx/sec
stdb_raw 🧠 location unique 0 100 209.7±0.70µs 212.4±0.49µs 4.7 Ktx/sec 4.6 Ktx/sec
stdb_raw 🧠 location unique 1000 100 237.9±0.25µs 246.2±0.62µs 4.1 Ktx/sec 4.0 Ktx/sec
stdb_raw 🧠 person multi_index 0 100 650.7±1.16µs 673.6±0.76µs 1536 tx/sec 1484 tx/sec
stdb_raw 🧠 person multi_index 1000 100 698.7±1.27µs 724.2±1.66µs 1431 tx/sec 1380 tx/sec
stdb_raw 🧠 person non_unique 0 100 191.2±0.40µs 188.6±0.18µs 5.1 Ktx/sec 5.2 Ktx/sec
stdb_raw 🧠 person non_unique 1000 100 201.6±0.41µs 200.0±0.25µs 4.8 Ktx/sec 4.9 Ktx/sec
stdb_raw 🧠 person unique 0 100 356.3±0.25µs 367.9±3.05µs 2.7 Ktx/sec 2.7 Ktx/sec
stdb_raw 🧠 person unique 1000 100 382.0±1.07µs 392.8±0.92µs 2.6 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 8.9±0.17µs 9.1±0.11µs 110.1 Ktx/sec 106.9 Ktx/sec
sqlite 💿 person unique 9.3±0.10µs 9.6±0.09µs 105.2 Ktx/sec 102.1 Ktx/sec
sqlite 🧠 location unique 7.7±0.08µs 7.9±0.13µs 127.2 Ktx/sec 123.6 Ktx/sec
sqlite 🧠 person unique 8.0±0.07µs 8.4±0.08µs 122.5 Ktx/sec 116.3 Ktx/sec
stdb_module 💿 location unique 41.9±2.68µs 44.1±4.80µs 23.3 Ktx/sec 22.1 Ktx/sec
stdb_module 💿 person unique 60.0±8.49µs 56.2±9.55µs 16.3 Ktx/sec 17.4 Ktx/sec
stdb_module 🧠 location unique 44.4±2.52µs 43.7±4.03µs 22.0 Ktx/sec 22.4 Ktx/sec
stdb_module 🧠 person unique 56.1±10.47µs 59.2±8.17µs 17.4 Ktx/sec 16.5 Ktx/sec
stdb_raw 💿 location unique 9.6±0.01µs 10.3±0.01µs 102.1 Ktx/sec 94.5 Ktx/sec
stdb_raw 💿 person unique 10.8±0.07µs 11.1±0.03µs 90.7 Ktx/sec 88.0 Ktx/sec
stdb_raw 🧠 location unique 9.6±0.01µs 10.3±0.00µs 102.0 Ktx/sec 94.5 Ktx/sec
stdb_raw 🧠 person unique 10.5±0.02µs 11.1±0.03µs 93.0 Ktx/sec 88.1 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.00µs 2.4±0.01µs 407.8 Ktx/sec 405.9 Ktx/sec
sqlite 🧠 u32 1000 1166.8±9.87ns 1170.9±6.98ns 837.0 Ktx/sec 834.0 Ktx/sec
stdb_module 💿 u32 1000 18.1±0.80µs 18.6±1.32µs 54.0 Ktx/sec 52.5 Ktx/sec
stdb_module 🧠 u32 1000 18.4±0.85µs 18.3±0.67µs 53.1 Ktx/sec 53.4 Ktx/sec
stdb_raw 💿 u32 1000 428.8±1.40ns 443.8±1.34ns 2.2 Mtx/sec 2.1 Mtx/sec
stdb_raw 🧠 u32 1000 427.6±1.31ns 441.3±0.85ns 2.2 Mtx/sec 2.2 Mtx/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.03µs 5.8±0.01µs 168.8 Ktx/sec 169.3 Ktx/sec
sqlite 💿 string non_indexed 1000 10 48.8±0.43µs 49.1±0.40µs 20.0 Ktx/sec 19.9 Ktx/sec
sqlite 💿 u64 indexed 1000 10 5.5±0.02µs 5.6±0.02µs 176.2 Ktx/sec 175.4 Ktx/sec
sqlite 💿 u64 non_indexed 1000 10 33.0±0.06µs 33.1±0.15µs 29.6 Ktx/sec 29.5 Ktx/sec
sqlite 🧠 string indexed 1000 10 4.3±0.05µs 4.3±0.02µs 227.6 Ktx/sec 226.8 Ktx/sec
sqlite 🧠 string non_indexed 1000 10 47.4±0.52µs 47.7±0.60µs 20.6 Ktx/sec 20.5 Ktx/sec
sqlite 🧠 u64 indexed 1000 10 4.1±0.02µs 4.1±0.01µs 237.3 Ktx/sec 238.4 Ktx/sec
sqlite 🧠 u64 non_indexed 1000 10 31.7±0.40µs 31.8±0.12µs 30.8 Ktx/sec 30.7 Ktx/sec
stdb_module 💿 string indexed 1000 10 25.3±1.95µs 25.5±2.89µs 38.6 Ktx/sec 38.3 Ktx/sec
stdb_module 💿 string non_indexed 1000 10 190.8±0.66µs 182.0±11.44µs 5.1 Ktx/sec 5.4 Ktx/sec
stdb_module 💿 u64 indexed 1000 10 21.0±1.35µs 20.5±0.94µs 46.4 Ktx/sec 47.6 Ktx/sec
stdb_module 💿 u64 non_indexed 1000 10 142.0±0.72µs 152.5±25.98µs 6.9 Ktx/sec 6.4 Ktx/sec
stdb_module 🧠 string indexed 1000 10 24.8±1.71µs 24.5±2.92µs 39.4 Ktx/sec 39.9 Ktx/sec
stdb_module 🧠 string non_indexed 1000 10 185.9±1.31µs 180.1±4.52µs 5.3 Ktx/sec 5.4 Ktx/sec
stdb_module 🧠 u64 indexed 1000 10 21.2±1.51µs 20.7±1.06µs 46.0 Ktx/sec 47.1 Ktx/sec
stdb_module 🧠 u64 non_indexed 1000 10 144.0±7.68µs 141.7±5.32µs 6.8 Ktx/sec 6.9 Ktx/sec
stdb_raw 💿 string indexed 1000 10 2.2±0.00µs 2.2±0.00µs 448.2 Ktx/sec 445.1 Ktx/sec
stdb_raw 💿 string non_indexed 1000 10 175.8±0.25µs 163.5±0.55µs 5.6 Ktx/sec 6.0 Ktx/sec
stdb_raw 💿 u64 indexed 1000 10 1874.2±3.43ns 1741.0±2.07ns 521.1 Ktx/sec 560.9 Ktx/sec
stdb_raw 💿 u64 non_indexed 1000 10 135.3±0.28µs 131.4±0.17µs 7.2 Ktx/sec 7.4 Ktx/sec
stdb_raw 🧠 string indexed 1000 10 2.2±0.02µs 2.2±0.02µs 450.8 Ktx/sec 445.6 Ktx/sec
stdb_raw 🧠 string non_indexed 1000 10 175.6±0.40µs 161.2±1.51µs 5.6 Ktx/sec 6.1 Ktx/sec
stdb_raw 🧠 u64 indexed 1000 10 1884.2±3.44ns 1745.6±17.85ns 518.3 Ktx/sec 559.4 Ktx/sec
stdb_raw 🧠 u64 non_indexed 1000 10 137.3±0.51µs 131.9±0.37µs 7.1 Ktx/sec 7.4 Ktx/sec

Serialize

schema format count new latency old latency new throughput old throughput
location bsatn 100 1719.1±30.57ns 1738.0±51.73ns 55.5 Mtx/sec 54.9 Mtx/sec
location json 100 3.5±0.14µs 3.2±0.01µs 27.0 Mtx/sec 30.0 Mtx/sec
location product_value 100 2.4±0.01µs 2.4±0.01µs 40.1 Mtx/sec 40.1 Mtx/sec
person bsatn 100 2.6±0.05µs 2.4±0.02µs 37.2 Mtx/sec 39.0 Mtx/sec
person json 100 4.9±0.08µs 5.1±0.06µs 19.4 Mtx/sec 18.5 Mtx/sec
person product_value 100 1634.1±12.19ns 1611.5±5.06ns 58.4 Mtx/sec 59.2 Mtx/sec

Module: invoke with large arguments

arg size new latency old latency new throughput old throughput
64KiB 82.5±10.64µs 79.1±6.11µs - -

Module: print bulk

line count new latency old latency new throughput old throughput
1 19.7±0.88µs 20.3±1.02µs - -
100 199.4±4.35µs 199.4±1.19µs - -
1000 1850.3±69.17µs 1842.6±133.80µs - -

Remaining benchmarks

name new latency old latency new throughput old throughput

Please sign in to comment.