Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch from wasmer to wasmtime #457

Merged
merged 6 commits into from
Nov 17, 2023
Merged

Switch from wasmer to wasmtime #457

merged 6 commits into from
Nov 17, 2023

Conversation

coolreader18
Copy link
Collaborator

@coolreader18 coolreader18 commented Oct 20, 2023

Description of Changes

A draft PR to run benchmarks on wasmtime vs wasmer

API and ABI

  • This is a breaking change to the module ABI
  • This is a breaking change to the module API
  • This is a breaking change to the ClientAPI
  • This is a breaking change to the SDK API

The host_type parameter to /publish is renamed from wasmer to wasmtime, but I don't think that it was even being checked anyway.

@coolreader18
Copy link
Collaborator Author

benchmarks please

crates/sats/src/lib.rs Outdated Show resolved Hide resolved
@Centril
Copy link
Contributor

Centril commented Oct 20, 2023

There seem to be quite a few refactorings that are independent of the move to wasmtime; could these be extracted and reviewed separately? That could also make the benchmark more reliable.

@cloutiertyler
Copy link
Contributor

There seem to be quite a few refactorings that are independent of the move to wasmtime; could these be extracted and reviewed separately? That could also make the benchmark more reliable.

If we do end up merging this (and I will not do so without performance data that demonstrates we understand the impact), then we should break this up and make sure we document it well.

Right now it's just a draft to evaluate performance I believe.

@coolreader18
Copy link
Collaborator Author

@Centril this is like 3 separate PRs that are in one branch b/c they're not merged yet. once #266 and #417 merge this'd just be the last commit

