Skip to content

Commit

Permalink
Created a route to check what emails are already connected to an iden…
Browse files Browse the repository at this point in the history
…tity (#477)

* Created a route to check what emails are already connected to an identity

* Delete .vscode/settings.json

Signed-off-by: Nathaniel Richards <46858886+NateTheDev1@users.noreply.github.com>

* Fixing errors

* Fixed trivial errors

---------

Signed-off-by: Nathaniel Richards <46858886+NateTheDev1@users.noreply.github.com>
  • Loading branch information
NateTheDev1 authored Nov 8, 2023
1 parent 5998a69 commit 4cc6bb0
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 1 deletion.
7 changes: 7 additions & 0 deletions crates/client-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ pub trait ControlStateReadAccess {

// Identities
fn get_identities_for_email(&self, email: &str) -> spacetimedb::control_db::Result<Vec<IdentityEmail>>;
fn get_emails_for_identity(&self, identity: &Identity) -> spacetimedb::control_db::Result<Vec<IdentityEmail>>;
fn get_recovery_codes(&self, email: &str) -> spacetimedb::control_db::Result<Vec<RecoveryCode>>;

// Energy
Expand Down Expand Up @@ -213,6 +214,9 @@ impl<T: ControlStateReadAccess + ?Sized> ControlStateReadAccess for ArcEnv<T> {
fn get_identities_for_email(&self, email: &str) -> spacetimedb::control_db::Result<Vec<IdentityEmail>> {
self.0.get_identities_for_email(email)
}
fn get_emails_for_identity(&self, identity: &Identity) -> spacetimedb::control_db::Result<Vec<IdentityEmail>> {
self.0.get_emails_for_identity(identity)
}
fn get_recovery_codes(&self, email: &str) -> spacetimedb::control_db::Result<Vec<RecoveryCode>> {
self.0.get_recovery_codes(email)
}
Expand Down Expand Up @@ -366,6 +370,9 @@ impl<T: ControlStateReadAccess + ?Sized> ControlStateReadAccess for Arc<T> {
fn get_identities_for_email(&self, email: &str) -> spacetimedb::control_db::Result<Vec<IdentityEmail>> {
(**self).get_identities_for_email(email)
}
fn get_emails_for_identity(&self, identity: &Identity) -> spacetimedb::control_db::Result<Vec<IdentityEmail>> {
(**self).get_emails_for_identity(identity)
}
fn get_recovery_codes(&self, email: &str) -> spacetimedb::control_db::Result<Vec<RecoveryCode>> {
(**self).get_recovery_codes(email)
}
Expand Down
26 changes: 25 additions & 1 deletion crates/client-api/src/routes/identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ use http::StatusCode;
use serde::{Deserialize, Serialize};

use spacetimedb::auth::identity::encode_token_with_expiry;
use spacetimedb::messages::control_db::IdentityEmail;
use spacetimedb_lib::de::serde::DeserializeWrapper;
use spacetimedb_lib::{Address, Identity};

use crate::auth::{SpacetimeAuth, SpacetimeAuthHeader};
use crate::{log_and_500, ControlStateDelegate, ControlStateWriteAccess, NodeDelegate};
use crate::{log_and_500, ControlStateDelegate, ControlStateReadAccess, ControlStateWriteAccess, NodeDelegate};

#[derive(Deserialize)]
pub struct CreateIdentityQueryParams {
Expand Down Expand Up @@ -130,6 +131,28 @@ pub async fn set_email<S: ControlStateWriteAccess>(
Ok(())
}

pub async fn check_email<S: ControlStateReadAccess>(
State(ctx): State<S>,
Path(SetEmailParams { identity }): Path<SetEmailParams>,
auth: SpacetimeAuthHeader,
) -> axum::response::Result<impl IntoResponse> {
let identity = identity.into();
let auth = auth.get().ok_or(StatusCode::BAD_REQUEST)?;

if auth.identity != identity {
return Err(StatusCode::UNAUTHORIZED.into());
}

let emails = ctx
.get_emails_for_identity(&identity)
.map_err(log_and_500)?
.into_iter()
.map(|IdentityEmail { email, .. }| email)
.collect::<Vec<_>>();

Ok(axum::Json(emails))
}

#[derive(Deserialize)]
pub struct GetDatabasesParams {
identity: IdentityForUrl,
Expand Down Expand Up @@ -216,5 +239,6 @@ where
.route("/websocket_token", post(create_websocket_token::<S>))
.route("/:identity/verify", get(validate_token))
.route("/:identity/set-email", post(set_email::<S>))
.route("/:identity/emails", get(check_email::<S>))
.route("/:identity/databases", get(get_databases::<S>))
}
13 changes: 13 additions & 0 deletions crates/core/src/control_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,19 @@ impl ControlDb {
Ok(result)
}

pub fn get_emails_for_identity(&self, identity: &Identity) -> Result<Vec<IdentityEmail>> {
let mut result = Vec::<IdentityEmail>::new();
let tree = self.db.open_tree("email")?;
for i in tree.iter() {
let (_, value) = i?;
let iemail: IdentityEmail = bsatn::from_slice(&value)?;
if &iemail.identity == identity {
result.push(iemail);
}
}
Ok(result)
}

pub fn get_databases(&self) -> Result<Vec<Database>> {
let tree = self.db.open_tree("database")?;
let mut databases = Vec::new();
Expand Down
4 changes: 4 additions & 0 deletions crates/standalone/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@ impl spacetimedb_client_api::ControlStateReadAccess for StandaloneEnv {
self.control_db.get_identities_for_email(email)
}

fn get_emails_for_identity(&self, identity: &Identity) -> spacetimedb::control_db::Result<Vec<IdentityEmail>> {
self.control_db.get_emails_for_identity(identity)
}

fn get_recovery_codes(&self, email: &str) -> spacetimedb::control_db::Result<Vec<RecoveryCode>> {
self.control_db.spacetime_get_recovery_codes(email)
}
Expand Down

1 comment on commit 4cc6bb0

@github-actions
Copy link

@github-actions github-actions bot commented on 4cc6bb0 Nov 8, 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 💿 432.5±4.45ns 431.5±1.20ns - -
sqlite 🧠 424.2±1.69ns 424.1±1.92ns - -
stdb_module 💿 18.3±1.37µs 17.6±0.85µs - -
stdb_module 🧠 17.4±0.86µs 18.2±1.32µs - -
stdb_raw 💿 713.8±1.24ns 709.7±1.34ns - -
stdb_raw 🧠 706.4±1.74ns 709.2±0.70ns - -

Single-row insertions

db on disk schema index type load new latency old latency new throughput old throughput
sqlite 💿 location multi_index 0 14.8±0.61µs 15.0±1.72µs 65.9 Ktx/sec 65.1 Ktx/sec
sqlite 💿 location multi_index 1000 15.9±0.13µs 15.7±0.13µs 61.5 Ktx/sec 62.3 Ktx/sec
sqlite 💿 location non_unique 0 7.1±0.32µs 7.3±0.54µs 136.8 Ktx/sec 133.0 Ktx/sec
sqlite 💿 location non_unique 1000 7.0±0.05µs 7.1±0.04µs 139.2 Ktx/sec 137.5 Ktx/sec
sqlite 💿 location unique 0 7.1±0.03µs 7.3±0.04µs 137.6 Ktx/sec 134.3 Ktx/sec
sqlite 💿 location unique 1000 7.1±0.06µs 7.2±0.04µs 137.9 Ktx/sec 135.7 Ktx/sec
sqlite 💿 person multi_index 0 14.3±0.03µs 14.7±0.77µs 68.2 Ktx/sec 66.6 Ktx/sec
sqlite 💿 person multi_index 1000 16.1±0.13µs 16.5±4.50µs 60.5 Ktx/sec 59.1 Ktx/sec
sqlite 💿 person non_unique 0 7.2±0.04µs 7.3±0.04µs 135.8 Ktx/sec 133.1 Ktx/sec
sqlite 💿 person non_unique 1000 7.2±0.06µs 7.3±0.03µs 135.3 Ktx/sec 134.2 Ktx/sec
sqlite 💿 person unique 0 7.3±0.03µs 7.5±0.93µs 134.4 Ktx/sec 130.8 Ktx/sec
sqlite 💿 person unique 1000 7.3±0.05µs 7.3±0.04µs 133.3 Ktx/sec 133.6 Ktx/sec
sqlite 🧠 location multi_index 0 4.1±0.01µs 4.0±0.02µs 240.2 Ktx/sec 243.1 Ktx/sec
sqlite 🧠 location multi_index 1000 5.3±0.04µs 5.2±0.05µs 185.0 Ktx/sec 188.5 Ktx/sec
sqlite 🧠 location non_unique 0 1888.8±10.73ns 1850.3±6.61ns 517.0 Ktx/sec 527.8 Ktx/sec
sqlite 🧠 location non_unique 1000 1932.8±11.76ns 1916.1±12.84ns 505.2 Ktx/sec 509.7 Ktx/sec
sqlite 🧠 location unique 0 1869.0±4.85ns 1854.0±4.23ns 522.5 Ktx/sec 526.7 Ktx/sec
sqlite 🧠 location unique 1000 2.0±0.01µs 1965.9±13.33ns 486.4 Ktx/sec 496.7 Ktx/sec
sqlite 🧠 person multi_index 0 3.7±0.01µs 3.7±0.01µs 263.8 Ktx/sec 267.0 Ktx/sec
sqlite 🧠 person multi_index 1000 5.5±0.02µs 5.5±0.05µs 177.8 Ktx/sec 178.9 Ktx/sec
sqlite 🧠 person non_unique 0 1959.3±5.96ns 1899.6±13.64ns 498.4 Ktx/sec 514.1 Ktx/sec
sqlite 🧠 person non_unique 1000 2.0±0.01µs 1983.9±11.87ns 484.7 Ktx/sec 492.3 Ktx/sec
sqlite 🧠 person unique 0 1952.4±18.62ns 1911.9±20.02ns 500.2 Ktx/sec 510.8 Ktx/sec
sqlite 🧠 person unique 1000 2.1±0.02µs 2.0±0.02µs 470.5 Ktx/sec 482.5 Ktx/sec
stdb_module 💿 location multi_index 0 55.1±5.19µs 59.1±6.37µs 17.7 Ktx/sec 16.5 Ktx/sec
stdb_module 💿 location multi_index 1000 109.6±82.09µs 309.3±10.61µs 8.9 Ktx/sec 3.2 Ktx/sec
stdb_module 💿 location non_unique 0 47.8±4.56µs 43.0±6.42µs 20.4 Ktx/sec 22.7 Ktx/sec
stdb_module 💿 location non_unique 1000 70.7±20.90µs 99.7±131.08µs 13.8 Ktx/sec 9.8 Ktx/sec
stdb_module 💿 location unique 0 53.2±4.60µs 53.8±5.67µs 18.4 Ktx/sec 18.1 Ktx/sec
stdb_module 💿 location unique 1000 103.0±62.82µs 148.3±4.91µs 9.5 Ktx/sec 6.6 Ktx/sec
stdb_module 💿 person multi_index 0 65.8±5.72µs 67.9±3.49µs 14.8 Ktx/sec 14.4 Ktx/sec
stdb_module 💿 person multi_index 1000 148.8±8.76µs 290.1±130.03µs 6.6 Ktx/sec 3.4 Ktx/sec
stdb_module 💿 person non_unique 0 50.4±4.96µs 46.5±6.19µs 19.4 Ktx/sec 21.0 Ktx/sec
stdb_module 💿 person non_unique 1000 192.4±35.71µs 292.0±6.31µs 5.1 Ktx/sec 3.3 Ktx/sec
stdb_module 💿 person unique 0 57.7±5.70µs 55.1±4.87µs 16.9 Ktx/sec 17.7 Ktx/sec
stdb_module 💿 person unique 1000 123.7±33.90µs 134.2±15.88µs 7.9 Ktx/sec 7.3 Ktx/sec
stdb_module 🧠 location multi_index 0 37.3±2.89µs 37.8±3.04µs 26.2 Ktx/sec 25.8 Ktx/sec
stdb_module 🧠 location multi_index 1000 147.5±20.23µs 92.8±2.12µs 6.6 Ktx/sec 10.5 Ktx/sec
stdb_module 🧠 location non_unique 0 32.3±3.00µs 32.7±2.89µs 30.3 Ktx/sec 29.8 Ktx/sec
stdb_module 🧠 location non_unique 1000 234.5±7.72µs 103.4±3.31µs 4.2 Ktx/sec 9.4 Ktx/sec
stdb_module 🧠 location unique 0 37.0±4.31µs 36.0±3.29µs 26.4 Ktx/sec 27.1 Ktx/sec
stdb_module 🧠 location unique 1000 221.1±12.90µs 111.2±2.76µs 4.4 Ktx/sec 8.8 Ktx/sec
stdb_module 🧠 person multi_index 0 46.1±5.37µs 45.9±4.44µs 21.2 Ktx/sec 21.3 Ktx/sec
stdb_module 🧠 person multi_index 1000 287.8±13.76µs 282.7±6.37µs 3.4 Ktx/sec 3.5 Ktx/sec
stdb_module 🧠 person non_unique 0 34.0±4.06µs 32.1±3.17µs 28.7 Ktx/sec 30.4 Ktx/sec
stdb_module 🧠 person non_unique 1000 312.6±4.47µs 294.2±4.60µs 3.1 Ktx/sec 3.3 Ktx/sec
stdb_module 🧠 person unique 0 40.3±4.43µs 39.0±3.59µs 24.2 Ktx/sec 25.0 Ktx/sec
stdb_module 🧠 person unique 1000 216.3±7.97µs 111.4±10.62µs 4.5 Ktx/sec 8.8 Ktx/sec
stdb_raw 💿 location multi_index 0 7.3±0.04µs 7.2±0.03µs 134.4 Ktx/sec 135.9 Ktx/sec
stdb_raw 💿 location multi_index 1000 9.9±0.16µs 9.8±0.17µs 98.8 Ktx/sec 99.4 Ktx/sec
stdb_raw 💿 location non_unique 0 4.8±0.01µs 4.8±0.01µs 203.7 Ktx/sec 201.7 Ktx/sec
stdb_raw 💿 location non_unique 1000 14.6±83.73µs 16.9±106.26µs 67.0 Ktx/sec 57.8 Ktx/sec
stdb_raw 💿 location unique 0 6.1±0.01µs 6.2±0.07µs 159.2 Ktx/sec 158.5 Ktx/sec
stdb_raw 💿 location unique 1000 22.6±142.09µs 8.4±0.24µs 43.2 Ktx/sec 116.2 Ktx/sec
stdb_raw 💿 person multi_index 0 11.0±0.02µs 10.9±0.01µs 88.8 Ktx/sec 90.0 Ktx/sec
stdb_raw 💿 person multi_index 1000 42.5±283.72µs 14.0±0.16µs 23.0 Ktx/sec 69.7 Ktx/sec
stdb_raw 💿 person non_unique 0 5.4±0.01µs 5.5±0.65µs 181.6 Ktx/sec 179.0 Ktx/sec
stdb_raw 💿 person non_unique 1000 17.9±109.13µs 7.0±0.08µs 54.6 Ktx/sec 140.5 Ktx/sec
stdb_raw 💿 person unique 0 7.8±0.02µs 7.7±0.02µs 124.8 Ktx/sec 127.3 Ktx/sec
stdb_raw 💿 person unique 1000 10.3±0.13µs 10.1±0.13µs 94.9 Ktx/sec 96.2 Ktx/sec
stdb_raw 🧠 location multi_index 0 4.2±0.05µs 4.2±0.01µs 232.1 Ktx/sec 234.6 Ktx/sec
stdb_raw 🧠 location multi_index 1000 5.9±0.03µs 5.8±0.07µs 165.5 Ktx/sec 168.0 Ktx/sec
stdb_raw 🧠 location non_unique 0 1921.8±4.50ns 1926.0±4.42ns 508.2 Ktx/sec 507.0 Ktx/sec
stdb_raw 🧠 location non_unique 1000 2.4±0.02µs 2.5±0.02µs 400.3 Ktx/sec 394.0 Ktx/sec
stdb_raw 🧠 location unique 0 3.2±0.01µs 3.2±0.00µs 305.7 Ktx/sec 308.2 Ktx/sec
stdb_raw 🧠 location unique 1000 4.4±0.03µs 4.2±0.03µs 223.9 Ktx/sec 230.1 Ktx/sec
stdb_raw 🧠 person multi_index 0 7.9±0.04µs 7.8±0.02µs 123.3 Ktx/sec 125.2 Ktx/sec
stdb_raw 🧠 person multi_index 1000 10.0±0.08µs 9.9±0.05µs 97.7 Ktx/sec 98.3 Ktx/sec
stdb_raw 🧠 person non_unique 0 2.5±0.01µs 2.5±0.01µs 394.9 Ktx/sec 393.5 Ktx/sec
stdb_raw 🧠 person non_unique 1000 3.2±0.04µs 3.2±0.02µs 302.5 Ktx/sec 305.9 Ktx/sec
stdb_raw 🧠 person unique 0 4.8±0.01µs 4.7±0.03µs 205.1 Ktx/sec 208.6 Ktx/sec
stdb_raw 🧠 person unique 1000 6.3±0.04µs 6.1±0.17µs 155.6 Ktx/sec 159.3 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.9±3.74µs 131.6±3.99µs 7.4 Ktx/sec 7.4 Ktx/sec
sqlite 💿 location multi_index 1000 100 204.1±1.48µs 201.2±1.56µs 4.8 Ktx/sec 4.9 Ktx/sec
sqlite 💿 location non_unique 0 100 50.6±1.90µs 51.6±1.35µs 19.3 Ktx/sec 18.9 Ktx/sec
sqlite 💿 location non_unique 1000 100 53.9±0.31µs 54.6±0.29µs 18.1 Ktx/sec 17.9 Ktx/sec
sqlite 💿 location unique 0 100 52.9±1.64µs 53.1±1.59µs 18.4 Ktx/sec 18.4 Ktx/sec
sqlite 💿 location unique 1000 100 58.6±0.37µs 58.4±10.89µs 16.7 Ktx/sec 16.7 Ktx/sec
sqlite 💿 person multi_index 0 100 119.5±4.14µs 118.0±2.95µs 8.2 Ktx/sec 8.3 Ktx/sec
sqlite 💿 person multi_index 1000 100 234.5±0.47µs 232.6±16.84µs 4.2 Ktx/sec 4.2 Ktx/sec
sqlite 💿 person non_unique 0 100 48.8±2.09µs 48.1±0.44µs 20.0 Ktx/sec 20.3 Ktx/sec
sqlite 💿 person non_unique 1000 100 60.6±0.31µs 59.7±0.51µs 16.1 Ktx/sec 16.4 Ktx/sec
sqlite 💿 person unique 0 100 50.0±0.84µs 50.3±2.14µs 19.5 Ktx/sec 19.4 Ktx/sec
sqlite 💿 person unique 1000 100 57.0±7.62µs 54.7±0.26µs 17.1 Ktx/sec 17.8 Ktx/sec
sqlite 🧠 location multi_index 0 100 120.9±0.21µs 119.2±0.70µs 8.1 Ktx/sec 8.2 Ktx/sec
sqlite 🧠 location multi_index 1000 100 174.5±0.47µs 169.3±0.42µs 5.6 Ktx/sec 5.8 Ktx/sec
sqlite 🧠 location non_unique 0 100 44.0±0.36µs 44.6±0.42µs 22.2 Ktx/sec 21.9 Ktx/sec
sqlite 🧠 location non_unique 1000 100 44.9±0.37µs 45.0±0.35µs 21.7 Ktx/sec 21.7 Ktx/sec
sqlite 🧠 location unique 0 100 45.7±0.35µs 46.4±0.41µs 21.4 Ktx/sec 21.0 Ktx/sec
sqlite 🧠 location unique 1000 100 49.9±0.55µs 48.9±0.32µs 19.6 Ktx/sec 20.0 Ktx/sec
sqlite 🧠 person multi_index 0 100 107.9±0.26µs 106.0±0.40µs 9.0 Ktx/sec 9.2 Ktx/sec
sqlite 🧠 person multi_index 1000 100 191.0±0.31µs 187.5±0.34µs 5.1 Ktx/sec 5.2 Ktx/sec
sqlite 🧠 person non_unique 0 100 42.7±0.43µs 41.9±0.40µs 22.9 Ktx/sec 23.3 Ktx/sec
sqlite 🧠 person non_unique 1000 100 46.4±0.40µs 44.9±0.57µs 21.0 Ktx/sec 21.8 Ktx/sec
sqlite 🧠 person unique 0 100 44.5±0.42µs 43.1±0.39µs 22.0 Ktx/sec 22.7 Ktx/sec
sqlite 🧠 person unique 1000 100 48.0±0.29µs 46.5±0.38µs 20.4 Ktx/sec 21.0 Ktx/sec
stdb_module 💿 location multi_index 0 100 621.9±18.86µs 999.0±84.66µs 1607 tx/sec 1000 tx/sec
stdb_module 💿 location multi_index 1000 100 767.9±100.24µs 712.9±10.33µs 1302 tx/sec 1402 tx/sec
stdb_module 💿 location non_unique 0 100 402.8±133.41µs 460.6±72.47µs 2.4 Ktx/sec 2.1 Ktx/sec
stdb_module 💿 location non_unique 1000 100 640.5±32.21µs 658.8±28.57µs 1561 tx/sec 1517 tx/sec
stdb_module 💿 location unique 0 100 633.0±98.70µs 567.1±63.05µs 1579 tx/sec 1763 tx/sec
stdb_module 💿 location unique 1000 100 889.3±146.35µs 593.7±13.24µs 1124 tx/sec 1684 tx/sec
stdb_module 💿 person multi_index 0 100 959.8±13.63µs 999.7±7.30µs 1041 tx/sec 1000 tx/sec
stdb_module 💿 person multi_index 1000 100 1032.1±3.06µs 1164.2±77.08µs 968 tx/sec 858 tx/sec
stdb_module 💿 person non_unique 0 100 497.1±83.62µs 524.1±126.55µs 2011 tx/sec 1908 tx/sec
stdb_module 💿 person non_unique 1000 100 757.7±70.23µs 1042.3±44.31µs 1319 tx/sec 959 tx/sec
stdb_module 💿 person unique 0 100 789.3±108.66µs 716.4±11.77µs 1266 tx/sec 1395 tx/sec
stdb_module 💿 person unique 1000 100 838.1±82.55µs 937.9±33.46µs 1193 tx/sec 1066 tx/sec
stdb_module 🧠 location multi_index 0 100 641.3±117.97µs 716.5±2.03µs 1559 tx/sec 1395 tx/sec
stdb_module 🧠 location multi_index 1000 100 695.2±68.50µs 709.2±68.63µs 1438 tx/sec 1409 tx/sec
stdb_module 🧠 location non_unique 0 100 379.0±20.42µs 364.8±29.89µs 2.6 Ktx/sec 2.7 Ktx/sec
stdb_module 🧠 location non_unique 1000 100 396.1±6.62µs 369.6±4.33µs 2.5 Ktx/sec 2.6 Ktx/sec
stdb_module 🧠 location unique 0 100 477.0±72.55µs 356.9±33.81µs 2.0 Ktx/sec 2.7 Ktx/sec
stdb_module 🧠 location unique 1000 100 436.7±7.45µs 379.8±2.31µs 2.2 Ktx/sec 2.6 Ktx/sec
stdb_module 🧠 person multi_index 0 100 876.9±1.82µs 965.6±6.22µs 1140 tx/sec 1035 tx/sec
stdb_module 🧠 person multi_index 1000 100 1004.9±49.72µs 1094.0±6.42µs 995 tx/sec 914 tx/sec
stdb_module 🧠 person non_unique 0 100 368.5±2.14µs 495.4±41.27µs 2.7 Ktx/sec 2018 tx/sec
stdb_module 🧠 person non_unique 1000 100 581.6±9.97µs 764.7±17.38µs 1719 tx/sec 1307 tx/sec
stdb_module 🧠 person unique 0 100 638.6±10.80µs 651.1±79.81µs 1565 tx/sec 1535 tx/sec
stdb_module 🧠 person unique 1000 100 822.1±18.52µs 821.0±25.49µs 1216 tx/sec 1217 tx/sec
stdb_raw 💿 location multi_index 0 100 403.7±1.26µs 397.4±1.06µs 2.4 Ktx/sec 2.5 Ktx/sec
stdb_raw 💿 location multi_index 1000 100 454.7±262.37µs 448.5±262.51µs 2.1 Ktx/sec 2.2 Ktx/sec
stdb_raw 💿 location non_unique 0 100 171.1±0.31µs 169.6±0.17µs 5.7 Ktx/sec 5.8 Ktx/sec
stdb_raw 💿 location non_unique 1000 100 185.5±116.97µs 183.8±118.10µs 5.3 Ktx/sec 5.3 Ktx/sec
stdb_raw 💿 location unique 0 100 296.2±7.57µs 292.5±0.44µs 3.3 Ktx/sec 3.3 Ktx/sec
stdb_raw 💿 location unique 1000 100 334.0±192.46µs 329.6±191.24µs 2.9 Ktx/sec 3.0 Ktx/sec
stdb_raw 💿 person multi_index 0 100 724.2±0.73µs 721.8±10.66µs 1380 tx/sec 1385 tx/sec
stdb_raw 💿 person multi_index 1000 100 751.4±1.41µs 780.1±324.77µs 1330 tx/sec 1281 tx/sec
stdb_raw 💿 person non_unique 0 100 228.0±0.87µs 228.9±17.54µs 4.3 Ktx/sec 4.3 Ktx/sec
stdb_raw 💿 person non_unique 1000 100 244.8±139.77µs 241.4±119.78µs 4.0 Ktx/sec 4.0 Ktx/sec
stdb_raw 💿 person unique 0 100 438.3±4.94µs 435.3±0.72µs 2.2 Ktx/sec 2.2 Ktx/sec
stdb_raw 💿 person unique 1000 100 478.4±212.98µs 476.6±238.99µs 2.0 Ktx/sec 2.0 Ktx/sec
stdb_raw 🧠 location multi_index 0 100 307.8±0.64µs 297.0±2.62µs 3.2 Ktx/sec 3.3 Ktx/sec
stdb_raw 🧠 location multi_index 1000 100 331.1±0.41µs 321.2±0.43µs 2.9 Ktx/sec 3.0 Ktx/sec
stdb_raw 🧠 location non_unique 0 100 75.6±0.13µs 74.2±0.19µs 12.9 Ktx/sec 13.2 Ktx/sec
stdb_raw 🧠 location non_unique 1000 100 76.8±0.25µs 75.4±0.16µs 12.7 Ktx/sec 12.9 Ktx/sec
stdb_raw 🧠 location unique 0 100 199.1±0.42µs 196.2±0.23µs 4.9 Ktx/sec 5.0 Ktx/sec
stdb_raw 🧠 location unique 1000 100 219.7±0.49µs 216.5±1.17µs 4.4 Ktx/sec 4.5 Ktx/sec
stdb_raw 🧠 person multi_index 0 100 621.1±4.94µs 620.7±3.58µs 1610 tx/sec 1611 tx/sec
stdb_raw 🧠 person multi_index 1000 100 651.5±1.29µs 649.6±3.98µs 1534 tx/sec 1539 tx/sec
stdb_raw 🧠 person non_unique 0 100 127.1±0.11µs 126.2±0.17µs 7.7 Ktx/sec 7.7 Ktx/sec
stdb_raw 🧠 person non_unique 1000 100 129.6±0.29µs 128.4±0.42µs 7.5 Ktx/sec 7.6 Ktx/sec
stdb_raw 🧠 person unique 0 100 336.0±0.57µs 333.3±0.50µs 2.9 Ktx/sec 2.9 Ktx/sec
stdb_raw 🧠 person unique 1000 100 355.8±0.65µs 350.4±0.52µs 2.7 Ktx/sec 2.8 Ktx/sec

Full table iterate

db on disk schema index type new latency old latency new throughput old throughput
sqlite 💿 location unique 8.7±0.12µs 9.1±0.09µs 112.0 Ktx/sec 107.7 Ktx/sec
sqlite 💿 person unique 9.3±0.09µs 9.6±0.11µs 104.9 Ktx/sec 102.2 Ktx/sec
sqlite 🧠 location unique 7.5±0.11µs 7.8±0.10µs 130.8 Ktx/sec 125.7 Ktx/sec
sqlite 🧠 person unique 8.2±0.10µs 8.4±0.06µs 119.5 Ktx/sec 116.6 Ktx/sec
stdb_module 💿 location unique 48.0±6.27µs 50.2±5.82µs 20.4 Ktx/sec 19.4 Ktx/sec
stdb_module 💿 person unique 66.1±7.51µs 54.4±10.57µs 14.8 Ktx/sec 18.0 Ktx/sec
stdb_module 🧠 location unique 49.7±6.16µs 50.4±7.88µs 19.6 Ktx/sec 19.4 Ktx/sec
stdb_module 🧠 person unique 51.5±10.26µs 62.7±10.94µs 19.0 Ktx/sec 15.6 Ktx/sec
stdb_raw 💿 location unique 9.0±0.02µs 9.1±0.00µs 108.6 Ktx/sec 107.8 Ktx/sec
stdb_raw 💿 person unique 9.0±0.00µs 9.1±0.01µs 108.6 Ktx/sec 107.9 Ktx/sec
stdb_raw 🧠 location unique 9.0±0.01µs 9.0±0.00µs 108.7 Ktx/sec 107.9 Ktx/sec
stdb_raw 🧠 person unique 9.0±0.00µs 9.0±0.00µs 108.7 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.01µs 2.3±0.01µs 412.1 Ktx/sec 416.1 Ktx/sec
sqlite 🧠 u32 1000 1110.9±13.75ns 1130.3±10.32ns 879.0 Ktx/sec 864.0 Ktx/sec
stdb_module 💿 u32 1000 24.9±1.75µs 24.8±2.22µs 39.3 Ktx/sec 39.4 Ktx/sec
stdb_module 🧠 u32 1000 23.8±1.40µs 24.5±1.49µs 41.1 Ktx/sec 39.8 Ktx/sec
stdb_raw 💿 u32 1000 1887.8±2.22ns 1880.2±3.83ns 517.3 Ktx/sec 519.4 Ktx/sec
stdb_raw 🧠 u32 1000 1882.2±3.55ns 1870.2±2.09ns 518.8 Ktx/sec 522.2 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.7±0.01µs 5.6±0.02µs 170.7 Ktx/sec 174.0 Ktx/sec
sqlite 💿 string non_indexed 1000 10 49.5±0.90µs 49.5±0.15µs 19.7 Ktx/sec 19.7 Ktx/sec
sqlite 💿 u64 indexed 1000 10 5.5±0.05µs 5.4±0.01µs 176.5 Ktx/sec 180.0 Ktx/sec
sqlite 💿 u64 non_indexed 1000 10 32.9±0.10µs 33.2±0.31µs 29.7 Ktx/sec 29.4 Ktx/sec
sqlite 🧠 string indexed 1000 10 4.2±0.01µs 4.3±0.02µs 230.9 Ktx/sec 229.3 Ktx/sec
sqlite 🧠 string non_indexed 1000 10 47.7±0.83µs 48.8±0.34µs 20.5 Ktx/sec 20.0 Ktx/sec
sqlite 🧠 u64 indexed 1000 10 4.1±0.04µs 4.1±0.02µs 236.7 Ktx/sec 240.8 Ktx/sec
sqlite 🧠 u64 non_indexed 1000 10 31.5±0.08µs 31.7±0.14µs 31.0 Ktx/sec 30.8 Ktx/sec
stdb_module 💿 string indexed 1000 10 36.3±3.20µs 35.6±2.77µs 26.9 Ktx/sec 27.4 Ktx/sec
stdb_module 💿 string non_indexed 1000 10 165.5±0.85µs 179.7±0.46µs 5.9 Ktx/sec 5.4 Ktx/sec
stdb_module 💿 u64 indexed 1000 10 33.0±2.59µs 33.9±2.14µs 29.6 Ktx/sec 28.8 Ktx/sec
stdb_module 💿 u64 non_indexed 1000 10 141.9±1.40µs 146.4±14.05µs 6.9 Ktx/sec 6.7 Ktx/sec
stdb_module 🧠 string indexed 1000 10 36.3±2.99µs 36.4±3.08µs 26.9 Ktx/sec 26.8 Ktx/sec
stdb_module 🧠 string non_indexed 1000 10 168.8±1.85µs 163.3±0.88µs 5.8 Ktx/sec 6.0 Ktx/sec
stdb_module 🧠 u64 indexed 1000 10 33.3±2.81µs 32.8±2.82µs 29.3 Ktx/sec 29.8 Ktx/sec
stdb_module 🧠 u64 non_indexed 1000 10 139.0±10.90µs 141.1±10.56µs 7.0 Ktx/sec 6.9 Ktx/sec
stdb_raw 💿 string indexed 1000 10 4.3±0.01µs 4.5±0.02µs 227.1 Ktx/sec 219.2 Ktx/sec
stdb_raw 💿 string non_indexed 1000 10 142.1±1.85µs 141.5±0.22µs 6.9 Ktx/sec 6.9 Ktx/sec
stdb_raw 💿 u64 indexed 1000 10 4.3±0.01µs 4.3±0.02µs 227.8 Ktx/sec 224.6 Ktx/sec
stdb_raw 💿 u64 non_indexed 1000 10 114.6±0.10µs 122.3±0.15µs 8.5 Ktx/sec 8.0 Ktx/sec
stdb_raw 🧠 string indexed 1000 10 4.3±0.01µs 4.4±0.01µs 227.3 Ktx/sec 219.7 Ktx/sec
stdb_raw 🧠 string non_indexed 1000 10 140.1±0.25µs 138.9±0.38µs 7.0 Ktx/sec 7.0 Ktx/sec
stdb_raw 🧠 u64 indexed 1000 10 4.3±0.01µs 4.3±0.01µs 227.8 Ktx/sec 225.1 Ktx/sec
stdb_raw 🧠 u64 non_indexed 1000 10 114.5±0.11µs 121.3±0.16µs 8.5 Ktx/sec 8.1 Ktx/sec

Serialize

schema format count new latency old latency new throughput old throughput
location bsatn 100 1673.9±30.81ns 1811.2±31.84ns 57.0 Mtx/sec 52.7 Mtx/sec
location json 100 3.4±0.05µs 3.2±0.04µs 27.8 Mtx/sec 29.5 Mtx/sec
location product_value 100 578.9±0.41ns 552.6±0.39ns 164.7 Mtx/sec 172.6 Mtx/sec
person bsatn 100 3.0±0.01µs 2.5±0.01µs 31.3 Mtx/sec 38.3 Mtx/sec
person json 100 5.0±0.03µs 5.1±0.02µs 18.9 Mtx/sec 18.9 Mtx/sec
person product_value 100 1004.8±2.53ns 1006.6±1.16ns 94.9 Mtx/sec 94.7 Mtx/sec

Module: invoke with large arguments

arg size new latency old latency new throughput old throughput
64KiB 81.6±1.52µs 80.2±6.27µs - -

Module: print bulk

line count new latency old latency new throughput old throughput
1 25.0±1.34µs 24.4±2.17µs - -
100 204.2±11.93µs 204.5±5.01µs - -
1000 1923.9±335.32µs 2.0±1.04ms - -

Remaining benchmarks

name new latency old latency new throughput old throughput

Please sign in to comment.