Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ on:
push:
branches:
- master
- kazimuth/benchwrangle
workflow_dispatch:
inputs:
pr_number:
Expand Down Expand Up @@ -63,27 +64,23 @@ jobs:
run: |
cargo build --release

- name: Install clippy for module build
Copy link
Contributor

Choose a reason for hiding this comment

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

Someone other than me should probably ACK the CI changes, I'm not super familiar.

run: |
rustup component add clippy

- name: Criterion compare base branch
if: ${{ env.PR_BASE_REF }}
uses: clockworklabs/criterion-compare-action@main
with:
cwd: "crates/bench"
branchName: ${{ env.PR_BASE_REF }}
benchName: modules

- name: Criterion compare previous commit
if: env.PR_BASE_REF == ''
uses: clockworklabs/criterion-compare-action@main
with:
cwd: "crates/bench"
branchName: "HEAD~1"
benchName: modules

- name: Benchmark Vs Sqlite
working-directory: crates/bench/
run: |
python3 hyper_cmp.py versus > out.report
cat out.report >> $GITHUB_STEP_SUMMARY

- name: Clean up
if: always()
Expand Down
7 changes: 7 additions & 0 deletions Cargo.lock

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

10 changes: 8 additions & 2 deletions crates/bench/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ license-file = "LICENSE"
description = "Bench library/utility for SpacetimeDB"

[[bench]]
name = "db"
name = "special"
harness = false

[[bench]]
name = "modules"
name = "generic"
harness = false

[lib]
Expand All @@ -23,12 +23,18 @@ spacetimedb-standalone = { path = "../standalone" }
spacetimedb-client-api = { path = "../client-api" }
spacetimedb-testing = { path = "../testing" }

log.workspace = true
clap.workspace = true
rusqlite.workspace = true
criterion.workspace = true
tempdir.workspace = true
rand.workspace = true
tokio.workspace = true
serde_json.workspace = true
serde.workspace = true
anyhow.workspace = true
anymap.workspace = true
byte-unit.workspace = true
futures.workspace = true
tracing-subscriber.workspace = true
lazy_static.workspace = true
58 changes: 57 additions & 1 deletion crates/bench/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,60 @@
spacetimedb-bench# Benchmarking suite for SpacetimeDB
# spacetimedb-bench
Benchmarking suite for SpacetimeDB using Criterion. Provides comparisons between the underlying spacetime datastore, spacetime modules, and sqlite.

Timings for spacetime modules should be understood as *latencies to call a spacetime reducer without network delays*. They include serialization and deserialization times for any arguments passed. There are also separate benchmarks that measure these times on their own.

## Benchmark structure

The complete structure (not yet fully implemented) is as follows:

```
[db]/[disk]/
empty_transaction/
insert_1/[schema]/[index_type]/[load]
insert_bulk/[schema]/[index_type]/[load]/[count]
insert_large_value/[count]
iterate/[schema]/[count]/
filter/[string, u64]/[index?]/[load]/[count]
find_unique/u32/[load]/
update/[load]/[count]
delete/[index_type]/[load]/[count]

# "load" refers to the number of rows in the table at the start of the benchmark.

# db: [stdb_raw, stdb_module, sqlite]
# disk: [disk, mem]
# schema: [person, location]
# index_type: [unique, non_unique, multi_index]

# "person" is a schema with 2 ints and a string, "location" is a schema with 3 ints.

serialize/
bsatn/[schema]/[count]
json/[schema]/[count]
product_value/[schema]/[count]

deserialize/
bsatn/[schema]/[count]
json/[schema]/[count]

stdb_module/
print_bulk/[count]
large_arguments/64KiB/
```

Typically you don't want to run all benchmarks at once, there are a lot of them and it will take many minutes.
You can pass regexes to the bench script to select what slice of benchmarks you'd like. For example,

```sh
cargo bench -- 'stdb_raw/.*/insert_bulk'
```
Will run all of the `insert_bulk` benchmarks against the raw spacetime backend.

Similarly,
```sh
cargo bench -- 'mem/.*/unique'
```
Will run benchmarks involving unique primary keys against all databases, without writing to disc.

## Install tools

Expand Down
100 changes: 0 additions & 100 deletions crates/bench/benches/db.rs

This file was deleted.

Loading