@github-actions
Copy link

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 💿 - 440.6±2.18ns - -
sqlite 🧠 - 433.6±1.07ns - -
stdb_module 💿 15.8±0.47µs 15.8±0.42µs - -
stdb_module 🧠 16.2±0.42µs 16.4±0.58µs - -
stdb_raw 💿 204.1±0.42ns 102.0±0.86ns - -
stdb_raw 🧠 204.1±0.30ns 101.7±0.78ns - -

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.04µs - 66.9 Ktx/sec
sqlite 💿 location multi_index 1000 - 15.9±0.12µs - 61.3 Ktx/sec
sqlite 💿 location non_unique 0 - 7.3±0.05µs - 134.0 Ktx/sec
sqlite 💿 location non_unique 1000 - 7.0±0.03µs - 138.5 Ktx/sec
sqlite 💿 location unique 0 - 7.3±0.27µs - 134.0 Ktx/sec
sqlite 💿 location unique 1000 - 7.1±0.10µs - 136.6 Ktx/sec
sqlite 💿 person multi_index 0 - 14.4±0.06µs - 67.7 Ktx/sec
sqlite 💿 person multi_index 1000 - 16.1±0.19µs - 60.5 Ktx/sec
sqlite 💿 person non_unique 0 - 7.4±0.04µs - 131.4 Ktx/sec
sqlite 💿 person non_unique 1000 - 7.3±0.04µs - 134.5 Ktx/sec
sqlite 💿 person unique 0 - 7.5±0.38µs - 130.6 Ktx/sec
sqlite 💿 person unique 1000 - 7.4±0.04µs - 132.2 Ktx/sec
sqlite 🧠 location multi_index 0 - 4.1±0.01µs - 237.0 Ktx/sec
sqlite 🧠 location multi_index 1000 - 5.3±0.03µs - 185.7 Ktx/sec
sqlite 🧠 location non_unique 0 - 1876.0±6.14ns - 520.6 Ktx/sec
sqlite 🧠 location non_unique 1000 - 1931.3±12.26ns - 505.6 Ktx/sec
sqlite 🧠 location unique 0 - 1850.0±6.98ns - 527.9 Ktx/sec
sqlite 🧠 location unique 1000 - 1958.9±6.41ns - 498.5 Ktx/sec
sqlite 🧠 person multi_index 0 - 3.7±0.01µs - 261.8 Ktx/sec
sqlite 🧠 person multi_index 1000 - 5.5±0.02µs - 178.0 Ktx/sec
sqlite 🧠 person non_unique 0 - 1957.7±6.77ns - 498.8 Ktx/sec
sqlite 🧠 person non_unique 1000 - 2.0±0.02µs - 480.6 Ktx/sec
sqlite 🧠 person unique 0 - 1949.8±6.81ns - 500.8 Ktx/sec
sqlite 🧠 person unique 1000 - 2.1±0.01µs - 473.3 Ktx/sec
stdb_module 💿 location multi_index 0 41.1±3.22µs 36.6±3.35µs 23.8 Ktx/sec 26.7 Ktx/sec
stdb_module 💿 location multi_index 1000 129.4±16.42µs 263.4±2.80µs 7.5 Ktx/sec 3.7 Ktx/sec
stdb_module 💿 location non_unique 0 34.0±3.71µs 32.8±3.10µs 28.7 Ktx/sec 29.8 Ktx/sec
stdb_module 💿 location non_unique 1000 208.5±62.74µs 181.4±77.71µs 4.7 Ktx/sec 5.4 Ktx/sec
stdb_module 💿 location unique 0 40.1±3.98µs 34.7±3.60µs 24.4 Ktx/sec 28.1 Ktx/sec
stdb_module 💿 location unique 1000 109.6±25.00µs 122.7±16.93µs 8.9 Ktx/sec 8.0 Ktx/sec
stdb_module 💿 person multi_index 0 53.6±4.89µs 46.9±4.65µs 18.2 Ktx/sec 20.8 Ktx/sec
stdb_module 💿 person multi_index 1000 313.8±15.54µs 283.9±4.67µs 3.1 Ktx/sec 3.4 Ktx/sec
stdb_module 💿 person non_unique 0 36.3±3.23µs 32.4±2.43µs 26.9 Ktx/sec 30.2 Ktx/sec
stdb_module 💿 person non_unique 1000 156.8±21.66µs 172.9±18.03µs 6.2 Ktx/sec 5.6 Ktx/sec
stdb_module 💿 person unique 0 44.6±4.89µs 39.2±3.01µs 21.9 Ktx/sec 24.9 Ktx/sec
stdb_module 💿 person unique 1000 246.5±64.17µs 248.2±4.13µs 4.0 Ktx/sec 3.9 Ktx/sec
stdb_module 🧠 location multi_index 0 31.2±2.38µs 30.9±3.14µs 31.3 Ktx/sec 31.6 Ktx/sec
stdb_module 🧠 location multi_index 1000 193.4±43.81µs 159.8±86.50µs 5.0 Ktx/sec 6.1 Ktx/sec
stdb_module 🧠 location non_unique 0 26.7±1.76µs 26.1±1.61µs 36.6 Ktx/sec 37.4 Ktx/sec
stdb_module 🧠 location non_unique 1000 200.4±43.55µs 204.3±36.40µs 4.9 Ktx/sec 4.8 Ktx/sec
stdb_module 🧠 location unique 0 30.8±2.47µs 31.0±2.70µs 31.7 Ktx/sec 31.5 Ktx/sec
stdb_module 🧠 location unique 1000 237.3±12.47µs 95.2±7.14µs 4.1 Ktx/sec 10.3 Ktx/sec
stdb_module 🧠 person multi_index 0 40.4±3.48µs 32.9±2.43µs 24.2 Ktx/sec 29.7 Ktx/sec
stdb_module 🧠 person multi_index 1000 185.5±133.27µs 265.4±5.62µs 5.3 Ktx/sec 3.7 Ktx/sec
stdb_module 🧠 person non_unique 0 29.4±1.74µs 27.2±1.68µs 33.2 Ktx/sec 36.0 Ktx/sec
stdb_module 🧠 person non_unique 1000 202.5±24.56µs 166.2±19.84µs 4.8 Ktx/sec 5.9 Ktx/sec
stdb_module 🧠 person unique 0 34.3±2.52µs 30.2±1.90µs 28.5 Ktx/sec 32.3 Ktx/sec
stdb_module 🧠 person unique 1000 129.4±33.71µs 101.0±4.48µs 7.5 Ktx/sec 9.7 Ktx/sec
stdb_raw 💿 location multi_index 0 6.3±0.08µs 5.0±0.05µs 155.8 Ktx/sec 196.5 Ktx/sec
stdb_raw 💿 location multi_index 1000 30.1±213.13µs 7.1±0.15µs 32.5 Ktx/sec 136.9 Ktx/sec
stdb_raw 💿 location non_unique 0 3.9±0.00µs 3.4±0.01µs 248.2 Ktx/sec 285.3 Ktx/sec
stdb_raw 💿 location non_unique 1000 5.2±0.13µs 4.6±0.15µs 187.7 Ktx/sec 213.6 Ktx/sec
stdb_raw 💿 location unique 0 5.2±0.02µs 4.2±0.01µs 186.1 Ktx/sec 234.9 Ktx/sec
stdb_raw 💿 location unique 1000 23.2±160.28µs 15.0±88.68µs 42.0 Ktx/sec 65.1 Ktx/sec
stdb_raw 💿 person multi_index 0 9.9±0.03µs 8.5±0.18µs 98.3 Ktx/sec 114.8 Ktx/sec
stdb_raw 💿 person multi_index 1000 48.7±356.11µs 40.0±287.79µs 20.1 Ktx/sec 24.4 Ktx/sec
stdb_raw 💿 person non_unique 0 4.5±0.01µs 4.0±0.01µs 216.6 Ktx/sec 246.5 Ktx/sec
stdb_raw 💿 person non_unique 1000 6.1±0.09µs 17.7±124.03µs 158.8 Ktx/sec 55.0 Ktx/sec
stdb_raw 💿 person unique 0 6.8±0.01µs 5.7±0.17µs 143.4 Ktx/sec 171.9 Ktx/sec
stdb_raw 💿 person unique 1000 9.4±0.17µs 23.0±153.62µs 103.4 Ktx/sec 42.4 Ktx/sec
stdb_raw 🧠 location multi_index 0 4.8±0.01µs 3.6±0.01µs 204.1 Ktx/sec 270.9 Ktx/sec
stdb_raw 🧠 location multi_index 1000 6.4±0.05µs 5.0±0.06µs 152.7 Ktx/sec 193.5 Ktx/sec
stdb_raw 🧠 location non_unique 0 2.5±0.00µs 2.1±0.01µs 387.3 Ktx/sec 457.8 Ktx/sec
stdb_raw 🧠 location non_unique 1000 3.1±0.02µs 2.7±0.02µs 313.2 Ktx/sec 359.7 Ktx/sec
stdb_raw 🧠 location unique 0 3.8±0.04µs 2.8±0.01µs 260.1 Ktx/sec 349.6 Ktx/sec
stdb_raw 🧠 location unique 1000 5.0±0.02µs 4.0±0.03µs 196.5 Ktx/sec 242.8 Ktx/sec
stdb_raw 🧠 person multi_index 0 8.4±0.02µs 6.9±0.01µs 116.1 Ktx/sec 140.5 Ktx/sec
stdb_raw 🧠 person multi_index 1000 10.5±0.12µs 8.9±0.11µs 92.9 Ktx/sec 110.0 Ktx/sec
stdb_raw 🧠 person non_unique 0 3.1±0.00µs 2.6±0.00µs 316.9 Ktx/sec 369.7 Ktx/sec
stdb_raw 🧠 person non_unique 1000 3.8±0.05µs 3.2±0.02µs 257.4 Ktx/sec 301.1 Ktx/sec
stdb_raw 🧠 person unique 0 5.3±0.00µs 4.3±0.01µs 182.7 Ktx/sec 226.3 Ktx/sec
stdb_raw 🧠 person unique 1000 6.7±0.08µs 5.5±0.02µs 145.7 Ktx/sec 177.6 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 - 132.3±0.42µs - 7.4 Ktx/sec
sqlite 💿 location multi_index 1000 100 - 205.9±1.10µs - 4.7 Ktx/sec
sqlite 💿 location non_unique 0 100 - 51.9±1.54µs - 18.8 Ktx/sec
sqlite 💿 location non_unique 1000 100 - 55.1±0.48µs - 17.7 Ktx/sec
sqlite 💿 location unique 0 100 - 53.6±1.15µs - 18.2 Ktx/sec
sqlite 💿 location unique 1000 100 - 58.3±0.22µs - 16.7 Ktx/sec
sqlite 💿 person multi_index 0 100 - 119.6±5.59µs - 8.2 Ktx/sec
sqlite 💿 person multi_index 1000 100 - 230.2±1.28µs - 4.2 Ktx/sec
sqlite 💿 person non_unique 0 100 - 48.7±1.71µs - 20.1 Ktx/sec
sqlite 💿 person non_unique 1000 100 - 61.7±13.63µs - 15.8 Ktx/sec
sqlite 💿 person unique 0 100 - 50.1±1.31µs - 19.5 Ktx/sec
sqlite 💿 person unique 1000 100 - 56.0±0.24µs - 17.4 Ktx/sec
sqlite 🧠 location multi_index 0 100 - 120.7±0.61µs - 8.1 Ktx/sec
sqlite 🧠 location multi_index 1000 100 - 171.7±0.20µs - 5.7 Ktx/sec
sqlite 🧠 location non_unique 0 100 - 44.4±0.25µs - 22.0 Ktx/sec
sqlite 🧠 location non_unique 1000 100 - 47.1±0.51µs - 20.7 Ktx/sec
sqlite 🧠 location unique 0 100 - 46.5±0.40µs - 21.0 Ktx/sec
sqlite 🧠 location unique 1000 100 - 50.1±0.38µs - 19.5 Ktx/sec
sqlite 🧠 person multi_index 0 100 - 108.1±0.33µs - 9.0 Ktx/sec
sqlite 🧠 person multi_index 1000 100 - 191.4±0.46µs - 5.1 Ktx/sec
sqlite 🧠 person non_unique 0 100 - 41.9±0.56µs - 23.3 Ktx/sec
sqlite 🧠 person non_unique 1000 100 - 46.3±0.24µs - 21.1 Ktx/sec
sqlite 🧠 person unique 0 100 - 44.5±0.41µs - 21.9 Ktx/sec
sqlite 🧠 person unique 1000 100 - 47.7±0.29µs - 20.5 Ktx/sec
stdb_module 💿 location multi_index 0 100 668.8±162.94µs 611.0±122.68µs 1495 tx/sec 1636 tx/sec
stdb_module 💿 location multi_index 1000 100 753.0±24.61µs 796.0±3.63µs 1328 tx/sec 1256 tx/sec
stdb_module 💿 location non_unique 0 100 297.4±23.48µs 465.7±14.56µs 3.3 Ktx/sec 2.1 Ktx/sec
stdb_module 💿 location non_unique 1000 100 627.4±109.32µs 530.6±41.11µs 1593 tx/sec 1884 tx/sec
stdb_module 💿 location unique 0 100 426.5±14.35µs 441.0±78.15µs 2.3 Ktx/sec 2.2 Ktx/sec
stdb_module 💿 location unique 1000 100 542.1±69.96µs 740.7±89.76µs 1844 tx/sec 1350 tx/sec
stdb_module 💿 person multi_index 0 100 962.6±100.83µs 847.8±135.15µs 1038 tx/sec 1179 tx/sec
stdb_module 💿 person multi_index 1000 100 1194.2±9.28µs 1113.4±21.95µs 837 tx/sec 898 tx/sec
stdb_module 💿 person non_unique 0 100 374.6±2.75µs 524.4±46.71µs 2.6 Ktx/sec 1907 tx/sec
stdb_module 💿 person non_unique 1000 100 555.6±84.25µs 689.3±4.35µs 1799 tx/sec 1450 tx/sec
stdb_module 💿 person unique 0 100 677.5±1.40µs 610.2±1.78µs 1475 tx/sec 1638 tx/sec
stdb_module 💿 person unique 1000 100 682.6±42.86µs 848.2±4.61µs 1465 tx/sec 1179 tx/sec
stdb_module 🧠 location multi_index 0 100 774.7±121.99µs 390.0±55.04µs 1290 tx/sec 2.5 Ktx/sec
stdb_module 🧠 location multi_index 1000 100 888.0±106.45µs 534.9±34.08µs 1126 tx/sec 1869 tx/sec
stdb_module 🧠 location non_unique 0 100 413.1±32.46µs 288.5±26.90µs 2.4 Ktx/sec 3.4 Ktx/sec
stdb_module 🧠 location non_unique 1000 100 462.3±4.40µs 488.0±64.14µs 2.1 Ktx/sec 2.0 Ktx/sec
stdb_module 🧠 location unique 0 100 489.4±17.52µs 461.7±67.91µs 2043 tx/sec 2.1 Ktx/sec
stdb_module 🧠 location unique 1000 100 434.5±10.57µs 531.0±4.54µs 2.2 Ktx/sec 1883 tx/sec
stdb_module 🧠 person multi_index 0 100 954.8±2.46µs 712.6±10.19µs 1047 tx/sec 1403 tx/sec
stdb_module 🧠 person multi_index 1000 100 933.4±5.29µs 790.6±24.88µs 1071 tx/sec 1264 tx/sec
stdb_module 🧠 person non_unique 0 100 522.5±92.25µs 443.3±50.33µs 1913 tx/sec 2.2 Ktx/sec
stdb_module 🧠 person non_unique 1000 100 623.0±39.67µs 571.5±65.94µs 1605 tx/sec 1749 tx/sec
stdb_module 🧠 person unique 0 100 617.9±37.93µs 569.2±8.54µs 1618 tx/sec 1756 tx/sec
stdb_module 🧠 person unique 1000 100 861.7±14.49µs 755.0±9.36µs 1160 tx/sec 1324 tx/sec
stdb_raw 💿 location multi_index 0 100 368.9±0.56µs 267.2±0.47µs 2.6 Ktx/sec 3.7 Ktx/sec
stdb_raw 💿 location multi_index 1000 100 418.0±232.76µs 309.2±177.93µs 2.3 Ktx/sec 3.2 Ktx/sec
stdb_raw 💿 location non_unique 0 100 140.1±0.11µs 122.5±0.64µs 7.0 Ktx/sec 8.0 Ktx/sec
stdb_raw 💿 location non_unique 1000 100 142.9±0.96µs 127.2±25.28µs 6.8 Ktx/sec 7.7 Ktx/sec
stdb_raw 💿 location unique 0 100 268.2±13.80µs 191.2±0.64µs 3.6 Ktx/sec 5.1 Ktx/sec
stdb_raw 💿 location unique 1000 100 284.3±1.22µs 209.1±1.41µs 3.4 Ktx/sec 4.7 Ktx/sec
stdb_raw 💿 person multi_index 0 100 691.3±0.41µs 568.2±3.42µs 1446 tx/sec 1759 tx/sec
stdb_raw 💿 person multi_index 1000 100 722.0±0.71µs 626.2±295.15µs 1384 tx/sec 1597 tx/sec
stdb_raw 💿 person non_unique 0 100 199.2±0.50µs 176.0±0.37µs 4.9 Ktx/sec 5.5 Ktx/sec
stdb_raw 💿 person non_unique 1000 100 214.7±125.12µs 178.8±0.43µs 4.5 Ktx/sec 5.5 Ktx/sec
stdb_raw 💿 person unique 0 100 411.3±7.48µs 324.0±1.64µs 2.4 Ktx/sec 3.0 Ktx/sec
stdb_raw 💿 person unique 1000 100 449.9±232.25µs 341.4±1.72µs 2.2 Ktx/sec 2.9 Ktx/sec
stdb_raw 🧠 location multi_index 0 100 363.3±0.51µs 262.3±0.52µs 2.7 Ktx/sec 3.7 Ktx/sec
stdb_raw 🧠 location multi_index 1000 100 388.9±0.58µs 286.6±0.38µs 2.5 Ktx/sec 3.4 Ktx/sec
stdb_raw 🧠 location non_unique 0 100 135.9±0.15µs 120.2±1.27µs 7.2 Ktx/sec 8.1 Ktx/sec
stdb_raw 🧠 location non_unique 1000 100 138.4±0.85µs 122.4±0.17µs 7.1 Ktx/sec 8.0 Ktx/sec
stdb_raw 🧠 location unique 0 100 261.3±0.41µs 188.4±0.14µs 3.7 Ktx/sec 5.2 Ktx/sec
stdb_raw 🧠 location unique 1000 100 279.0±1.05µs 205.8±1.62µs 3.5 Ktx/sec 4.7 Ktx/sec
stdb_raw 🧠 person multi_index 0 100 684.6±0.71µs 560.7±3.19µs 1460 tx/sec 1783 tx/sec
stdb_raw 🧠 person multi_index 1000 100 715.6±2.46µs 589.3±1.60µs 1397 tx/sec 1696 tx/sec
stdb_raw 🧠 person non_unique 0 100 193.1±0.44µs 171.8±1.92µs 5.1 Ktx/sec 5.7 Ktx/sec
stdb_raw 🧠 person non_unique 1000 100 196.2±0.31µs 174.2±1.26µs 5.0 Ktx/sec 5.6 Ktx/sec
stdb_raw 🧠 person unique 0 100 403.1±0.64µs 316.5±0.62µs 2.4 Ktx/sec 3.1 Ktx/sec
stdb_raw 🧠 person unique 1000 100 421.1±0.49µs 334.8±0.37µs 2.3 Ktx/sec 2.9 Ktx/sec

Full table iterate

