Skip to content

Commit

Permalink
Prometheus stuff (#301)
Browse files Browse the repository at this point in the history
  • Loading branch information
coolreader18 authored Oct 17, 2023
1 parent b9bfe2c commit ac24ff0
Show file tree
Hide file tree
Showing 20 changed files with 364 additions and 483 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ log = "0.4.17"
nonempty = "0.8.1"
once_cell = "1.16"
parking_lot = { version = "0.12.1", features = ["send_guard", "arc_lock"] }
paste = "1.0"
pin-project-lite = "0.2.9"
postgres-types = "0.2.5"
proc-macro2 = "1.0"
Expand Down
1 change: 1 addition & 0 deletions crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ nonempty.workspace = true
once_cell.workspace = true
openssl.workspace = true
parking_lot.workspace = true
paste.workspace = true
pin-project-lite.workspace = true
prometheus.workspace = true
prost.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/auth/identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub fn encode_token_with_expiry(
});

let claims = SpacetimeIdentityClaims {
hex_identity: identity.to_hex(),
hex_identity: identity.to_hex().to_string(),
iat: SystemTime::now(),
exp: expiry,
};
Expand Down
19 changes: 8 additions & 11 deletions crates/core/src/client/client_connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ use std::ops::Deref;

use crate::host::{ModuleHost, NoSuchModule, ReducerArgs, ReducerCallError, ReducerCallResult};
use crate::protobuf::client_api::Subscribe;
use crate::worker_metrics::{CONNECTED_CLIENTS, WEBSOCKET_SENT, WEBSOCKET_SENT_MSG_SIZE};
use crate::util::prometheus_handle::IntGaugeExt;
use crate::worker_metrics::WORKER_METRICS;
use derive_more::From;
use futures::prelude::*;
use tokio::sync::mpsc;
Expand Down Expand Up @@ -42,12 +43,11 @@ impl ClientConnectionSender {

self.sendtx.send(message).await.map_err(|_| ClientClosed)?;

WEBSOCKET_SENT
.with_label_values(&[self.id.identity.to_hex().as_str()])
.inc();
WORKER_METRICS.websocket_sent.with_label_values(&self.id.identity).inc();

WEBSOCKET_SENT_MSG_SIZE
.with_label_values(&[self.id.identity.to_hex().as_str()])
WORKER_METRICS
.websocket_sent_msg_size
.with_label_values(&self.id.identity)
.observe(bytes_len as f64);

Ok(())
Expand Down Expand Up @@ -121,11 +121,8 @@ impl ClientConnection {
};

let actor_fut = actor(this.clone(), sendrx);
tokio::spawn(async move {
CONNECTED_CLIENTS.inc();
actor_fut.await;
CONNECTED_CLIENTS.dec();
});
let gauge_guard = WORKER_METRICS.connected_clients.inc_scope();
tokio::spawn(actor_fut.map(|()| drop(gauge_guard)));

Ok(this)
}
Expand Down
12 changes: 7 additions & 5 deletions crates/core/src/client/message_handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::host::module_host::{EventStatus, ModuleEvent, ModuleFunctionCall};
use crate::host::{EnergyDiff, ReducerArgs, Timestamp};
use crate::identity::Identity;
use crate::protobuf::client_api::{message, FunctionCall, Message, Subscribe};
use crate::worker_metrics::{WEBSOCKET_REQUESTS, WEBSOCKET_REQUEST_MSG_SIZE};
use crate::worker_metrics::WORKER_METRICS;
use base64::Engine;
use bytes::Bytes;
use bytestring::ByteString;
Expand Down Expand Up @@ -35,12 +35,14 @@ pub async fn handle(client: &ClientConnection, message: DataMessage) -> Result<(
DataMessage::Binary(_) => "binary",
};

WEBSOCKET_REQUEST_MSG_SIZE
.with_label_values(&[format!("{}", client.database_instance_id).as_str(), message_kind])
WORKER_METRICS
.websocket_request_msg_size
.with_label_values(&client.database_instance_id, message_kind)
.observe(message.len() as f64);

WEBSOCKET_REQUESTS
.with_label_values(&[format!("{}", client.database_instance_id).as_str(), message_kind])
WORKER_METRICS
.websocket_requests
.with_label_values(&client.database_instance_id, message_kind)
.inc();