db on disk schema index type new latency old latency new throughput old throughput
sqlite 💿 location unique - 9.0±0.13µs - 108.9 Ktx/sec
sqlite 💿 person unique - 9.6±0.09µs - 101.5 Ktx/sec
sqlite 🧠 location unique - 7.6±0.10µs - 128.3 Ktx/sec
sqlite 🧠 person unique - 8.4±0.09µs - 116.9 Ktx/sec
stdb_module 💿 location unique 43.8±4.59µs 31.5±1.98µs 22.3 Ktx/sec 31.0 Ktx/sec
stdb_module 💿 person unique 57.9±6.08µs 45.4±4.52µs 16.9 Ktx/sec 21.5 Ktx/sec
stdb_module 🧠 location unique 45.6±2.90µs 31.2±2.91µs 21.4 Ktx/sec 31.3 Ktx/sec
stdb_module 🧠 person unique 57.0±6.76µs 47.4±3.15µs 17.1 Ktx/sec 20.6 Ktx/sec
stdb_raw 💿 location unique 8.5±0.34µs 3.4±0.04µs 115.4 Ktx/sec 287.0 Ktx/sec
stdb_raw 💿 person unique 8.3±0.27µs 3.4±0.01µs 118.1 Ktx/sec 287.5 Ktx/sec
stdb_raw 🧠 location unique 8.6±0.32µs 3.4±0.01µs 113.8 Ktx/sec 287.5 Ktx/sec
stdb_raw 🧠 person unique 8.2±0.25µs 3.4±0.05µs 118.4 Ktx/sec 287.8 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 - 412.1 Ktx/sec
sqlite 🧠 u32 1000 - 1133.8±10.54ns - 861.3 Ktx/sec
stdb_module 💿 u32 1000 19.5±1.75µs 17.8±0.39µs 50.0 Ktx/sec 54.8 Ktx/sec
stdb_module 🧠 u32 1000 20.2±1.74µs 17.9±0.31µs 48.3 Ktx/sec 54.6 Ktx/sec
stdb_raw 💿 u32 1000 883.9±1.86ns 366.4±1.42ns 1104.8 Ktx/sec 2.6 Mtx/sec
stdb_raw 🧠 u32 1000 883.5±2.94ns 365.2±0.46ns 1105.4 Ktx/sec 2.6 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.6±0.04µs - 173.6 Ktx/sec
sqlite 💿 string non_indexed 1000 10 - 49.4±0.28µs - 19.8 Ktx/sec
sqlite 💿 u64 indexed 1000 10 - 5.4±0.02µs - 180.7 Ktx/sec
sqlite 💿 u64 non_indexed 1000 10 - 32.8±0.07µs - 29.8 Ktx/sec
sqlite 🧠 string indexed 1000 10 - 4.2±0.05µs - 235.1 Ktx/sec
sqlite 🧠 string non_indexed 1000 10 - 47.8±0.31µs - 20.4 Ktx/sec
sqlite 🧠 u64 indexed 1000 10 - 4.0±0.02µs - 246.1 Ktx/sec
sqlite 🧠 u64 non_indexed 1000 10 - 31.5±0.20µs - 31.0 Ktx/sec
stdb_module 💿 string indexed 1000 10 27.2±2.65µs 22.6±1.65µs 35.9 Ktx/sec 43.2 Ktx/sec
stdb_module 💿 string non_indexed 1000 10 180.1±1.89µs 112.3±8.26µs 5.4 Ktx/sec 8.7 Ktx/sec
stdb_module 💿 u64 indexed 1000 10 23.0±1.23µs 20.5±1.30µs 42.5 Ktx/sec 47.6 Ktx/sec
stdb_module 💿 u64 non_indexed 1000 10 144.7±4.99µs 91.6±16.29µs 6.8 Ktx/sec 10.7 Ktx/sec
stdb_module 🧠 string indexed 1000 10 27.1±2.58µs 22.6±1.66µs 36.0 Ktx/sec 43.3 Ktx/sec
stdb_module 🧠 string non_indexed 1000 10 177.3±1.96µs 121.3±5.25µs 5.5 Ktx/sec 8.1 Ktx/sec
stdb_module 🧠 u64 indexed 1000 10 22.6±1.45µs 20.9±1.59µs 43.2 Ktx/sec 46.8 Ktx/sec
stdb_module 🧠 u64 non_indexed 1000 10 145.0±5.47µs 87.2±6.92µs 6.7 Ktx/sec 11.2 Ktx/sec
stdb_raw 💿 string indexed 1000 10 3.3±0.02µs 1229.9±0.95ns 294.4 Ktx/sec 794.0 Ktx/sec
stdb_raw 💿 string non_indexed 1000 10 134.4±0.52µs 80.6±0.14µs 7.3 Ktx/sec 12.1 Ktx/sec
stdb_raw 💿 u64 indexed 1000 10 3.2±0.02µs 1154.6±1.01ns 308.9 Ktx/sec 845.8 Ktx/sec
stdb_raw 💿 u64 non_indexed 1000 10 115.9±0.40µs 55.2±0.17µs 8.4 Ktx/sec 17.7 Ktx/sec
stdb_raw 🧠 string indexed 1000 10 3.3±0.02µs 1231.0±1.01ns 295.2 Ktx/sec 793.3 Ktx/sec
stdb_raw 🧠 string non_indexed 1000 10 132.9±1.85µs 79.7±0.25µs 7.4 Ktx/sec 12.3 Ktx/sec
stdb_raw 🧠 u64 indexed 1000 10 3.2±0.02µs 1153.4±1.50ns 309.0 Ktx/sec 846.7 Ktx/sec
stdb_raw 🧠 u64 non_indexed 1000 10 114.9±0.38µs 54.7±0.13µs 8.5 Ktx/sec 17.9 Ktx/sec

Serialize

schema format count new latency old latency new throughput old throughput
location bsatn 100 1778.7±32.42ns 1738.5±31.23ns 53.6 Mtx/sec 54.9 Mtx/sec
location json 100 3.1±0.03µs 3.1±0.03µs 30.6 Mtx/sec 30.8 Mtx/sec
location product_value 100 598.0±2.79ns 845.3±0.74ns 159.5 Mtx/sec 112.8 Mtx/sec
person bsatn 100 2.6±0.03µs 2.5±0.01µs 37.0 Mtx/sec 37.9 Mtx/sec
person json 100 4.7±0.04µs 5.0±0.07µs 20.3 Mtx/sec 19.2 Mtx/sec
person product_value 100 1034.1±0.50ns 1120.1±0.59ns 92.2 Mtx/sec 85.1 Mtx/sec

Module: invoke with large arguments

arg size new latency old latency new throughput old throughput
64KiB 70.7±10.05µs 73.5±10.22µs - -

Module: print bulk

line count new latency old latency new throughput old throughput
1 21.2±2.02µs 19.5±1.19µs - -
100 196.5±0.93µs 193.9±1.48µs - -
1000 1767.4±5.83µs 1762.1±54.75µs - -

Remaining benchmarks

name new latency old latency new throughput old throughput

@coolreader18
Copy link
Collaborator Author

hmmm :/ idk what's up with this. how old are the old benchmark numbers?

@RReverser
Copy link
Member

RReverser commented Oct 24, 2023

They should be from master. That said, this PR does quite a lot, including upgrade of a bunch of dependencies and some minor refactorings, so it's hard to attribute the performance difference to just the engine change. It would be better to split them out and keep this change isolated.

@coolreader18
Copy link
Collaborator Author

@RReverser well, approve #266 and we can do that :))

@RReverser
Copy link
Member

@RReverser well, approve #266 and we can do that :))

I started benchmarks on that one for now :) (also I only reread conversation above which had the same points raised already, only after leaving my comment lol)

@github-actions
Copy link

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 💿 - 467.0±4.38ns - -
sqlite 🧠 - 448.5±2.32ns - -
stdb_module 💿 15.3±0.36µs 16.1±0.50µs - -
stdb_module 🧠 15.9±0.52µs 16.4±0.66µs - -
stdb_raw 💿 199.3±2.17ns 189.8±2.81ns - -
stdb_raw 🧠 201.5±1.75ns 190.1±2.84ns - -

Single-row insertions

db on disk schema index type load new latency old latency new throughput old throughput
sqlite 💿 location multi_index 0 - 14.7±0.61µs - 66.4 Ktx/sec
sqlite 💿 location multi_index 1000 - 18.0±21.10µs - 54.4 Ktx/sec
sqlite 💿 location non_unique 0 - 7.3±1.05µs - 133.1 Ktx/sec
sqlite 💿 location non_unique 1000 - 7.0±0.03µs - 138.6 Ktx/sec
sqlite 💿 location unique 0 - 7.2±0.04µs - 136.1 Ktx/sec
sqlite 💿 location unique 1000 - 7.1±0.03µs - 137.6 Ktx/sec
sqlite 💿 person multi_index 0 - 14.3±0.05µs - 68.4 Ktx/sec
sqlite 💿 person multi_index 1000 - 16.2±0.11µs - 60.1 Ktx/sec
sqlite 💿 person non_unique 0 - 7.3±0.04µs - 134.5 Ktx/sec
sqlite 💿 person non_unique 1000 - 7.3±0.03µs - 133.9 Ktx/sec
sqlite 💿 person unique 0 - 7.4±0.80µs - 132.9 Ktx/sec
sqlite 💿 person unique 1000 - 7.3±0.07µs - 133.4 Ktx/sec
sqlite 🧠 location multi_index 0 - 4.0±0.01µs - 243.0 Ktx/sec
sqlite 🧠 location multi_index 1000 - 5.3±0.05µs - 184.2 Ktx/sec
sqlite 🧠 location non_unique 0 - 1862.0±5.56ns - 524.5 Ktx/sec
sqlite 🧠 location non_unique 1000 - 1923.1±10.83ns - 507.8 Ktx/sec
sqlite 🧠 location unique 0 - 1857.2±10.34ns - 525.8 Ktx/sec
sqlite 🧠 location unique 1000 - 1975.6±17.45ns - 494.3 Ktx/sec
sqlite 🧠 person multi_index 0 - 3.7±0.01µs - 265.2 Ktx/sec
sqlite 🧠 person multi_index 1000 - 5.5±0.03µs - 177.8 Ktx/sec
sqlite 🧠 person non_unique 0 - 1920.5±4.10ns - 508.5 Ktx/sec
sqlite 🧠 person non_unique 1000 - 2.0±0.02µs - 480.0 Ktx/sec
sqlite 🧠 person unique 0 - 1904.6±8.19ns - 512.7 Ktx/sec
sqlite 🧠 person unique 1000 - 2.0±0.01µs - 477.4 Ktx/sec
stdb_module 💿 location multi_index 0 41.7±4.74µs 41.3±5.21µs 23.4 Ktx/sec 23.6 Ktx/sec
stdb_module 💿 location multi_index 1000 146.1±31.55µs 126.1±23.85µs 6.7 Ktx/sec 7.7 Ktx/sec
stdb_module 💿 location non_unique 0 35.1±4.23µs 35.5±3.89µs 27.8 Ktx/sec 27.5 Ktx/sec
stdb_module 💿 location non_unique 1000 122.3±21.53µs 293.5±3.53µs 8.0 Ktx/sec 3.3 Ktx/sec
stdb_module 💿 location unique 0 39.0±3.61µs 40.8±3.95µs 25.1 Ktx/sec 24.0 Ktx/sec
stdb_module 💿 location unique 1000 86.8±5.42µs 108.5±6.68µs 11.3 Ktx/sec 9.0 Ktx/sec
stdb_module 💿 person multi_index 0 53.7±4.83µs 50.9±5.40µs 18.2 Ktx/sec 19.2 Ktx/sec
stdb_module 💿 person multi_index 1000 146.7±19.21µs 211.7±104.85µs 6.7 Ktx/sec 4.6 Ktx/sec
stdb_module 💿 person non_unique 0 37.4±3.80µs 35.6±3.57µs 26.1 Ktx/sec 27.4 Ktx/sec
stdb_module 💿 person non_unique 1000 176.8±35.97µs 186.8±10.51µs 5.5 Ktx/sec 5.2 Ktx/sec
stdb_module 💿 person unique 0 44.4±5.83µs 50.6±5.07µs 22.0 Ktx/sec 19.3 Ktx/sec
stdb_module 💿 person unique 1000 170.6±72.67µs 147.6±10.38µs 5.7 Ktx/sec 6.6 Ktx/sec
stdb_module 🧠 location multi_index 0 32.9±2.84µs 32.9±1.87µs 29.7 Ktx/sec 29.7 Ktx/sec
stdb_module 🧠 location multi_index 1000 136.0±8.20µs 250.3±11.24µs 7.2 Ktx/sec 3.9 Ktx/sec
stdb_module 🧠 location non_unique 0 27.0±2.07µs 28.6±2.00µs 36.2 Ktx/sec 34.2 Ktx/sec
stdb_module 🧠 location non_unique 1000 122.7±7.33µs 274.5±4.62µs 8.0 Ktx/sec 3.6 Ktx/sec
stdb_module 🧠 location unique 0 30.7±2.20µs 31.8±2.90µs 31.8 Ktx/sec 30.7 Ktx/sec
stdb_module 🧠 location unique 1000 129.4±21.75µs 230.2±4.07µs 7.5 Ktx/sec 4.2 Ktx/sec
stdb_module 🧠 person multi_index 0 39.9±3.33µs 41.6±4.87µs 24.5 Ktx/sec 23.5 Ktx/sec
stdb_module 🧠 person multi_index 1000 304.1±25.37µs 316.1±3.85µs 3.2 Ktx/sec 3.1 Ktx/sec
stdb_module 🧠 person non_unique 0 27.4±1.66µs 31.0±3.08µs 35.6 Ktx/sec 31.5 Ktx/sec
stdb_module 🧠 person non_unique 1000 202.1±37.75µs 143.7±6.37µs 4.8 Ktx/sec 6.8 Ktx/sec
stdb_module 🧠 person unique 0 33.2±2.08µs 34.2±3.42µs 29.4 Ktx/sec 28.5 Ktx/sec
stdb_module 🧠 person unique 1000 103.3±9.91µs 192.6±5.89µs 9.4 Ktx/sec 5.1 Ktx/sec
stdb_raw 💿 location multi_index 0 6.3±0.02µs 6.3±0.02µs 155.1 Ktx/sec 155.4 Ktx/sec
stdb_raw 💿 location multi_index 1000 30.0±211.55µs 8.7±0.17µs 32.6 Ktx/sec 112.0 Ktx/sec
stdb_raw 💿 location non_unique 0 3.9±0.01µs 4.0±0.06µs 248.2 Ktx/sec 247.2 Ktx/sec
stdb_raw 💿 location non_unique 1000 12.0±67.88µs 5.2±0.14µs 81.1 Ktx/sec 188.8 Ktx/sec
stdb_raw 💿 location unique 0 5.2±0.07µs 5.3±0.19µs 186.7 Ktx/sec 185.5 Ktx/sec
stdb_raw 💿 location unique 1000 7.2±0.14µs 23.3±159.73µs 135.2 Ktx/sec 41.9 Ktx/sec
stdb_raw 💿 person multi_index 0 10.0±0.07µs 9.9±0.01µs 97.5 Ktx/sec 98.7 Ktx/sec
stdb_raw 💿 person multi_index 1000 13.0±0.17µs 12.9±0.32µs 75.3 Ktx/sec 75.5 Ktx/sec
stdb_raw 💿 person non_unique 0 4.5±0.01µs 4.9±0.31µs 217.4 Ktx/sec 198.0 Ktx/sec
stdb_raw 💿 person non_unique 1000 17.1±111.30µs 28.4±157.31µs 57.0 Ktx/sec 34.4 Ktx/sec
stdb_raw 💿 person unique 0 6.8±0.02µs 6.9±0.03µs 143.1 Ktx/sec 142.4 Ktx/sec
stdb_raw 💿 person unique 1000 26.4±170.59µs 30.5±213.00µs 37.0 Ktx/sec 32.0 Ktx/sec
stdb_raw 🧠 location multi_index 0 4.8±0.01µs 4.8±0.01µs 204.0 Ktx/sec 203.5 Ktx/sec
stdb_raw 🧠 location multi_index 1000 6.4±0.04µs 6.4±0.07µs 152.5 Ktx/sec 153.4 Ktx/sec
stdb_raw 🧠 location non_unique 0 2.5±0.00µs 2.5±0.02µs 383.7 Ktx/sec 387.6 Ktx/sec
stdb_raw 🧠 location non_unique 1000 3.2±0.02µs 3.2±0.03µs 309.3 Ktx/sec 305.4 Ktx/sec
stdb_raw 🧠 location unique 0 3.8±0.01µs 3.8±0.01µs 259.6 Ktx/sec 258.7 Ktx/sec
stdb_raw 🧠 location unique 1000 5.0±0.04µs 5.1±0.07µs 194.1 Ktx/sec 190.2 Ktx/sec
stdb_raw 🧠 person multi_index 0 8.4±0.01µs 8.4±0.03µs 115.6 Ktx/sec 116.0 Ktx/sec
stdb_raw 🧠 person multi_index 1000 10.5±0.12µs 10.4±0.10µs 92.9 Ktx/sec 93.9 Ktx/sec
stdb_raw 🧠 person non_unique 0 3.1±0.00µs 3.1±0.01µs 317.7 Ktx/sec 317.5 Ktx/sec
stdb_raw 🧠 person non_unique 1000 3.7±0.01µs 3.8±0.02µs 261.5 Ktx/sec 259.5 Ktx/sec
stdb_raw 🧠 person unique 0 5.3±0.01µs 5.4±0.01µs 183.3 Ktx/sec 182.4 Ktx/sec
stdb_raw 🧠 person unique 1000 6.7±0.05µs 6.8±0.07µs 146.4 Ktx/sec 143.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 - 132.5±2.23µs - 7.4 Ktx/sec
sqlite 💿 location multi_index 1000 100 - 204.2±1.25µs - 4.8 Ktx/sec
sqlite 💿 location non_unique 0 100 - 51.3±1.06µs - 19.0 Ktx/sec
sqlite 💿 location non_unique 1000 100 - 53.6±0.29µs - 18.2 Ktx/sec
sqlite 💿 location unique 0 100 - 53.6±2.61µs - 18.2 Ktx/sec
sqlite 💿 location unique 1000 100 - 58.1±0.64µs - 16.8 Ktx/sec
sqlite 💿 person multi_index 0 100 - 119.5±2.66µs - 8.2 Ktx/sec
sqlite 💿 person multi_index 1000 100 - 233.1±0.71µs - 4.2 Ktx/sec
sqlite 💿 person non_unique 0 100 - 49.7±1.60µs - 19.6 Ktx/sec
sqlite 💿 person non_unique 1000 100 - 61.5±0.21µs - 15.9 Ktx/sec
sqlite 💿 person unique 0 100 - 50.8±1.25µs - 19.2 Ktx/sec
sqlite 💿 person unique 1000 100 - 57.4±10.98µs - 17.0 Ktx/sec
sqlite 🧠 location multi_index 0 100 - 120.9±0.46µs - 8.1 Ktx/sec
sqlite 🧠 location multi_index 1000 100 - 172.3±0.46µs - 5.7 Ktx/sec
sqlite 🧠 location non_unique 0 100 - 45.6±0.47µs - 21.4 Ktx/sec
sqlite 🧠 location non_unique 1000 100 - 46.4±0.29µs - 21.0 Ktx/sec
sqlite 🧠 location unique 0 100 - 46.8±0.37µs - 20.9 Ktx/sec
sqlite 🧠 location unique 1000 100 - 50.6±0.50µs - 19.3 Ktx/sec
sqlite 🧠 person multi_index 0 100 - 109.2±0.42µs - 8.9 Ktx/sec
sqlite 🧠 person multi_index 1000 100 - 190.7±0.53µs - 5.1 Ktx/sec
sqlite 🧠 person non_unique 0 100 - 43.9±0.44µs - 22.2 Ktx/sec
sqlite 🧠 person non_unique 1000 100 - 47.0±0.35µs - 20.8 Ktx/sec
sqlite 🧠 person unique 0 100 - 45.2±0.54µs - 21.6 Ktx/sec
sqlite 🧠 person unique 1000 100 - 49.5±0.44µs - 19.7 Ktx/sec
stdb_module 💿 location multi_index 0 100 616.1±3.28µs 897.2±43.71µs 1623 tx/sec 1114 tx/sec
stdb_module 💿 location multi_index 1000 100 971.6±5.36µs 1154.8±106.65µs 1029 tx/sec 865 tx/sec
stdb_module 💿 location non_unique 0 100 504.5±0.87µs 532.5±8.33µs 1982 tx/sec 1878 tx/sec
stdb_module 💿 location non_unique 1000 100 378.1±3.70µs 550.2±4.22µs 2.6 Ktx/sec 1817 tx/sec
stdb_module 💿 location unique 0 100 565.5±84.35µs 509.4±38.37µs 1768 tx/sec 1963 tx/sec
stdb_module 💿 location unique 1000 100 496.2±26.70µs 634.8±106.24µs 2015 tx/sec 1575 tx/sec
stdb_module 💿 person multi_index 0 100 962.9±66.94µs 927.1±8.33µs 1038 tx/sec 1078 tx/sec
stdb_module 💿 person multi_index 1000 100 1191.1±16.95µs 1096.7±34.06µs 839 tx/sec 911 tx/sec
stdb_module 💿 person non_unique 0 100 649.7±10.96µs 478.8±15.65µs 1539 tx/sec 2.0 Ktx/sec
stdb_module 💿 person non_unique 1000 100 827.3±121.57µs 648.2±29.07µs 1208 tx/sec 1542 tx/sec
stdb_module 💿 person unique 0 100 681.0±16.78µs 655.9±56.64µs 1468 tx/sec 1524 tx/sec
stdb_module 💿 person unique 1000 100 991.4±60.35µs 930.9±36.81µs 1008 tx/sec 1074 tx/sec
stdb_module 🧠 location multi_index 0 100 476.3±2.39µs 648.9±137.82µs 2.1 Ktx/sec 1541 tx/sec
stdb_module 🧠 location multi_index 1000 100 653.5±1.37µs 686.4±14.14µs 1530 tx/sec 1456 tx/sec
stdb_module 🧠 location non_unique 0 100 344.9±42.20µs 402.8±26.28µs 2.8 Ktx/sec 2.4 Ktx/sec
stdb_module 🧠 location non_unique 1000 100 418.8±0.96µs 610.7±3.52µs 2.3 Ktx/sec 1637 tx/sec
stdb_module 🧠 location unique 0 100 522.8±49.11µs 476.8±2.43µs 1912 tx/sec 2.0 Ktx/sec
stdb_module 🧠 location unique 1000 100 737.9±77.81µs 759.6±54.70µs 1355 tx/sec 1316 tx/sec
stdb_module 🧠 person multi_index 0 100 893.0±98.36µs 956.7±20.22µs 1119 tx/sec 1045 tx/sec
stdb_module 🧠 person multi_index 1000 100 915.3±11.23µs 1043.7±4.47µs 1092 tx/sec 958 tx/sec
stdb_module 🧠 person non_unique 0 100 580.2±12.30µs 386.9±48.66µs 1723 tx/sec 2.5 Ktx/sec
stdb_module 🧠 person non_unique 1000 100 764.8±54.25µs 477.4±4.38µs 1307 tx/sec 2.0 Ktx/sec
stdb_module 🧠 person unique 0 100 655.4±6.22µs 631.8±39.54µs 1525 tx/sec 1582 tx/sec
stdb_module 🧠 person unique 1000 100 847.6±20.81µs 810.1±57.15µs 1179 tx/sec 1234 tx/sec
stdb_raw 💿 location multi_index 0 100 368.8±7.49µs 367.1±0.74µs 2.6 Ktx/sec 2.7 Ktx/sec
stdb_raw 💿 location multi_index 1000 100 403.0±95.36µs 415.7±229.40µs 2.4 Ktx/sec 2.3 Ktx/sec
stdb_raw 💿 location non_unique 0 100 142.7±0.48µs 140.9±0.36µs 6.8 Ktx/sec 6.9 Ktx/sec
stdb_raw 💿 location non_unique 1000 100 152.5±72.87µs 142.9±1.04µs 6.4 Ktx/sec 6.8 Ktx/sec
stdb_raw 💿 location unique 0 100 267.0±0.37µs 268.5±9.46µs 3.7 Ktx/sec 3.6 Ktx/sec
stdb_raw 💿 location unique 1000 100 286.4±1.50µs 303.7±160.11µs 3.4 Ktx/sec 3.2 Ktx/sec
stdb_raw 💿 person multi_index 0 100 692.7±1.45µs 685.1±1.94µs 1443 tx/sec 1459 tx/sec
stdb_raw 💿 person multi_index 1000 100 723.2±5.32µs 717.8±6.07µs 1382 tx/sec 1393 tx/sec
stdb_raw 💿 person non_unique 0 100 199.0±0.41µs 198.8±0.51µs 4.9 Ktx/sec 4.9 Ktx/sec
stdb_raw 💿 person non_unique 1000 100 201.9±0.32µs 211.9±98.76µs 4.8 Ktx/sec 4.6 Ktx/sec
stdb_raw 💿 person unique 0 100 408.9±0.90µs 408.6±0.56µs 2.4 Ktx/sec 2.4 Ktx/sec
stdb_raw 💿 person unique 1000 100 450.1±231.66µs 447.9±181.70µs 2.2 Ktx/sec 2.2 Ktx/sec
stdb_raw 🧠 location multi_index 0 100 362.6±0.52µs 362.7±0.67µs 2.7 Ktx/sec 2.7 Ktx/sec
stdb_raw 🧠 location multi_index 1000 100 387.5±0.63µs 389.6±0.77µs 2.5 Ktx/sec 2.5 Ktx/sec
stdb_raw 🧠 location non_unique 0 100 138.0±0.35µs 136.9±0.14µs 7.1 Ktx/sec 7.1 Ktx/sec
stdb_raw 🧠 location non_unique 1000 100 139.9±0.36µs 139.0±0.73µs 7.0 Ktx/sec 7.0 Ktx/sec
stdb_raw 🧠 location unique 0 100 262.0±2.47µs 266.1±2.08µs 3.7 Ktx/sec 3.7 Ktx/sec
stdb_raw 🧠 location unique 1000 100 281.3±0.47µs 287.2±3.33µs 3.5 Ktx/sec 3.4 Ktx/sec
stdb_raw 🧠 person multi_index 0 100 684.3±0.59µs 679.2±0.58µs 1461 tx/sec 1472 tx/sec
stdb_raw 🧠 person multi_index 1000 100 715.2±0.54µs 712.1±1.25µs 1398 tx/sec 1404 tx/sec
stdb_raw 🧠 person non_unique 0 100 193.3±0.70µs 193.3±0.76µs 5.1 Ktx/sec 5.1 Ktx/sec
stdb_raw 🧠 person non_unique 1000 100 195.7±0.43µs 196.0±0.24µs 5.0 Ktx/sec 5.0 Ktx/sec
stdb_raw 🧠 person unique 0 100 402.1±0.79µs 404.9±1.67µs 2.4 Ktx/sec 2.4 Ktx/sec
stdb_raw 🧠 person unique 1000 100 421.8±0.83µs 425.7±3.57µs 2.3 Ktx/sec 2.3 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.08µs - 107.2 Ktx/sec
sqlite 💿 person unique - 9.7±0.09µs - 101.2 Ktx/sec
sqlite 🧠 location unique - 7.9±0.06µs - 123.6 Ktx/sec
sqlite 🧠 person unique - 8.5±0.08µs - 115.3 Ktx/sec
stdb_module 💿 location unique 44.6±3.37µs 46.7±5.17µs 21.9 Ktx/sec 20.9 Ktx/sec
stdb_module 💿 person unique 54.4±5.11µs 56.0±9.46µs 18.0 Ktx/sec 17.4 Ktx/sec
stdb_module 🧠 location unique 42.5±3.27µs 46.7±5.20µs 23.0 Ktx/sec 20.9 Ktx/sec
stdb_module 🧠 person unique 53.3±7.73µs 60.9±6.07µs 18.3 Ktx/sec 16.0 Ktx/sec
stdb_raw 💿 location unique 9.0±0.03µs 8.2±0.01µs 108.0 Ktx/sec 119.0 Ktx/sec
stdb_raw 💿 person unique 9.0±0.04µs 8.2±0.01µs 107.9 Ktx/sec 119.0 Ktx/sec
stdb_raw 🧠 location unique 9.0±0.03µs 8.2±0.03µs 107.9 Ktx/sec 118.9 Ktx/sec
stdb_raw 🧠 person unique 9.1±0.09µs 8.2±0.01µs 107.9 Ktx/sec 118.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 - 406.8 Ktx/sec
sqlite 🧠 u32 1000 - 1143.0±4.64ns - 854.4 Ktx/sec
stdb_module 💿 u32 1000 18.6±0.99µs 19.7±0.94µs 52.6 Ktx/sec 49.7 Ktx/sec
stdb_module 🧠 u32 1000 18.5±0.69µs 19.5±0.76µs 52.9 Ktx/sec 50.1 Ktx/sec
stdb_raw 💿 u32 1000 874.6±2.80ns 872.3±2.30ns 1116.5 Ktx/sec 1119.6 Ktx/sec
stdb_raw 🧠 u32 1000 881.3±3.63ns 871.9±11.38ns 1108.1 Ktx/sec 1120.0 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.02µs - 169.2 Ktx/sec
sqlite 💿 string non_indexed 1000 10 - 53.4±1.01µs - 18.3 Ktx/sec
sqlite 💿 u64 indexed 1000 10 - 5.5±0.02µs - 178.8 Ktx/sec
sqlite 💿 u64 non_indexed 1000 10 - 34.5±0.19µs - 28.3 Ktx/sec
sqlite 🧠 string indexed 1000 10 - 4.2±0.02µs - 232.1 Ktx/sec
sqlite 🧠 string non_indexed 1000 10 - 52.0±0.95µs - 18.8 Ktx/sec
sqlite 🧠 u64 indexed 1000 10 - 4.0±0.02µs - 244.5 Ktx/sec
sqlite 🧠 u64 non_indexed 1000 10 - 33.2±0.23µs - 29.4 Ktx/sec
stdb_module 💿 string indexed 1000 10 27.4±2.29µs 30.1±2.52µs 35.7 Ktx/sec 32.4 Ktx/sec
stdb_module 💿 string non_indexed 1000 10 168.2±2.97µs 182.7±7.39µs 5.8 Ktx/sec 5.3 Ktx/sec
stdb_module 💿 u64 indexed 1000 10 22.2±1.12µs 24.9±2.12µs 44.0 Ktx/sec 39.2 Ktx/sec
stdb_module 💿 u64 non_indexed 1000 10 136.8±2.77µs 162.9±6.77µs 7.1 Ktx/sec 6.0 Ktx/sec
stdb_module 🧠 string indexed 1000 10 25.3±2.13µs 28.3±2.19µs 38.6 Ktx/sec 34.5 Ktx/sec
stdb_module 🧠 string non_indexed 1000 10 167.2±3.55µs 182.8±2.98µs 5.8 Ktx/sec 5.3 Ktx/sec
stdb_module 🧠 u64 indexed 1000 10 21.8±0.94µs 24.2±1.68µs 44.7 Ktx/sec 40.3 Ktx/sec
stdb_module 🧠 u64 non_indexed 1000 10 142.4±21.36µs 158.2±3.66µs 6.9 Ktx/sec 6.2 Ktx/sec
stdb_raw 💿 string indexed 1000 10 3.3±0.01µs 3.2±0.01µs 294.9 Ktx/sec 301.0 Ktx/sec
stdb_raw 💿 string non_indexed 1000 10 131.5±0.24µs 142.8±0.47µs 7.4 Ktx/sec 6.8 Ktx/sec
stdb_raw 💿 u64 indexed 1000 10 3.2±0.01µs 3.1±0.01µs 306.6 Ktx/sec 310.1 Ktx/sec
stdb_raw 💿 u64 non_indexed 1000 10 110.4±0.21µs 122.3±0.25µs 8.8 Ktx/sec 8.0 Ktx/sec
stdb_raw 🧠 string indexed 1000 10 3.3±0.02µs 3.3±0.04µs 295.1 Ktx/sec 299.8 Ktx/sec
stdb_raw 🧠 string non_indexed 1000 10 127.2±0.77µs 142.6±0.38µs 7.7 Ktx/sec 6.9 Ktx/sec
stdb_raw 🧠 u64 indexed 1000 10 3.2±0.01µs 3.1±0.01µs 306.6 Ktx/sec 311.0 Ktx/sec
stdb_raw 🧠 u64 non_indexed 1000 10 109.9±0.34µs 121.9±0.14µs 8.9 Ktx/sec 8.0 Ktx/sec