match message {
Expand Down
4 changes: 2 additions & 2 deletions crates/core/src/database_instance_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub struct DatabaseInstanceContext {
impl DatabaseInstanceContext {
pub fn from_database(config: Config, database: &Database, instance_id: u64, root_db_path: PathBuf) -> Arc<Self> {
let mut db_path = root_db_path;
db_path.extend([database.address.to_hex(), instance_id.to_string()]);
db_path.extend([&*database.address.to_hex(), &*instance_id.to_string()]);
db_path.push("database");

let log_path = DatabaseLogger::filepath(&database.address, instance_id);
Expand All @@ -44,7 +44,7 @@ impl DatabaseInstanceContext {

pub fn scheduler_db_path(&self, root_db_path: PathBuf) -> PathBuf {
let mut scheduler_db_path = root_db_path;
scheduler_db_path.extend([self.address.to_hex(), self.database_instance_id.to_string()]);
scheduler_db_path.extend([&*self.address.to_hex(), &*self.database_instance_id.to_string()]);
scheduler_db_path.push("scheduler");
scheduler_db_path
}
Expand Down
2 changes: 1 addition & 1 deletion crates/core/src/database_logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ impl DatabaseLogger {

pub fn filepath(address: &Address, instance_id: u64) -> PathBuf {
let root = crate::stdb_path("worker_node/database_instances");
root.join(address.to_hex())
root.join(&*address.to_hex())
.join(instance_id.to_string())
.join("module_logs")
}
Expand Down
158 changes: 47 additions & 111 deletions crates/core/src/db/db_metrics/mod.rs
Original file line number Diff line number Diff line change
@@ -1,119 +1,55 @@
use crate::util::typed_prometheus::metrics_group;
use once_cell::sync::Lazy;
use prometheus::{Histogram, HistogramOpts, HistogramVec, Registry};
use prometheus::{Histogram, HistogramVec};

#[non_exhaustive]
pub struct DbMetrics {
pub registry: Registry,
pub tdb_insert_time: Histogram,
pub tdb_delete_time: Histogram,
pub tdb_seek_time: Histogram,
pub tdb_scan_time: Histogram,
pub tdb_commit_time: Histogram,
pub rdb_create_table_time: HistogramVec,
pub rdb_drop_table_time: HistogramVec,
pub rdb_iter_time: HistogramVec,
pub rdb_insert_row_time: HistogramVec,
pub rdb_delete_by_rel_time: HistogramVec,
}
metrics_group!(
#[non_exhaustive]
pub struct DbMetrics {
#[name = spacetime_tdb_insert_time]
#[help = "Time time it takes for the transactional store to perform an insert"]
pub tdb_insert_time: Histogram,

pub static DB_METRICS: Lazy<DbMetrics> = Lazy::new(DbMetrics::new);
#[name = spacetime_tdb_delete_time]
#[help = "Time time it takes for the transactional store to perform a delete"]
pub tdb_delete_time: Histogram,

impl DbMetrics {
fn new() -> Self {
DbMetrics {
registry: Registry::new(),
tdb_insert_time: Histogram::with_opts(HistogramOpts::new(
"spacetime_tdb_insert_time",
"Time time it takes for the transactional store to perform an insert",
))
.unwrap(),
tdb_delete_time: Histogram::with_opts(HistogramOpts::new(
"spacetime_tdb_delete_time",
"Time time it takes for the transactional store to perform a delete",
))
.unwrap(),
tdb_seek_time: Histogram::with_opts(HistogramOpts::new(
"spacetime_tdb_seek_time",
"Time time it takes for the transactional store to perform a seek",
))
.unwrap(),
tdb_scan_time: Histogram::with_opts(HistogramOpts::new(
"spacetime_tdb_scan_time",
"Time time it takes for the transactional store to perform a scan",
))
.unwrap(),
tdb_commit_time: Histogram::with_opts(HistogramOpts::new(
"spacetime_tdb_commit_time",
"Time time it takes for the transactional store to perform a Tx commit",
))
.unwrap(),
rdb_create_table_time: HistogramVec::new(
HistogramOpts::new("spacetime_rdb_create_table_time", "The time it takes to create a table"),
&["table_name"],
)
.unwrap(),
rdb_drop_table_time: HistogramVec::new(
HistogramOpts::new("spacetime_rdb_drop_table_time", "The time spent dropping a table"),
&["table_id"],
)
.unwrap(),
rdb_iter_time: HistogramVec::new(
HistogramOpts::new("spacetime_rdb_iter_time", "The time spent iterating a table"),
&["table_id"],
)
.unwrap(),
rdb_insert_row_time: HistogramVec::new(
HistogramOpts::new("spacetime_rdb_insert_row_time", "The time spent inserting into a table"),
&["table_id"],
)
.unwrap(),
rdb_delete_by_rel_time: HistogramVec::new(
HistogramOpts::new(
"spacetime_rdb_delete_in_time",
"The time spent deleting values in a set from a table",
),
&["table_id"],
)
.unwrap(),
}
}
#[name = spacetime_tdb_seek_time]
#[help = "Time time it takes for the transactional store to perform a seek"]
pub tdb_seek_time: Histogram,

pub fn register_custom_metrics(&self) {
self.registry.register(Box::new(self.tdb_insert_time.clone())).unwrap();
self.registry.register(Box::new(self.tdb_delete_time.clone())).unwrap();
self.registry.register(Box::new(self.tdb_seek_time.clone())).unwrap();
self.registry.register(Box::new(self.tdb_scan_time.clone())).unwrap();
self.registry.register(Box::new(self.tdb_commit_time.clone())).unwrap();
#[name = spacetime_tdb_scan_time]
#[help = "Time time it takes for the transactional store to perform a scan"]
pub tdb_scan_time: Histogram,

self.registry
.register(Box::new(self.rdb_create_table_time.clone()))
.unwrap();
self.registry
.register(Box::new(self.rdb_drop_table_time.clone()))
.unwrap();
self.registry.register(Box::new(self.rdb_iter_time.clone())).unwrap();
self.registry
.register(Box::new(self.rdb_insert_row_time.clone()))
.unwrap();
self.registry
.register(Box::new(self.rdb_delete_by_rel_time.clone()))
.unwrap();
}
}
#[name = spacetime_tdb_commit_time]
#[help = "Time time it takes for the transactional store to perform a Tx commit"]
pub tdb_commit_time: Histogram,

#[name = spacetime_rdb_create_table_time]
#[help = "The time it takes to create a table"]
#[labels(table_name: str)]
pub rdb_create_table_time: HistogramVec,

#[name = spacetime_rdb_drop_table_time]
#[help = "The time spent dropping a table"]
#[labels(table_id: u32)]
pub rdb_drop_table_time: HistogramVec,

use DB_METRICS as METRICS;
metrics_delegator!(REGISTRY, registry: Registry);
metrics_delegator!(TDB_INSERT_TIME, tdb_insert_time: Histogram);
metrics_delegator!(TDB_DELETE_TIME, tdb_delete_time: Histogram);
metrics_delegator!(TDB_SEEK_TIME, tdb_seek_time: Histogram);
metrics_delegator!(TDB_SCAN_TIME, tdb_scan_time: Histogram);
metrics_delegator!(TDB_COMMIT_TIME, tdb_commit_time: Histogram);
metrics_delegator!(RDB_CREATE_TABLE_TIME, rdb_create_table_time: HistogramVec);
metrics_delegator!(RDB_DROP_TABLE_TIME, rdb_drop_table_time: HistogramVec);
metrics_delegator!(RDB_ITER_TIME, rdb_iter_time: HistogramVec);
metrics_delegator!(RDB_INSERT_TIME, rdb_insert_row_time: HistogramVec);
metrics_delegator!(RDB_DELETE_BY_REL_TIME, rdb_delete_by_rel_time: HistogramVec);
#[name = spacetime_rdb_iter_time]
#[help = "The time spent iterating a table"]
#[labels(table_id: u32)]
pub rdb_iter_time: HistogramVec,

pub fn register_custom_metrics() {
DB_METRICS.register_custom_metrics()
}
#[name = spacetime_rdb_insert_row_time]
#[help = "The time spent inserting into a table"]
#[labels(table_id: u32)]
pub rdb_insert_row_time: HistogramVec,

#[name = spacetime_rdb_delete_in_time]
#[help = "The time spent deleting values in a set from a table"]
#[labels(table_id: u32)]
pub rdb_delete_by_rel_time: HistogramVec,
}
);

pub static DB_METRICS: Lazy<DbMetrics> = Lazy::new(DbMetrics::new);
26 changes: 14 additions & 12 deletions crates/core/src/db/relational_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@ use super::ostorage::memory_object_db::MemoryObjectDB;
use super::relational_operators::Relation;
use crate::address::Address;
use crate::db::commit_log;
use crate::db::db_metrics::{RDB_DELETE_BY_REL_TIME, RDB_DROP_TABLE_TIME, RDB_INSERT_TIME, RDB_ITER_TIME};
use crate::db::db_metrics::DB_METRICS;
use crate::db::messages::commit::Commit;
use crate::db::ostorage::hashmap_object_db::HashMapObjectDB;
use crate::db::ostorage::ObjectDB;
use crate::error::{DBError, DatabaseError, IndexError, TableError};
use crate::hash::Hash;
use crate::util::prometheus_handle::HistogramVecHandle;
use fs2::FileExt;
use nonempty::NonEmpty;
use prometheus::HistogramVec;
use spacetimedb_lib::ColumnIndexAttribute;
use spacetimedb_lib::{data_key::ToDataKey, PrimaryKey};
use spacetimedb_sats::{AlgebraicType, AlgebraicValue, ProductType, ProductValue};
Expand All @@ -30,11 +28,6 @@ use std::sync::{Arc, Mutex};

use super::datastore::locking_tx_datastore::Locking;

/// Starts histogram prometheus measurements for `table_id`.
fn measure(hist: &'static HistogramVec, table_id: u32) {
HistogramVecHandle::new(hist, vec![format!("{}", table_id)]).start();
}

pub const ST_TABLES_NAME: &str = "st_table";
pub const ST_COLUMNS_NAME: &str = "st_columns";
pub const ST_SEQUENCES_NAME: &str = "st_sequence";
Expand Down Expand Up @@ -394,7 +387,10 @@ impl RelationalDB {
}

pub fn drop_table(&self, tx: &mut MutTxId, table_id: u32) -> Result<(), DBError> {
measure(&RDB_DROP_TABLE_TIME, table_id);
let _guard = DB_METRICS
.rdb_drop_table_time
.with_label_values(&table_id)
.start_timer();
self.inner.drop_table_mut_tx(tx, TableId(table_id))
}

Expand Down Expand Up @@ -484,7 +480,7 @@ impl RelationalDB {
/// yielding every row in the table identified by `table_id`.
#[tracing::instrument(skip(self, tx))]
pub fn iter<'a>(&'a self, tx: &'a MutTxId, table_id: u32) -> Result<Iter<'a>, DBError> {
measure(&RDB_ITER_TIME, table_id);
let _guard = DB_METRICS.rdb_iter_time.with_label_values(&table_id).start_timer();
self.inner.iter_mut_tx(tx, TableId(table_id))
}

Expand Down Expand Up @@ -521,7 +517,10 @@ impl RelationalDB {

#[tracing::instrument(skip(self, tx, row))]
pub fn insert(&self, tx: &mut MutTxId, table_id: u32, row: ProductValue) -> Result<ProductValue, DBError> {
measure(&RDB_INSERT_TIME, table_id);
let _guard = DB_METRICS
.rdb_insert_row_time
.with_label_values(&table_id)
.start_timer();
self.inner.insert_mut_tx(tx, TableId(table_id), row)
}

Expand Down Expand Up @@ -552,7 +551,10 @@ impl RelationalDB {
table_id: u32,
relation: R,
) -> Result<Option<u32>, DBError> {
measure(&RDB_DELETE_BY_REL_TIME, table_id);
let _guard = DB_METRICS
.rdb_delete_by_rel_time
.with_label_values(&table_id)
.start_timer();
self.inner.delete_by_rel_mut_tx(tx, TableId(table_id), relation)
}

Expand Down
6 changes: 5 additions & 1 deletion crates/core/src/host/module_host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use crate::protobuf::client_api::{table_row_operation, SubscriptionUpdate, Table
use crate::subscription::module_subscription_actor::ModuleSubscriptionManager;
use crate::util::lending_pool::{Closed, LendingPool, LentResource, PoolClosed};
use crate::util::notify_once::NotifyOnce;
use crate::worker_metrics::WORKER_METRICS;
use base64::{engine::general_purpose::STANDARD as BASE_64_STD, Engine as _};
use futures::{Future, FutureExt};
use indexmap::IndexMap;
Expand Down Expand Up @@ -461,7 +462,10 @@ pub enum InitDatabaseError {
impl ModuleHost {
pub fn new(threadpool: Arc<HostThreadpool>, mut module: impl Module) -> Self {
let info = module.info();
let instance_pool = LendingPool::new();
let waiter_gauge = WORKER_METRICS
.instance_queue_length
.with_label_values(&info.identity, &info.module_hash);
let instance_pool = LendingPool::new(waiter_gauge);
instance_pool.add_multiple(module.initial_instances()).unwrap();
let inner = Arc::new(HostControllerActor {
module: Arc::new(module),
Expand Down
Loading

1 comment on commit ac24ff0

@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 💿 461.6±2.49ns 457.9±1.13ns - -
sqlite 🧠 445.5±2.05ns 460.3±1.85ns - -
stdb_module 💿 15.5±0.36µs 15.6±0.54µs - -
stdb_module 🧠 16.2±0.67µs 16.0±0.45µs - -
stdb_raw 💿 103.4±0.04ns 105.1±0.04ns - -
stdb_raw 🧠 103.1±0.15ns 100.6±0.22ns - -

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.03µs 15.0±2.08µs 66.7 Ktx/sec 65.0 Ktx/sec
sqlite 💿 location multi_index 1000 15.9±0.13µs 15.9±0.10µs 61.2 Ktx/sec 61.3 Ktx/sec
sqlite 💿 location non_unique 0 7.4±0.85µs 7.3±0.03µs 132.1 Ktx/sec 134.1 Ktx/sec
sqlite 💿 location non_unique 1000 7.0±0.03µs 7.1±0.04µs 139.2 Ktx/sec 136.8 Ktx/sec
sqlite 💿 location unique 0 7.4±0.85µs 7.3±0.72µs 131.7 Ktx/sec 133.7 Ktx/sec
sqlite 💿 location unique 1000 7.1±0.04µs 7.2±0.05µs 136.9 Ktx/sec 135.8 Ktx/sec
sqlite 💿 person multi_index 0 14.4±0.05µs 14.4±0.04µs 67.7 Ktx/sec 67.7 Ktx/sec
sqlite 💿 person multi_index 1000 16.3±0.21µs 16.3±0.13µs 59.9 Ktx/sec 59.8 Ktx/sec
sqlite 💿 person non_unique 0 7.5±1.16µs 7.3±0.45µs 130.0 Ktx/sec 133.0 Ktx/sec
sqlite 💿 person non_unique 1000 7.4±0.04µs 7.4±0.06µs 132.3 Ktx/sec 132.0 Ktx/sec
sqlite 💿 person unique 0 7.5±0.96µs 7.3±0.04µs 130.4 Ktx/sec 134.0 Ktx/sec
sqlite 💿 person unique 1000 7.4±0.05µs 7.4±0.05µs 131.6 Ktx/sec 132.4 Ktx/sec
sqlite 🧠 location multi_index 0 4.1±0.01µs 4.1±0.01µs 239.7 Ktx/sec 239.3 Ktx/sec
sqlite 🧠 location multi_index 1000 5.3±0.03µs 5.3±0.02µs 183.2 Ktx/sec 184.5 Ktx/sec
sqlite 🧠 location non_unique 0 1860.2±6.55ns 1898.7±4.99ns 525.0 Ktx/sec 514.3 Ktx/sec
sqlite 🧠 location non_unique 1000 1903.0±5.32ns 1936.7±15.49ns 513.2 Ktx/sec 504.3 Ktx/sec
sqlite 🧠 location unique 0 1838.2±5.32ns 1872.3±5.76ns 531.3 Ktx/sec 521.6 Ktx/sec
sqlite 🧠 location unique 1000 1953.4±11.32ns 1973.5±8.53ns 499.9 Ktx/sec 494.8 Ktx/sec
sqlite 🧠 person multi_index 0 4.0±0.02µs 3.9±0.01µs 246.8 Ktx/sec 250.9 Ktx/sec
sqlite 🧠 person multi_index 1000 5.6±0.08µs 5.8±0.06µs 174.0 Ktx/sec 168.7 Ktx/sec
sqlite 🧠 person non_unique 0 1931.5±5.52ns 1959.2±6.91ns 505.6 Ktx/sec 498.4 Ktx/sec
sqlite 🧠 person non_unique 1000 2.1±0.01µs 2.1±0.10µs 467.5 Ktx/sec 468.6 Ktx/sec
sqlite 🧠 person unique 0 1916.2±5.10ns 1947.1±8.65ns 509.6 Ktx/sec 501.6 Ktx/sec
sqlite 🧠 person unique 1000 2.1±0.02µs 2.1±0.04µs 463.2 Ktx/sec 457.8 Ktx/sec
stdb_module 💿 location multi_index 0 41.1±3.26µs 38.6±6.19µs 23.7 Ktx/sec 25.3 Ktx/sec
stdb_module 💿 location multi_index 1000 187.4±51.58µs 316.9±155.44µs 5.2 Ktx/sec 3.1 Ktx/sec
stdb_module 💿 location non_unique 0 36.1±4.00µs 34.9±2.79µs 27.1 Ktx/sec 28.0 Ktx/sec
stdb_module 💿 location non_unique 1000 329.0±55.15µs 252.5±19.61µs 3.0 Ktx/sec 3.9 Ktx/sec
stdb_module 💿 location unique 0 35.9±4.36µs 36.9±4.67µs 27.2 Ktx/sec 26.5 Ktx/sec
stdb_module 💿 location unique 1000 436.4±21.69µs 179.6±51.66µs 2.2 Ktx/sec 5.4 Ktx/sec
stdb_module 💿 person multi_index 0 48.7±5.33µs 53.4±5.81µs 20.0 Ktx/sec 18.3 Ktx/sec
stdb_module 💿 person multi_index 1000 569.1±29.73µs 543.5±17.70µs 1757 tx/sec 1839 tx/sec
stdb_module 💿 person non_unique 0 42.0±3.95µs 38.4±4.55µs 23.2 Ktx/sec 25.4 Ktx/sec
stdb_module 💿 person non_unique 1000 377.0±63.06µs 316.3±25.43µs 2.6 Ktx/sec 3.1 Ktx/sec
stdb_module 💿 person unique 0 45.2±5.32µs 46.7±4.34µs 21.6 Ktx/sec 20.9 Ktx/sec
stdb_module 💿 person unique 1000 392.9±60.50µs 498.8±15.08µs 2.5 Ktx/sec 2004 tx/sec
stdb_module 🧠 location multi_index 0 29.2±1.78µs 33.2±3.64µs 33.5 Ktx/sec 29.4 Ktx/sec
stdb_module 🧠 location multi_index 1000 296.3±29.93µs 212.5±9.86µs 3.3 Ktx/sec 4.6 Ktx/sec
stdb_module 🧠 location non_unique 0 25.2±1.55µs 26.8±2.39µs 38.7 Ktx/sec 36.4 Ktx/sec
stdb_module 🧠 location non_unique 1000 208.0±11.35µs 182.0±2.02µs 4.7 Ktx/sec 5.4 Ktx/sec
stdb_module 🧠 location unique 0 28.0±1.92µs 27.8±2.44µs 34.9 Ktx/sec 35.2 Ktx/sec
stdb_module 🧠 location unique 1000 314.8±5.76µs 350.9±6.97µs 3.1 Ktx/sec 2.8 Ktx/sec
stdb_module 🧠 person multi_index 0 39.0±4.51µs 39.7±3.96µs 25.0 Ktx/sec 24.6 Ktx/sec
stdb_module 🧠 person multi_index 1000 400.4±71.85µs 216.4±23.46µs 2.4 Ktx/sec 4.5 Ktx/sec
stdb_module 🧠 person non_unique 0 29.6±2.58µs 27.8±2.26µs 33.0 Ktx/sec 35.1 Ktx/sec
stdb_module 🧠 person non_unique 1000 251.2±28.89µs 257.6±31.94µs 3.9 Ktx/sec 3.8 Ktx/sec
stdb_module 🧠 person unique 0 36.1±3.75µs 33.3±2.72µs 27.1 Ktx/sec 29.3 Ktx/sec
stdb_module 🧠 person unique 1000 436.7±67.04µs 344.8±8.07µs 2.2 Ktx/sec 2.8 Ktx/sec
stdb_raw 💿 location multi_index 0 5.3±0.01µs 5.3±0.01µs 185.4 Ktx/sec 182.8 Ktx/sec
stdb_raw 💿 location multi_index 1000 33.4±0.80µs 34.0±0.65µs 29.2 Ktx/sec 28.7 Ktx/sec
stdb_raw 💿 location non_unique 0 3.5±0.02µs 3.5±0.01µs 279.3 Ktx/sec 276.0 Ktx/sec
stdb_raw 💿 location non_unique 1000 21.6±0.16µs 21.7±0.18µs 45.1 Ktx/sec 44.9 Ktx/sec
stdb_raw 💿 location unique 0 4.3±0.01µs 4.3±0.01µs 225.7 Ktx/sec 225.9 Ktx/sec
stdb_raw 💿 location unique 1000 27.0±0.32µs 26.8±0.18µs 36.1 Ktx/sec 36.5 Ktx/sec
stdb_raw 💿 person multi_index 0 9.0±0.04µs 9.1±0.01µs 108.6 Ktx/sec 107.6 Ktx/sec
stdb_raw 💿 person multi_index 1000 60.4±353.07µs 25.5±1.03µs 16.2 Ktx/sec 38.3 Ktx/sec
stdb_raw 💿 person non_unique 0 4.1±0.01µs 4.2±0.04µs 237.2 Ktx/sec 232.8 Ktx/sec
stdb_raw 💿 person non_unique 1000 29.1±149.69µs 29.4±149.17µs 33.6 Ktx/sec 33.3 Ktx/sec
stdb_raw 💿 person unique 0 5.9±0.02µs 6.0±0.01µs 165.5 Ktx/sec 163.3 Ktx/sec
stdb_raw 💿 person unique 1000 21.8±0.35µs 21.5±0.41µs 44.7 Ktx/sec 45.3 Ktx/sec
stdb_raw 🧠 location multi_index 0 4.3±0.01µs 4.2±0.01µs 229.5 Ktx/sec 229.8 Ktx/sec
stdb_raw 🧠 location multi_index 1000 29.5±0.56µs 28.8±0.72µs 33.1 Ktx/sec 34.0 Ktx/sec
stdb_raw 🧠 location non_unique 0 2.2±0.00µs 2.3±0.01µs 444.9 Ktx/sec 428.3 Ktx/sec
stdb_raw 🧠 location non_unique 1000 19.1±0.07µs 18.7±0.05µs 51.1 Ktx/sec 52.2 Ktx/sec
stdb_raw 🧠 location unique 0 3.0±0.01µs 3.1±0.01µs 327.0 Ktx/sec 313.6 Ktx/sec
stdb_raw 🧠 location unique 1000 24.5±0.27µs 24.6±0.35µs 39.9 Ktx/sec 39.7 Ktx/sec
stdb_raw 🧠 person multi_index 0 7.6±0.20µs 7.7±0.01µs 128.1 Ktx/sec 127.2 Ktx/sec
stdb_raw 🧠 person multi_index 1000 20.7±1.50µs 21.9±1.41µs 47.1 Ktx/sec 44.6 Ktx/sec
stdb_raw 🧠 person non_unique 0 2.8±0.00µs 2.9±0.00µs 348.7 Ktx/sec 335.7 Ktx/sec
stdb_raw 🧠 person non_unique 1000 12.7±0.19µs 13.1±0.18µs 76.9 Ktx/sec 74.7 Ktx/sec
stdb_raw 🧠 person unique 0 4.6±0.01µs 4.6±0.01µs 210.6 Ktx/sec 210.9 Ktx/sec
stdb_raw 🧠 person unique 1000 17.0±0.62µs 17.2±0.56µs 57.4 Ktx/sec 56.9 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.46µs 129.7±0.52µs 7.4 Ktx/sec 7.5 Ktx/sec
sqlite 💿 location multi_index 1000 100 203.7±1.09µs 203.9±1.44µs 4.8 Ktx/sec 4.8 Ktx/sec
sqlite 💿 location non_unique 0 100 50.5±1.29µs 49.9±1.03µs 19.4 Ktx/sec 19.6 Ktx/sec
sqlite 💿 location non_unique 1000 100 52.1±0.20µs 52.4±0.38µs 18.7 Ktx/sec 18.6 Ktx/sec
sqlite 💿 location unique 0 100 52.5±0.24µs 52.3±1.23µs 18.6 Ktx/sec 18.7 Ktx/sec
sqlite 💿 location unique 1000 100 56.8±0.27µs 57.1±0.29µs 17.2 Ktx/sec 17.1 Ktx/sec
sqlite 💿 person multi_index 0 100 118.6±4.51µs 120.7±3.44µs 8.2 Ktx/sec 8.1 Ktx/sec
sqlite 💿 person multi_index 1000 100 236.2±1.77µs 238.6±37.87µs 4.1 Ktx/sec 4.1 Ktx/sec
sqlite 💿 person non_unique 0 100 48.8±1.11µs 50.5±1.20µs 20.0 Ktx/sec 19.4 Ktx/sec
sqlite 💿 person non_unique 1000 100 62.4±10.36µs 61.2±0.29µs 15.7 Ktx/sec 15.9 Ktx/sec
sqlite 💿 person unique 0 100 50.7±1.00µs 52.9±2.81µs 19.3 Ktx/sec 18.5 Ktx/sec
sqlite 💿 person unique 1000 100 56.1±0.31µs 57.9±0.28µs 17.4 Ktx/sec 16.9 Ktx/sec
sqlite 🧠 location multi_index 0 100 120.0±0.69µs 119.2±0.32µs 8.1 Ktx/sec 8.2 Ktx/sec
sqlite 🧠 location multi_index 1000 100 171.1±0.63µs 171.8±0.42µs 5.7 Ktx/sec 5.7 Ktx/sec
sqlite 🧠 location non_unique 0 100 43.2±0.23µs 44.7±0.42µs 22.6 Ktx/sec 21.9 Ktx/sec
sqlite 🧠 location non_unique 1000 100 44.9±0.37µs 45.5±0.44µs 21.7 Ktx/sec 21.5 Ktx/sec
sqlite 🧠 location unique 0 100 45.3±0.30µs 46.0±0.25µs 21.6 Ktx/sec 21.2 Ktx/sec
sqlite 🧠 location unique 1000 100 48.7±0.30µs 48.4±0.31µs 20.0 Ktx/sec 20.2 Ktx/sec
sqlite 🧠 person multi_index 0 100 106.6±0.39µs 109.2±0.49µs 9.2 Ktx/sec 8.9 Ktx/sec
sqlite 🧠 person multi_index 1000 100 190.4±0.36µs 191.8±0.35µs 5.1 Ktx/sec 5.1 Ktx/sec
sqlite 🧠 person non_unique 0 100 42.0±0.25µs 44.3±0.29µs 23.2 Ktx/sec 22.1 Ktx/sec
sqlite 🧠 person non_unique 1000 100 47.3±0.40µs 48.0±0.33µs 20.6 Ktx/sec 20.3 Ktx/sec
sqlite 🧠 person unique 0 100 43.6±0.33µs 46.2±0.52µs 22.4 Ktx/sec 21.2 Ktx/sec
sqlite 🧠 person unique 1000 100 48.3±0.34µs 50.2±0.52µs 20.2 Ktx/sec 19.5 Ktx/sec
stdb_module 💿 location multi_index 0 100 816.6±10.39µs 805.2±179.41µs 1224 tx/sec 1241 tx/sec
stdb_module 💿 location multi_index 1000 100 984.3±43.34µs 900.3±52.17µs 1015 tx/sec 1110 tx/sec
stdb_module 💿 location non_unique 0 100 512.3±7.03µs 531.1±19.87µs 1952 tx/sec 1882 tx/sec
stdb_module 💿 location non_unique 1000 100 687.4±13.89µs 788.1±80.09µs 1454 tx/sec 1268 tx/sec
stdb_module 💿 location unique 0 100 663.1±4.18µs 547.3±52.22µs 1508 tx/sec 1827 tx/sec
stdb_module 💿 location unique 1000 100 852.8±49.90µs 837.3±68.52µs 1172 tx/sec 1194 tx/sec
stdb_module 💿 person multi_index 0 100 1016.5±43.58µs 1482.9±9.38µs 983 tx/sec 674 tx/sec
stdb_module 💿 person multi_index 1000 100 1208.6±9.09µs 1175.7±207.44µs 827 tx/sec 850 tx/sec
stdb_module 💿 person non_unique 0 100 689.8±7.56µs 686.4±3.54µs 1449 tx/sec 1456 tx/sec
stdb_module 💿 person non_unique 1000 100 945.8±144.57µs 1024.0±14.92µs 1057 tx/sec 976 tx/sec
stdb_module 💿 person unique 0 100 966.7±3.83µs 985.7±3.60µs 1034 tx/sec 1014 tx/sec
stdb_module 💿 person unique 1000 100 1231.9±47.03µs 1410.1±112.92µs 811 tx/sec 709 tx/sec
stdb_module 🧠 location multi_index 0 100 715.5±7.92µs 746.8±7.01µs 1397 tx/sec 1339 tx/sec
stdb_module 🧠 location multi_index 1000 100 931.4±4.43µs 990.0±107.93µs 1073 tx/sec 1010 tx/sec
stdb_module 🧠 location non_unique 0 100 388.2±12.88µs 433.8±12.17µs 2.5 Ktx/sec 2.3 Ktx/sec
stdb_module 🧠 location non_unique 1000 100 547.4±9.66µs 588.4±3.38µs 1826 tx/sec 1699 tx/sec
stdb_module 🧠 location unique 0 100 561.8±7.53µs 581.3±1.99µs 1780 tx/sec 1720 tx/sec
stdb_module 🧠 location unique 1000 100 760.6±4.62µs 887.1±23.43µs 1314 tx/sec 1127 tx/sec
stdb_module 🧠 person multi_index 0 100 1343.6±15.49µs 1357.1±38.50µs 744 tx/sec 736 tx/sec
stdb_module 🧠 person multi_index 1000 100 1625.5±111.26µs 1431.0±15.00µs 615 tx/sec 698 tx/sec
stdb_module 🧠 person non_unique 0 100 593.7±1.93µs 553.3±30.50µs 1684 tx/sec 1807 tx/sec
stdb_module 🧠 person non_unique 1000 100 813.9±54.90µs 762.4±8.18µs 1228 tx/sec 1311 tx/sec
stdb_module 🧠 person unique 0 100 895.0±12.14µs 856.7±16.98µs 1117 tx/sec 1167 tx/sec
stdb_module 🧠 person unique 1000 100 1321.0±52.14µs 1106.2±10.17µs 756 tx/sec 904 tx/sec
stdb_raw 💿 location multi_index 0 100 309.6±0.68µs 317.8±16.81µs 3.2 Ktx/sec 3.1 Ktx/sec
stdb_raw 💿 location multi_index 1000 100 361.0±1.36µs 369.4±1.43µs 2.7 Ktx/sec 2.6 Ktx/sec
stdb_raw 💿 location non_unique 0 100 141.9±4.33µs 145.8±0.14µs 6.9 Ktx/sec 6.7 Ktx/sec
stdb_raw 💿 location non_unique 1000 100 174.5±109.58µs 168.8±1.12µs 5.6 Ktx/sec 5.8 Ktx/sec
stdb_raw 💿 location unique 0 100 219.0±13.38µs 226.1±8.12µs 4.5 Ktx/sec 4.3 Ktx/sec
stdb_raw 💿 location unique 1000 100 263.4±1.21µs 271.1±1.46µs 3.7 Ktx/sec 3.6 Ktx/sec
stdb_raw 💿 person multi_index 0 100 651.4±4.41µs 657.1±16.88µs 1535 tx/sec 1521 tx/sec
stdb_raw 💿 person multi_index 1000 100 709.1±140.86µs 709.3±1.28µs 1410 tx/sec 1409 tx/sec
stdb_raw 💿 person non_unique 0 100 196.3±8.89µs 203.7±9.91µs 5.0 Ktx/sec 4.8 Ktx/sec
stdb_raw 💿 person non_unique 1000 100 233.6±160.53µs 240.7±161.86µs 4.2 Ktx/sec 4.1 Ktx/sec
stdb_raw 💿 person unique 0 100 362.2±0.26µs 369.4±1.49µs 2.7 Ktx/sec 2.6 Ktx/sec
stdb_raw 💿 person unique 1000 100 423.3±228.11µs 409.0±0.99µs 2.3 Ktx/sec 2.4 Ktx/sec
stdb_raw 🧠 location multi_index 0 100 314.8±0.38µs 321.1±0.51µs 3.1 Ktx/sec 3.0 Ktx/sec
stdb_raw 🧠 location multi_index 1000 100 359.6±0.79µs 370.0±0.67µs 2.7 Ktx/sec 2.6 Ktx/sec
stdb_raw 🧠 location non_unique 0 100 136.5±0.09µs 141.7±0.88µs 7.2 Ktx/sec 6.9 Ktx/sec
stdb_raw 🧠 location non_unique 1000 100 158.7±0.34µs 164.5±0.96µs 6.2 Ktx/sec 5.9 Ktx/sec
stdb_raw 🧠 location unique 0 100 213.6±0.19µs 221.5±0.88µs 4.6 Ktx/sec 4.4 Ktx/sec
stdb_raw 🧠 location unique 1000 100 261.0±0.48µs 268.1±0.95µs 3.7 Ktx/sec 3.6 Ktx/sec
stdb_raw 🧠 person multi_index 0 100 648.9±1.39µs 657.1±0.47µs 1541 tx/sec 1521 tx/sec
stdb_raw 🧠 person multi_index 1000 100 701.3±3.00µs 721.5±2.13µs 1425 tx/sec 1385 tx/sec
stdb_raw 🧠 person non_unique 0 100 192.3±0.49µs 199.2±0.15µs 5.1 Ktx/sec 4.9 Ktx/sec
stdb_raw 🧠 person non_unique 1000 100 214.2±0.64µs 222.9±0.86µs 4.6 Ktx/sec 4.4 Ktx/sec
stdb_raw 🧠 person unique 0 100 356.1±0.83µs 364.4±0.28µs 2.7 Ktx/sec 2.7 Ktx/sec
stdb_raw 🧠 person unique 1000 100 397.3±0.96µs 406.0±0.92µs 2.5 Ktx/sec 2.4 Ktx/sec

Full table iterate

db on disk schema index type new latency old latency new throughput old throughput
sqlite 💿 location unique 8.5±0.05µs 8.9±0.13µs 114.9 Ktx/sec 109.4 Ktx/sec
sqlite 💿 person unique 8.8±0.06µs 9.4±0.09µs 110.8 Ktx/sec 103.6 Ktx/sec
sqlite 🧠 location unique 7.3±0.05µs 7.8±0.15µs 133.3 Ktx/sec 124.5 Ktx/sec
sqlite 🧠 person unique 7.7±0.20µs 8.0±0.08µs 127.0 Ktx/sec 121.7 Ktx/sec
stdb_module 💿 location unique 45.8±5.84µs 42.6±2.48µs 21.3 Ktx/sec 22.9 Ktx/sec
stdb_module 💿 person unique 53.8±10.74µs 57.1±8.84µs 18.2 Ktx/sec 17.1 Ktx/sec
stdb_module 🧠 location unique 45.4±3.24µs 44.6±3.11µs 21.5 Ktx/sec 21.9 Ktx/sec
stdb_module 🧠 person unique 62.0±8.33µs 57.4±7.24µs 15.8 Ktx/sec 17.0 Ktx/sec
stdb_raw 💿 location unique 10.4±0.02µs 11.3±0.02µs 94.1 Ktx/sec 86.3 Ktx/sec
stdb_raw 💿 person unique 11.5±0.10µs 12.7±0.01µs 85.2 Ktx/sec 76.6 Ktx/sec
stdb_raw 🧠 location unique 10.4±0.07µs 11.3±0.01µs 93.8 Ktx/sec 86.4 Ktx/sec
stdb_raw 🧠 person unique 11.4±0.06µs 12.6±0.15µs 85.6 Ktx/sec 77.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 410.9 Ktx/sec 407.3 Ktx/sec
sqlite 🧠 u32 1000 1157.8±4.26ns 1156.8±6.15ns 843.5 Ktx/sec 844.2 Ktx/sec
stdb_module 💿 u32 1000 19.7±1.62µs 17.6±0.58µs 49.6 Ktx/sec 55.5 Ktx/sec
stdb_module 🧠 u32 1000 18.4±0.52µs 18.1±0.95µs 53.2 Ktx/sec 54.0 Ktx/sec
stdb_raw 💿 u32 1000 484.1±1.64ns 496.5±1.04ns 2017.2 Ktx/sec 1966.8 Ktx/sec
stdb_raw 🧠 u32 1000 481.4±0.62ns 495.9±1.15ns 2028.8 Ktx/sec 1969.5 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.01µs 5.8±0.03µs 175.6 Ktx/sec 168.3 Ktx/sec
sqlite 💿 string non_indexed 1000 10 48.0±0.32µs 48.7±0.30µs 20.4 Ktx/sec 20.1 Ktx/sec
sqlite 💿 u64 indexed 1000 10 5.4±0.02µs 5.6±0.01µs 180.7 Ktx/sec 174.6 Ktx/sec
sqlite 💿 u64 non_indexed 1000 10 33.0±0.31µs 32.9±0.07µs 29.6 Ktx/sec 29.7 Ktx/sec
sqlite 🧠 string indexed 1000 10 4.1±0.01µs 4.3±0.02µs 236.0 Ktx/sec 227.8 Ktx/sec
sqlite 🧠 string non_indexed 1000 10 44.8±0.73µs 47.4±0.44µs 21.8 Ktx/sec 20.6 Ktx/sec
sqlite 🧠 u64 indexed 1000 10 4.0±0.01µs 4.2±0.02µs 245.8 Ktx/sec 234.9 Ktx/sec
sqlite 🧠 u64 non_indexed 1000 10 31.8±0.08µs 31.5±0.10µs 30.8 Ktx/sec 31.0 Ktx/sec
stdb_module 💿 string indexed 1000 10 27.2±2.53µs 24.8±1.98µs 35.9 Ktx/sec 39.4 Ktx/sec
stdb_module 💿 string non_indexed 1000 10 211.3±13.43µs 199.8±1.23µs 4.6 Ktx/sec 4.9 Ktx/sec
stdb_module 💿 u64 indexed 1000 10 22.2±2.25µs 21.0±1.57µs 44.0 Ktx/sec 46.5 Ktx/sec
stdb_module 💿 u64 non_indexed 1000 10 168.3±3.21µs 163.7±4.43µs 5.8 Ktx/sec 6.0 Ktx/sec
stdb_module 🧠 string indexed 1000 10 25.1±1.66µs 26.4±2.41µs 39.0 Ktx/sec 37.0 Ktx/sec
stdb_module 🧠 string non_indexed 1000 10 194.5±0.99µs 194.4±3.65µs 5.0 Ktx/sec 5.0 Ktx/sec
stdb_module 🧠 u64 indexed 1000 10 21.6±1.60µs 21.3±1.21µs 45.1 Ktx/sec 45.9 Ktx/sec
stdb_module 🧠 u64 non_indexed 1000 10 165.2±0.89µs 159.7±3.26µs 5.9 Ktx/sec 6.1 Ktx/sec
stdb_raw 💿 string indexed 1000 10 2.5±0.01µs 2.5±0.00µs 389.8 Ktx/sec 388.6 Ktx/sec
stdb_raw 💿 string non_indexed 1000 10 186.5±0.28µs 174.3±0.60µs 5.2 Ktx/sec 5.6 Ktx/sec
stdb_raw 💿 u64 indexed 1000 10 2.3±0.00µs 2.3±0.00µs 421.5 Ktx/sec 428.4 Ktx/sec
stdb_raw 💿 u64 non_indexed 1000 10 132.2±0.18µs 123.5±0.39µs 7.4 Ktx/sec 7.9 Ktx/sec
stdb_raw 🧠 string indexed 1000 10 2.5±0.00µs 2.5±0.00µs 386.3 Ktx/sec 387.4 Ktx/sec
stdb_raw 🧠 string non_indexed 1000 10 188.2±0.48µs 174.2±0.42µs 5.2 Ktx/sec 5.6 Ktx/sec
stdb_raw 🧠 u64 indexed 1000 10 2.3±0.01µs 2.3±0.00µs 421.2 Ktx/sec 430.6 Ktx/sec
stdb_raw 🧠 u64 non_indexed 1000 10 132.2±0.38µs 123.8±0.18µs 7.4 Ktx/sec 7.9 Ktx/sec

Serialize

schema format count new latency old latency new throughput old throughput
location bsatn 100 1714.9±32.44ns 1850.8±30.99ns 55.6 Mtx/sec 51.5 Mtx/sec
location json 100 3.4±0.04µs 3.5±0.05µs 28.4 Mtx/sec 26.9 Mtx/sec
location product_value 100 2.5±0.01µs 2.5±0.01µs 38.6 Mtx/sec 38.8 Mtx/sec
person bsatn 100 2.4±0.01µs 2.6±0.02µs 40.2 Mtx/sec 36.9 Mtx/sec
person json 100 4.9±0.03µs 5.0±0.03µs 19.3 Mtx/sec 19.0 Mtx/sec
person product_value 100 1648.0±4.76ns 1628.3±11.04ns 57.9 Mtx/sec 58.6 Mtx/sec

Module: invoke with large arguments

arg size new latency old latency new throughput old throughput
64KiB 78.4±9.42µs 77.3±6.99µs - -

Module: print bulk

line count new latency old latency new throughput old throughput
1 19.9±1.14µs 20.4±1.51µs - -
100 199.9±1.51µs 197.1±1.30µs - -
1000 1849.5±60.71µs 1985.1±22.47µs - -

Remaining benchmarks

name new latency old latency new throughput old throughput

Please sign in to comment.