Serialize

schema format count new latency old latency new throughput old throughput
location bsatn 100 1646.9±35.94ns 1711.5±50.39ns 57.9 Mtx/sec 55.7 Mtx/sec
location json 100 3.7±0.02µs 3.4±0.05µs 26.1 Mtx/sec 28.1 Mtx/sec
location product_value 100 622.7±3.82ns 1119.9±0.69ns 153.1 Mtx/sec 85.2 Mtx/sec
person bsatn 100 2.8±0.01µs 2.9±0.01µs 34.0 Mtx/sec 33.1 Mtx/sec
person json 100 5.1±0.03µs 5.0±0.08µs 18.6 Mtx/sec 18.9 Mtx/sec
person product_value 100 1009.2±0.82ns 1114.3±0.93ns 94.5 Mtx/sec 85.6 Mtx/sec

Module: invoke with large arguments

arg size new latency old latency new throughput old throughput
64KiB 65.0±9.74µs 76.0±6.93µs - -

Module: print bulk

line count new latency old latency new throughput old throughput
1 20.0±0.98µs 20.4±0.79µs - -
100 192.7±2.69µs 202.9±8.76µs - -
1000 1796.1±78.57µs 1825.2±18.29µs - -

Remaining benchmarks

name new latency old latency new throughput old throughput

@github-actions
Copy link

github-actions bot commented Oct 25, 2023

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 💿 - 467.0±4.38ns - -
sqlite 🧠 - 448.5±2.32ns - -
stdb_module 💿 15.6±0.44µs 16.1±0.50µs - -
stdb_module 🧠 15.9±0.56µs 16.4±0.66µs - -
stdb_raw 💿 209.6±2.57ns 189.8±2.81ns - -
stdb_raw 🧠 210.6±1.83ns 190.1±2.84ns - -

Single-row insertions

db on disk schema index type load new latency old latency new throughput old throughput
sqlite 💿 location multi_index 0 - 14.7±0.61µs - 66.4 Ktx/sec
sqlite 💿 location multi_index 1000 - 18.0±21.10µs - 54.4 Ktx/sec
sqlite 💿 location non_unique 0 - 7.3±1.05µs - 133.1 Ktx/sec
sqlite 💿 location non_unique 1000 - 7.0±0.03µs - 138.6 Ktx/sec
sqlite 💿 location unique 0 - 7.2±0.04µs - 136.1 Ktx/sec
sqlite 💿 location unique 1000 - 7.1±0.03µs - 137.6 Ktx/sec
sqlite 💿 person multi_index 0 - 14.3±0.05µs - 68.4 Ktx/sec
sqlite 💿 person multi_index 1000 - 16.2±0.11µs - 60.1 Ktx/sec
sqlite 💿 person non_unique 0 - 7.3±0.04µs - 134.5 Ktx/sec
sqlite 💿 person non_unique 1000 - 7.3±0.03µs - 133.9 Ktx/sec
sqlite 💿 person unique 0 - 7.4±0.80µs - 132.9 Ktx/sec
sqlite 💿 person unique 1000 - 7.3±0.07µs - 133.4 Ktx/sec
sqlite 🧠 location multi_index 0 - 4.0±0.01µs - 243.0 Ktx/sec
sqlite 🧠 location multi_index 1000 - 5.3±0.05µs - 184.2 Ktx/sec
sqlite 🧠 location non_unique 0 - 1862.0±5.56ns - 524.5 Ktx/sec
sqlite 🧠 location non_unique 1000 - 1923.1±10.83ns - 507.8 Ktx/sec
sqlite 🧠 location unique 0 - 1857.2±10.34ns - 525.8 Ktx/sec
sqlite 🧠 location unique 1000 - 1975.6±17.45ns - 494.3 Ktx/sec
sqlite 🧠 person multi_index 0 - 3.7±0.01µs - 265.2 Ktx/sec
sqlite 🧠 person multi_index 1000 - 5.5±0.03µs - 177.8 Ktx/sec
sqlite 🧠 person non_unique 0 - 1920.5±4.10ns - 508.5 Ktx/sec
sqlite 🧠 person non_unique 1000 - 2.0±0.02µs - 480.0 Ktx/sec
sqlite 🧠 person unique 0 - 1904.6±8.19ns - 512.7 Ktx/sec
sqlite 🧠 person unique 1000 - 2.0±0.01µs - 477.4 Ktx/sec
stdb_module 💿 location multi_index 0 43.1±4.78µs 41.3±5.21µs 22.6 Ktx/sec 23.6 Ktx/sec
stdb_module 💿 location multi_index 1000 104.3±8.46µs 126.1±23.85µs 9.4 Ktx/sec 7.7 Ktx/sec
stdb_module 💿 location non_unique 0 38.2±6.13µs 35.5±3.89µs 25.6 Ktx/sec 27.5 Ktx/sec
stdb_module 💿 location non_unique 1000 179.6±40.26µs 293.5±3.53µs 5.4 Ktx/sec 3.3 Ktx/sec
stdb_module 💿 location unique 0 39.0±4.75µs 40.8±3.95µs 25.1 Ktx/sec 24.0 Ktx/sec
stdb_module 💿 location unique 1000 222.1±51.89µs 108.5±6.68µs 4.4 Ktx/sec 9.0 Ktx/sec
stdb_module 💿 person multi_index 0 54.3±7.66µs 50.9±5.40µs 18.0 Ktx/sec 19.2 Ktx/sec
stdb_module 💿 person multi_index 1000 237.1±92.38µs 211.7±104.85µs 4.1 Ktx/sec 4.6 Ktx/sec
stdb_module 💿 person non_unique 0 36.7±4.81µs 35.6±3.57µs 26.6 Ktx/sec 27.4 Ktx/sec
stdb_module 💿 person non_unique 1000 282.6±15.49µs 186.8±10.51µs 3.5 Ktx/sec 5.2 Ktx/sec
stdb_module 💿 person unique 0 42.3±4.65µs 50.6±5.07µs 23.1 Ktx/sec 19.3 Ktx/sec
stdb_module 💿 person unique 1000 282.5±6.17µs 147.6±10.38µs 3.5 Ktx/sec 6.6 Ktx/sec
stdb_module 🧠 location multi_index 0 33.8±3.26µs 32.9±1.87µs 28.9 Ktx/sec 29.7 Ktx/sec
stdb_module 🧠 location multi_index 1000 93.1±7.09µs 250.3±11.24µs 10.5 Ktx/sec 3.9 Ktx/sec
stdb_module 🧠 location non_unique 0 28.2±1.41µs 28.6±2.00µs 34.7 Ktx/sec 34.2 Ktx/sec
stdb_module 🧠 location non_unique 1000 123.3±7.39µs 274.5±4.62µs 7.9 Ktx/sec 3.6 Ktx/sec
stdb_module 🧠 location unique 0 30.3±1.95µs 31.8±2.90µs 32.3 Ktx/sec 30.7 Ktx/sec
stdb_module 🧠 location unique 1000 254.3±47.84µs 230.2±4.07µs 3.8 Ktx/sec 4.2 Ktx/sec
stdb_module 🧠 person multi_index 0 38.5±3.87µs 41.6±4.87µs 25.4 Ktx/sec 23.5 Ktx/sec
stdb_module 🧠 person multi_index 1000 273.1±8.44µs 316.1±3.85µs 3.6 Ktx/sec 3.1 Ktx/sec
stdb_module 🧠 person non_unique 0 28.6±2.15µs 31.0±3.08µs 34.2 Ktx/sec 31.5 Ktx/sec
stdb_module 🧠 person non_unique 1000 271.7±43.88µs 143.7±6.37µs 3.6 Ktx/sec 6.8 Ktx/sec
stdb_module 🧠 person unique 0 32.9±2.43µs 34.2±3.42µs 29.7 Ktx/sec 28.5 Ktx/sec
stdb_module 🧠 person unique 1000 186.8±53.10µs 192.6±5.89µs 5.2 Ktx/sec 5.1 Ktx/sec
stdb_raw 💿 location multi_index 0 6.4±0.01µs 6.3±0.02µs 153.0 Ktx/sec 155.4 Ktx/sec
stdb_raw 💿 location multi_index 1000 9.0±0.17µs 8.7±0.17µs 108.0 Ktx/sec 112.0 Ktx/sec
stdb_raw 💿 location non_unique 0 4.1±0.01µs 4.0±0.06µs 240.4 Ktx/sec 247.2 Ktx/sec
stdb_raw 💿 location non_unique 1000 14.0±85.03µs 5.2±0.14µs 69.6 Ktx/sec 188.8 Ktx/sec
stdb_raw 💿 location unique 0 5.4±0.02µs 5.3±0.19µs 180.7 Ktx/sec 185.5 Ktx/sec
stdb_raw 💿 location unique 1000 7.7±0.15µs 23.3±159.73µs 126.8 Ktx/sec 41.9 Ktx/sec
stdb_raw 💿 person multi_index 0 10.5±0.21µs 9.9±0.01µs 93.4 Ktx/sec 98.7 Ktx/sec
stdb_raw 💿 person multi_index 1000 13.6±0.16µs 12.9±0.32µs 71.6 Ktx/sec 75.5 Ktx/sec
stdb_raw 💿 person non_unique 0 4.6±0.02µs 4.9±0.31µs 211.7 Ktx/sec 198.0 Ktx/sec
stdb_raw 💿 person non_unique 1000 17.5±111.92µs 28.4±157.31µs 55.9 Ktx/sec 34.4 Ktx/sec
stdb_raw 💿 person unique 0 7.1±0.01µs 6.9±0.03µs 138.0 Ktx/sec 142.4 Ktx/sec
stdb_raw 💿 person unique 1000 9.7±0.16µs 30.5±213.00µs 100.6 Ktx/sec 32.0 Ktx/sec
stdb_raw 🧠 location multi_index 0 4.9±0.01µs 4.8±0.01µs 199.1 Ktx/sec 203.5 Ktx/sec
stdb_raw 🧠 location multi_index 1000 6.7±0.04µs 6.4±0.07µs 145.9 Ktx/sec 153.4 Ktx/sec
stdb_raw 🧠 location non_unique 0 2.6±0.00µs 2.5±0.02µs 369.6 Ktx/sec 387.6 Ktx/sec
stdb_raw 🧠 location non_unique 1000 3.4±0.02µs 3.2±0.03µs 289.9 Ktx/sec 305.4 Ktx/sec
stdb_raw 🧠 location unique 0 3.9±0.04µs 3.8±0.01µs 249.2 Ktx/sec 258.7 Ktx/sec
stdb_raw 🧠 location unique 1000 5.4±0.06µs 5.1±0.07µs 179.7 Ktx/sec 190.2 Ktx/sec
stdb_raw 🧠 person multi_index 0 8.9±0.01µs 8.4±0.03µs 109.5 Ktx/sec 116.0 Ktx/sec
stdb_raw 🧠 person multi_index 1000 11.1±0.09µs 10.4±0.10µs 87.7 Ktx/sec 93.9 Ktx/sec
stdb_raw 🧠 person non_unique 0 3.2±0.01µs 3.1±0.01µs 306.7 Ktx/sec 317.5 Ktx/sec
stdb_raw 🧠 person non_unique 1000 4.1±0.03µs 3.8±0.02µs 237.5 Ktx/sec 259.5 Ktx/sec
stdb_raw 🧠 person unique 0 5.6±0.01µs 5.4±0.01µs 174.4 Ktx/sec 182.4 Ktx/sec
stdb_raw 🧠 person unique 1000 7.2±0.07µs 6.8±0.07µs 135.6 Ktx/sec 143.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 - 132.5±2.23µs - 7.4 Ktx/sec
sqlite 💿 location multi_index 1000 100 - 204.2±1.25µs - 4.8 Ktx/sec
sqlite 💿 location non_unique 0 100 - 51.3±1.06µs - 19.0 Ktx/sec
sqlite 💿 location non_unique 1000 100 - 53.6±0.29µs - 18.2 Ktx/sec
sqlite 💿 location unique 0 100 - 53.6±2.61µs - 18.2 Ktx/sec
sqlite 💿 location unique 1000 100 - 58.1±0.64µs - 16.8 Ktx/sec
sqlite 💿 person multi_index 0 100 - 119.5±2.66µs - 8.2 Ktx/sec
sqlite 💿 person multi_index 1000 100 - 233.1±0.71µs - 4.2 Ktx/sec
sqlite 💿 person non_unique 0 100 - 49.7±1.60µs - 19.6 Ktx/sec
sqlite 💿 person non_unique 1000 100 - 61.5±0.21µs - 15.9 Ktx/sec
sqlite 💿 person unique 0 100 - 50.8±1.25µs - 19.2 Ktx/sec
sqlite 💿 person unique 1000 100 - 57.4±10.98µs - 17.0 Ktx/sec
sqlite 🧠 location multi_index 0 100 - 120.9±0.46µs - 8.1 Ktx/sec
sqlite 🧠 location multi_index 1000 100 - 172.3±0.46µs - 5.7 Ktx/sec
sqlite 🧠 location non_unique 0 100 - 45.6±0.47µs - 21.4 Ktx/sec
sqlite 🧠 location non_unique 1000 100 - 46.4±0.29µs - 21.0 Ktx/sec
sqlite 🧠 location unique 0 100 - 46.8±0.37µs - 20.9 Ktx/sec
sqlite 🧠 location unique 1000 100 - 50.6±0.50µs - 19.3 Ktx/sec
sqlite 🧠 person multi_index 0 100 - 109.2±0.42µs - 8.9 Ktx/sec
sqlite 🧠 person multi_index 1000 100 - 190.7±0.53µs - 5.1 Ktx/sec
sqlite 🧠 person non_unique 0 100 - 43.9±0.44µs - 22.2 Ktx/sec
sqlite 🧠 person non_unique 1000 100 - 47.0±0.35µs - 20.8 Ktx/sec
sqlite 🧠 person unique 0 100 - 45.2±0.54µs - 21.6 Ktx/sec
sqlite 🧠 person unique 1000 100 - 49.5±0.44µs - 19.7 Ktx/sec
stdb_module 💿 location multi_index 0 100 754.8±130.28µs 897.2±43.71µs 1324 tx/sec 1114 tx/sec
stdb_module 💿 location multi_index 1000 100 632.3±2.68µs 1154.8±106.65µs 1581 tx/sec 865 tx/sec
stdb_module 💿 location non_unique 0 100 376.6±62.70µs 532.5±8.33µs 2.6 Ktx/sec 1878 tx/sec
stdb_module 💿 location non_unique 1000 100 510.0±6.88µs 550.2±4.22µs 1960 tx/sec 1817 tx/sec
stdb_module 💿 location unique 0 100 423.9±18.78µs 509.4±38.37µs 2.3 Ktx/sec 1963 tx/sec
stdb_module 💿 location unique 1000 100 499.3±6.33µs 634.8±106.24µs 2002 tx/sec 1575 tx/sec
stdb_module 💿 person multi_index 0 100 1076.5±86.44µs 927.1±8.33µs 928 tx/sec 1078 tx/sec
stdb_module 💿 person multi_index 1000 100 1077.8±4.44µs 1096.7±34.06µs 927 tx/sec 911 tx/sec
stdb_module 💿 person non_unique 0 100 448.3±49.64µs 478.8±15.65µs 2.2 Ktx/sec 2.0 Ktx/sec
stdb_module 💿 person non_unique 1000 100 815.1±85.51µs 648.2±29.07µs 1226 tx/sec 1542 tx/sec
stdb_module 💿 person unique 0 100 751.7±110.63µs 655.9±56.64µs 1330 tx/sec 1524 tx/sec
stdb_module 💿 person unique 1000 100 919.7±25.69µs 930.9±36.81µs 1087 tx/sec 1074 tx/sec
stdb_module 🧠 location multi_index 0 100 645.5±132.17µs 648.9±137.82µs 1549 tx/sec 1541 tx/sec
stdb_module 🧠 location multi_index 1000 100 585.5±10.70µs 686.4±14.14µs 1707 tx/sec 1456 tx/sec
stdb_module 🧠 location non_unique 0 100 309.6±35.47µs 402.8±26.28µs 3.2 Ktx/sec 2.4 Ktx/sec
stdb_module 🧠 location non_unique 1000 100 460.5±4.14µs 610.7±3.52µs 2.1 Ktx/sec 1637 tx/sec
stdb_module 🧠 location unique 0 100 370.4±2.44µs 476.8±2.43µs 2.6 Ktx/sec 2.0 Ktx/sec
stdb_module 🧠 location unique 1000 100 644.8±105.97µs 759.6±54.70µs 1550 tx/sec 1316 tx/sec
stdb_module 🧠 person multi_index 0 100 861.6±14.89µs 956.7±20.22µs 1160 tx/sec 1045 tx/sec
stdb_module 🧠 person multi_index 1000 100 961.4±6.16µs 1043.7±4.47µs 1040 tx/sec 958 tx/sec
stdb_module 🧠 person non_unique 0 100 391.0±64.16µs 386.9±48.66µs 2.5 Ktx/sec 2.5 Ktx/sec
stdb_module 🧠 person non_unique 1000 100 506.0±77.42µs 477.4±4.38µs 1976 tx/sec 2.0 Ktx/sec
stdb_module 🧠 person unique 0 100 664.1±8.71µs 631.8±39.54µs 1505 tx/sec 1582 tx/sec
stdb_module 🧠 person unique 1000 100 606.2±3.67µs 810.1±57.15µs 1649 tx/sec 1234 tx/sec
stdb_raw 💿 location multi_index 0 100 368.0±0.75µs 367.1±0.74µs 2.7 Ktx/sec 2.7 Ktx/sec
stdb_raw 💿 location multi_index 1000 100 393.3±3.50µs 415.7±229.40µs 2.5 Ktx/sec 2.3 Ktx/sec
stdb_raw 💿 location non_unique 0 100 142.4±4.69µs 140.9±0.36µs 6.9 Ktx/sec 6.9 Ktx/sec
stdb_raw 💿 location non_unique 1000 100 153.7±91.63µs 142.9±1.04µs 6.4 Ktx/sec 6.8 Ktx/sec
stdb_raw 💿 location unique 0 100 267.5±0.40µs 268.5±9.46µs 3.7 Ktx/sec 3.6 Ktx/sec
stdb_raw 💿 location unique 1000 100 302.1±159.73µs 303.7±160.11µs 3.2 Ktx/sec 3.2 Ktx/sec
stdb_raw 💿 person multi_index 0 100 726.3±2.02µs 685.1±1.94µs 1376 tx/sec 1459 tx/sec
stdb_raw 💿 person multi_index 1000 100 794.8±405.54µs 717.8±6.07µs 1258 tx/sec 1393 tx/sec
stdb_raw 💿 person non_unique 0 100 199.3±0.30µs 198.8±0.51µs 4.9 Ktx/sec 4.9 Ktx/sec
stdb_raw 💿 person non_unique 1000 100 202.3±0.29µs 211.9±98.76µs 4.8 Ktx/sec 4.6 Ktx/sec
stdb_raw 💿 person unique 0 100 420.0±0.50µs 408.6±0.56µs 2.3 Ktx/sec 2.4 Ktx/sec
stdb_raw 💿 person unique 1000 100 439.2±0.57µs 447.9±181.70µs 2.2 Ktx/sec 2.2 Ktx/sec
stdb_raw 🧠 location multi_index 0 100 363.5±0.54µs 362.7±0.67µs 2.7 Ktx/sec 2.7 Ktx/sec
stdb_raw 🧠 location multi_index 1000 100 387.5±0.51µs 389.6±0.77µs 2.5 Ktx/sec 2.5 Ktx/sec
stdb_raw 🧠 location non_unique 0 100 137.4±0.12µs 136.9±0.14µs 7.1 Ktx/sec 7.1 Ktx/sec
stdb_raw 🧠 location non_unique 1000 100 139.6±0.14µs 139.0±0.73µs 7.0 Ktx/sec 7.0 Ktx/sec
stdb_raw 🧠 location unique 0 100 262.5±0.42µs 266.1±2.08µs 3.7 Ktx/sec 3.7 Ktx/sec
stdb_raw 🧠 location unique 1000 100 280.9±0.54µs 287.2±3.33µs 3.5 Ktx/sec 3.4 Ktx/sec
stdb_raw 🧠 person multi_index 0 100 715.7±0.70µs 679.2±0.58µs 1397 tx/sec 1472 tx/sec
stdb_raw 🧠 person multi_index 1000 100 747.2±2.06µs 712.1±1.25µs 1338 tx/sec 1404 tx/sec
stdb_raw 🧠 person non_unique 0 100 193.7±0.21µs 193.3±0.76µs 5.0 Ktx/sec 5.1 Ktx/sec
stdb_raw 🧠 person non_unique 1000 100 196.6±0.26µs 196.0±0.24µs 5.0 Ktx/sec 5.0 Ktx/sec
stdb_raw 🧠 person unique 0 100 413.6±0.71µs 404.9±1.67µs 2.4 Ktx/sec 2.4 Ktx/sec
stdb_raw 🧠 person unique 1000 100 431.8±1.10µs 425.7±3.57µs 2.3 Ktx/sec 2.3 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.08µs - 107.2 Ktx/sec
sqlite 💿 person unique - 9.7±0.09µs - 101.2 Ktx/sec
sqlite 🧠 location unique - 7.9±0.06µs - 123.6 Ktx/sec
sqlite 🧠 person unique - 8.5±0.08µs - 115.3 Ktx/sec
stdb_module 💿 location unique 44.9±4.20µs 46.7±5.17µs 21.8 Ktx/sec 20.9 Ktx/sec
stdb_module 💿 person unique 53.4±5.01µs 56.0±9.46µs 18.3 Ktx/sec 17.4 Ktx/sec
stdb_module 🧠 location unique 43.4±4.40µs 46.7±5.20µs 22.5 Ktx/sec 20.9 Ktx/sec
stdb_module 🧠 person unique 50.8±7.42µs 60.9±6.07µs 19.2 Ktx/sec 16.0 Ktx/sec
stdb_raw 💿 location unique 8.7±0.05µs 8.2±0.01µs 112.6 Ktx/sec 119.0 Ktx/sec
stdb_raw 💿 person unique 8.8±0.45µs 8.2±0.01µs 111.3 Ktx/sec 119.0 Ktx/sec
stdb_raw 🧠 location unique 8.7±0.05µs 8.2±0.03µs 112.6 Ktx/sec 118.9 Ktx/sec
stdb_raw 🧠 person unique 8.7±0.05µs 8.2±0.01µs 112.7 Ktx/sec 118.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 - 406.8 Ktx/sec
sqlite 🧠 u32 1000 - 1143.0±4.64ns - 854.4 Ktx/sec
stdb_module 💿 u32 1000 18.4±0.74µs 19.7±0.94µs 53.0 Ktx/sec 49.7 Ktx/sec
stdb_module 🧠 u32 1000 18.7±1.00µs 19.5±0.76µs 52.2 Ktx/sec 50.1 Ktx/sec
stdb_raw 💿 u32 1000 931.2±4.32ns 872.3±2.30ns 1048.7 Ktx/sec 1119.6 Ktx/sec
stdb_raw 🧠 u32 1000 931.6±2.64ns 871.9±11.38ns 1048.3 Ktx/sec 1120.0 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.02µs - 169.2 Ktx/sec
sqlite 💿 string non_indexed 1000 10 - 53.4±1.01µs - 18.3 Ktx/sec
sqlite 💿 u64 indexed 1000 10 - 5.5±0.02µs - 178.8 Ktx/sec
sqlite 💿 u64 non_indexed 1000 10 - 34.5±0.19µs - 28.3 Ktx/sec
sqlite 🧠 string indexed 1000 10 - 4.2±0.02µs - 232.1 Ktx/sec
sqlite 🧠 string non_indexed 1000 10 - 52.0±0.95µs - 18.8 Ktx/sec
sqlite 🧠 u64 indexed 1000 10 - 4.0±0.02µs - 244.5 Ktx/sec
sqlite 🧠 u64 non_indexed 1000 10 - 33.2±0.23µs - 29.4 Ktx/sec
stdb_module 💿 string indexed 1000 10 27.0±2.41µs 30.1±2.52µs 36.1 Ktx/sec 32.4 Ktx/sec
stdb_module 💿 string non_indexed 1000 10 173.0±6.78µs 182.7±7.39µs 5.6 Ktx/sec 5.3 Ktx/sec
stdb_module 💿 u64 indexed 1000 10 22.0±1.12µs 24.9±2.12µs 44.4 Ktx/sec 39.2 Ktx/sec
stdb_module 💿 u64 non_indexed 1000 10 136.7±1.45µs 162.9±6.77µs 7.1 Ktx/sec 6.0 Ktx/sec
stdb_module 🧠 string indexed 1000 10 26.1±2.38µs 28.3±2.19µs 37.4 Ktx/sec 34.5 Ktx/sec
stdb_module 🧠 string non_indexed 1000 10 166.7±1.81µs 182.8±2.98µs 5.9 Ktx/sec 5.3 Ktx/sec
stdb_module 🧠 u64 indexed 1000 10 23.4±2.03µs 24.2±1.68µs 41.8 Ktx/sec 40.3 Ktx/sec
stdb_module 🧠 u64 non_indexed 1000 10 137.7±5.22µs 158.2±3.66µs 7.1 Ktx/sec 6.2 Ktx/sec
stdb_raw 💿 string indexed 1000 10 3.4±0.01µs 3.2±0.01µs 289.7 Ktx/sec 301.0 Ktx/sec
stdb_raw 💿 string non_indexed 1000 10 128.4±0.26µs 142.8±0.47µs 7.6 Ktx/sec 6.8 Ktx/sec
stdb_raw 💿 u64 indexed 1000 10 3.2±0.01µs 3.1±0.01µs 301.7 Ktx/sec 310.1 Ktx/sec
stdb_raw 💿 u64 non_indexed 1000 10 110.1±0.28µs 122.3±0.25µs 8.9 Ktx/sec 8.0 Ktx/sec
stdb_raw 🧠 string indexed 1000 10 3.4±0.01µs 3.3±0.04µs 289.5 Ktx/sec 299.8 Ktx/sec
stdb_raw 🧠 string non_indexed 1000 10 127.1±0.20µs 142.6±0.38µs 7.7 Ktx/sec 6.9 Ktx/sec
stdb_raw 🧠 u64 indexed 1000 10 3.2±0.01µs 3.1±0.01µs 301.4 Ktx/sec 311.0 Ktx/sec
stdb_raw 🧠 u64 non_indexed 1000 10 109.3±0.22µs 121.9±0.14µs 8.9 Ktx/sec 8.0 Ktx/sec

Serialize

schema format count new latency old latency new throughput old throughput
location bsatn 100 1667.9±28.63ns 1711.5±50.39ns 57.2 Mtx/sec 55.7 Mtx/sec
location json 100 3.7±0.04µs 3.4±0.05µs 26.0 Mtx/sec 28.1 Mtx/sec
location product_value 100 624.9±10.99ns 1119.9±0.69ns 152.6 Mtx/sec 85.2 Mtx/sec
person bsatn 100 2.8±0.00µs 2.9±0.01µs 34.1 Mtx/sec 33.1 Mtx/sec
person json 100 5.0±0.01µs 5.0±0.08µs 18.9 Mtx/sec 18.9 Mtx/sec
person product_value 100 1037.2±1.42ns 1114.3±0.93ns 91.9 Mtx/sec 85.6 Mtx/sec

Module: invoke with large arguments

arg size new latency old latency new throughput old throughput
64KiB 70.1±3.67µs 76.0±6.93µs - -

Module: print bulk

line count new latency old latency new throughput old throughput
1 19.7±1.06µs 20.4±0.79µs - -
100 191.0±3.47µs 202.9±8.76µs - -
1000 1816.4±91.23µs 1825.2±18.29µs - -

Remaining benchmarks

name new latency old latency new throughput old throughput

@coolreader18 coolreader18 changed the title wasmtime Switch from wasmer to wasmtime Oct 27, 2023
@coolreader18 coolreader18 marked this pull request as ready for review October 27, 2023 20:55
@coolreader18 coolreader18 force-pushed the noa/wasmtime branch 3 times, most recently from 221a604 to 3a99f58 Compare November 1, 2023 22:06
Copy link
Contributor

@gefjon gefjon left a comment

Choose a reason for hiding this comment

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

This looks great, thanks Noa! Before we merge, we should:

  1. Rename the wasmer files to wasmtime.
  2. Run a BitCraft playtest with this branch to see how our performance metrics change.

crates/client-api/src/routes/energy.rs Show resolved Hide resolved
crates/core/Cargo.toml Outdated Show resolved Hide resolved
crates/core/src/control_db.rs Show resolved Hide resolved
crates/core/src/host/host_controller.rs Outdated Show resolved Hide resolved
crates/core/src/host/host_controller.rs Outdated Show resolved Hide resolved
crates/core/src/host/instance_env.rs Show resolved Hide resolved
crates/core/src/host/wasm_common.rs Outdated Show resolved Hide resolved
let mut config = wasmtime::Config::new();
config
.cranelift_opt_level(wasmtime::OptLevel::Speed)
.consume_fuel(true)
Copy link
Contributor

Choose a reason for hiding this comment

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

In the future, I think we should investigate whether epoch interruption is sufficient for our needs. Within this PR, fuel seems like the right thing to use, as it's the closest translation of Wasmer metering.

Copy link
Contributor

Choose a reason for hiding this comment

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

Would you mind filing a ticket about this?

crates/core/src/host/wasmer/mod.rs Outdated Show resolved Hide resolved
crates/core/src/host/wasmer/mod.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@kulakowski kulakowski left a comment

Choose a reason for hiding this comment

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

I think the code as such is fine and pretty thoroughly reviewed now so I'll say what I think we need to do to land this.

edit: added the need for comments
edit: added the task to fix the energy/fuel exchange rate based on a run of some chunky reducer

  • appropriate levels of doc comments
  • ensure no perf regressions
  • measure and align the energy/fuel exchange rate
  • ensure energy monitoring is sensible when deployed
  • understand what is needed to deploy this for production
    • is the "wasmer" -> "wasmtime" name change going to break any deployment scripts?
    • is that same name change going to affect control db instances?
  • test on all supported OSes
    • linux
    • macos
    • windows


impl WasmtimeFuel {
/// 1000 energy quanta == 1 wasmtime fuel unit
const QUANTA_MULTIPLIER: i128 = 1_000;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd like to see some explicit validation that the test deployment of this had energy consumption metered appropriately.

crates/core/src/host/wasmtime/mod.rs Show resolved Hide resolved
crates/core/src/host/wasmtime/wasmtime_module.rs Outdated Show resolved Hide resolved
@gefjon
Copy link
Contributor

gefjon commented Nov 6, 2023

ensure no perf regressions

As discussed elsewhere, internal testing has shown mild to moderate performance improvements compared to v0.7.2-beta on one of BitCraft's hot loops. That testing was not particularly rigorous, and it's possible there are edge-case-ey regressions we haven't caught - e.g. Wasmtime might make module compilation/instantiation more expensive - but I feel comfortable saying that the part we care about, module execution, is at least no worse.

@coolreader18 coolreader18 force-pushed the noa/wasmtime branch 3 times, most recently from e8d5179 to 13d6877 Compare November 6, 2023 21:10
@coolreader18
Copy link
Collaborator Author

@kazimuth just pushed a commit that lets wasmtime cache compilation artifacts to the filesystem - I think you were looking for something like this for benchmarking, right?

@coolreader18
Copy link
Collaborator Author

(if someone feels that's too tangential/confounding to this PR, fair, I'm happy to split it off to a follow-up)

@joshua-spacetime joshua-spacetime linked an issue Nov 7, 2023 that may be closed by this pull request
crates/core/src/host/wasmtime/mod.rs Outdated Show resolved Hide resolved
crates/core/src/host/wasmtime/mod.rs Outdated Show resolved Hide resolved
crates/core/src/host/wasmtime/wasm_instance_env.rs Outdated Show resolved Hide resolved
@coolreader18 coolreader18 force-pushed the noa/wasmtime branch 4 times, most recently from ec83358 to 45e2837 Compare November 13, 2023 18:46
kulakowski pushed a commit that referenced this pull request Nov 14, 2023
This rolls up PR #457 as of commit 45e2837
so that it can be easily deployed to the v0.7.4 release branch.
joshua-spacetime pushed a commit that referenced this pull request Nov 15, 2023
This rolls up PR #457 as of commit 45e2837
so that it can be easily deployed to the v0.7.4 release branch.
crates/core/src/host/wasm_common.rs Show resolved Hide resolved
crates/core/src/host/wasmtime/wasm_instance_env.rs Outdated Show resolved Hide resolved
mut caller: Caller<'_, Self>,
func: AbiCall,
f: impl FnOnce(&mut Caller<'_, Self>) -> WasmResult<()>,
) -> RtResult<u32> {
Copy link
Contributor

Choose a reason for hiding this comment

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

re the u16 -> u32 change throughout this file: is this ultimately stemming from a wasmtime api? like does it only let you have fn types whose return type impls some trait goop, and it bottoms out in only u32s etc because wasm only has i32s and not i16s?

I'm assuming the same for the anyhow::Result change in RtResult.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, which was the same for wasmer and the difference is that wasmtime only lets you use {i,u,f}{32,64} for those, while wasmer was happy to truncate/zero-extend with other integer types.

@coolreader18 coolreader18 enabled auto-merge (squash) November 17, 2023 01:05
@coolreader18 coolreader18 merged commit a33fa53 into master Nov 17, 2023
5 checks passed
@coolreader18 coolreader18 deleted the noa/wasmtime branch November 17, 2023 03:00
@coolreader18
Copy link
Collaborator Author

wahoo!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Investigate (and possibly switch to) wasmtime
6 participants