Skip to content

Commit

Permalink
Removing dead code: Relational ops and cursor (#1956)
Browse files Browse the repository at this point in the history
  • Loading branch information
mamcx authored Nov 7, 2024
1 parent 0b1beec commit 97c8c26
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 241 deletions.
30 changes: 0 additions & 30 deletions crates/core/src/db/cursor.rs

This file was deleted.

1 change: 0 additions & 1 deletion crates/core/src/db/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
pub mod datastore;
pub mod db_metrics;
pub mod relational_db;
mod relational_operators;
pub mod update;

/// Whether SpacetimeDB is run in memory, or persists objects and
Expand Down
8 changes: 6 additions & 2 deletions crates/core/src/db/relational_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use super::datastore::{
traits::TxData,
};
use super::db_metrics::DB_METRICS;
use super::relational_operators::Relation;
use crate::db::datastore::system_tables::{StModuleRow, WASM_MODULE};
use crate::error::{DBError, DatabaseError, TableError};
use crate::execution_context::{ReducerContext, Workload};
Expand Down Expand Up @@ -1148,7 +1147,12 @@ impl RelationalDB {
self.inner.delete_mut_tx(tx, table_id, row_ids)
}

pub fn delete_by_rel<R: Relation>(&self, tx: &mut MutTx, table_id: TableId, relation: R) -> u32 {
pub fn delete_by_rel<R: IntoIterator<Item = ProductValue>>(
&self,
tx: &mut MutTx,
table_id: TableId,
relation: R,
) -> u32 {
self.inner.delete_by_rel_mut_tx(tx, table_id, relation)
}

Expand Down
208 changes: 0 additions & 208 deletions crates/core/src/db/relational_operators.rs

This file was deleted.

2 comments on commit 97c8c26

@github-actions
Copy link

@github-actions github-actions bot commented on 97c8c26 Nov 7, 2024

Choose a reason for hiding this comment

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

Criterion benchmark results

Criterion benchmark report

YOU SHOULD PROBABLY IGNORE THESE RESULTS.

Criterion is a wall time based benchmarking system that is extremely noisy when run on CI. We collect these results for longitudinal analysis, but they are not reliable for comparing individual PRs.

Go look at the callgrind report instead.

empty

db on disk new latency old latency new throughput old throughput
sqlite 💿 406.5±3.89ns 404.1±1.61ns - -
sqlite 🧠 399.3±3.89ns 398.2±3.57ns - -
stdb_raw 💿 782.4±0.57ns 774.3±1.40ns - -
stdb_raw 🧠 783.6±1.26ns 774.4±3.08ns - -

insert_1

db on disk schema indices preload new latency old latency new throughput old throughput

insert_bulk

db on disk schema indices preload count new latency old latency new throughput old throughput
sqlite 💿 u32_u64_str btree_each_column 2048 256 582.2±0.78µs 591.7±0.77µs 1717 tx/sec 1690 tx/sec
sqlite 💿 u32_u64_str unique_0 2048 256 150.3±0.92µs 147.5±0.62µs 6.5 Ktx/sec 6.6 Ktx/sec
sqlite 💿 u32_u64_u64 btree_each_column 2048 256 459.3±0.91µs 465.4±0.25µs 2.1 Ktx/sec 2.1 Ktx/sec
sqlite 💿 u32_u64_u64 unique_0 2048 256 137.4±12.01µs 135.4±0.31µs 7.1 Ktx/sec 7.2 Ktx/sec
sqlite 🧠 u32_u64_str btree_each_column 2048 256 439.9±0.75µs 447.7±0.58µs 2.2 Ktx/sec 2.2 Ktx/sec
sqlite 🧠 u32_u64_str unique_0 2048 256 121.5±0.31µs 121.6±1.08µs 8.0 Ktx/sec 8.0 Ktx/sec
sqlite 🧠 u32_u64_u64 btree_each_column 2048 256 359.5±1.12µs 365.6±0.40µs 2.7 Ktx/sec 2.7 Ktx/sec
sqlite 🧠 u32_u64_u64 unique_0 2048 256 103.3±0.89µs 104.6±1.42µs 9.5 Ktx/sec 9.3 Ktx/sec
stdb_raw 💿 u32_u64_str btree_each_column 2048 256 593.9±17.54µs 553.7±59.69µs 1683 tx/sec 1806 tx/sec
stdb_raw 💿 u32_u64_str unique_0 2048 256 464.9±62.11µs 481.6±21.15µs 2.1 Ktx/sec 2.0 Ktx/sec
stdb_raw 💿 u32_u64_u64 btree_each_column 2048 256 368.1±18.72µs 369.3±9.29µs 2.7 Ktx/sec 2.6 Ktx/sec
stdb_raw 💿 u32_u64_u64 unique_0 2048 256 343.8±7.85µs 345.7±7.02µs 2.8 Ktx/sec 2.8 Ktx/sec
stdb_raw 🧠 u32_u64_str btree_each_column 2048 256 302.9±0.18µs 298.0±0.19µs 3.2 Ktx/sec 3.3 Ktx/sec
stdb_raw 🧠 u32_u64_str unique_0 2048 256 233.0±0.26µs 227.7±0.20µs 4.2 Ktx/sec 4.3 Ktx/sec
stdb_raw 🧠 u32_u64_u64 btree_each_column 2048 256 234.7±0.29µs 234.1±0.15µs 4.2 Ktx/sec 4.2 Ktx/sec
stdb_raw 🧠 u32_u64_u64 unique_0 2048 256 209.9±0.15µs 207.2±0.20µs 4.7 Ktx/sec 4.7 Ktx/sec

iterate

db on disk schema indices new latency old latency new throughput old throughput
sqlite 💿 u32_u64_str unique_0 21.1±0.23µs 22.4±0.41µs 46.2 Ktx/sec 43.5 Ktx/sec
sqlite 💿 u32_u64_u64 unique_0 19.8±0.09µs 20.1±0.04µs 49.4 Ktx/sec 48.5 Ktx/sec
sqlite 🧠 u32_u64_str unique_0 18.9±0.60µs 19.5±0.11µs 51.7 Ktx/sec 50.1 Ktx/sec
sqlite 🧠 u32_u64_u64 unique_0 17.4±0.07µs 17.4±0.07µs 56.0 Ktx/sec 56.1 Ktx/sec
stdb_raw 💿 u32_u64_str unique_0 4.9±0.00µs 4.0±0.00µs 198.4 Ktx/sec 244.2 Ktx/sec
stdb_raw 💿 u32_u64_u64 unique_0 4.8±0.00µs 3.9±0.00µs 204.0 Ktx/sec 252.1 Ktx/sec
stdb_raw 🧠 u32_u64_str unique_0 4.9±0.00µs 4.0±0.00µs 198.5 Ktx/sec 244.5 Ktx/sec
stdb_raw 🧠 u32_u64_u64 unique_0 4.8±0.00µs 3.9±0.01µs 203.9 Ktx/sec 252.6 Ktx/sec

find_unique

db on disk key type preload new latency old latency new throughput old throughput

filter

db on disk key type index strategy load count new latency old latency new throughput old throughput
sqlite 💿 string index 2048 256 68.8±0.21µs 69.8±0.16µs 14.2 Ktx/sec 14.0 Ktx/sec
sqlite 💿 u64 index 2048 256 63.2±0.31µs 65.6±0.52µs 15.4 Ktx/sec 14.9 Ktx/sec
sqlite 🧠 string index 2048 256 63.6±0.19µs 65.5±0.24µs 15.4 Ktx/sec 14.9 Ktx/sec
sqlite 🧠 u64 index 2048 256 58.0±0.32µs 59.8±0.16µs 16.8 Ktx/sec 16.3 Ktx/sec
stdb_raw 💿 string index 2048 256 5.1±0.00µs 5.0±0.00µs 192.1 Ktx/sec 195.5 Ktx/sec
stdb_raw 💿 u64 index 2048 256 5.0±0.00µs 4.9±0.00µs 195.4 Ktx/sec 198.6 Ktx/sec
stdb_raw 🧠 string index 2048 256 5.1±0.00µs 5.0±0.00µs 192.0 Ktx/sec 195.5 Ktx/sec
stdb_raw 🧠 u64 index 2048 256 5.0±0.01µs 4.9±0.00µs 195.4 Ktx/sec 198.7 Ktx/sec

serialize

schema format count new latency old latency new throughput old throughput
u32_u64_str bflatn_to_bsatn_fast_path 100 3.5±0.01µs 3.6±0.01µs 26.9 Mtx/sec 26.9 Mtx/sec
u32_u64_str bflatn_to_bsatn_slow_path 100 3.5±0.00µs 3.5±0.00µs 27.0 Mtx/sec 26.9 Mtx/sec
u32_u64_str bsatn 100 2.4±0.00µs 2.4±0.01µs 39.3 Mtx/sec 40.1 Mtx/sec
u32_u64_str bsatn 100 7.1±0.03ns 15.7±0.11ns 13.0 Gtx/sec 6.0 Gtx/sec
u32_u64_str json 100 4.7±0.03µs 4.8±0.02µs 20.1 Mtx/sec 19.8 Mtx/sec
u32_u64_str json 100 8.8±0.14µs 9.1±0.18µs 10.8 Mtx/sec 10.4 Mtx/sec
u32_u64_str product_value 100 1020.5±0.87ns 1018.9±3.26ns 93.5 Mtx/sec 93.6 Mtx/sec
u32_u64_u64 bflatn_to_bsatn_fast_path 100 919.5±14.67ns 1007.2±37.10ns 103.7 Mtx/sec 94.7 Mtx/sec
u32_u64_u64 bflatn_to_bsatn_slow_path 100 2.8±0.00µs 2.8±0.00µs 34.3 Mtx/sec 34.2 Mtx/sec
u32_u64_u64 bsatn 100 1734.6±44.98ns 1736.0±29.40ns 55.0 Mtx/sec 54.9 Mtx/sec
u32_u64_u64 bsatn 100 6.7±0.17ns 14.8±0.02ns 13.8 Gtx/sec 6.3 Gtx/sec
u32_u64_u64 json 100 3.3±0.09µs 3.3±0.05µs 28.6 Mtx/sec 29.1 Mtx/sec
u32_u64_u64 json 100 6.1±0.12µs 6.0±0.13µs 15.5 Mtx/sec 15.9 Mtx/sec
u32_u64_u64 product_value 100 1014.4±0.65ns 1014.6±0.57ns 94.0 Mtx/sec 94.0 Mtx/sec
u64_u64_u32 bflatn_to_bsatn_fast_path 100 725.0±0.51ns 726.4±1.93ns 131.5 Mtx/sec 131.3 Mtx/sec
u64_u64_u32 bflatn_to_bsatn_slow_path 100 2.8±0.00µs 2.8±0.01µs 34.2 Mtx/sec 34.2 Mtx/sec
u64_u64_u32 bsatn 100 1732.2±25.77ns 1751.3±70.04ns 55.1 Mtx/sec 54.5 Mtx/sec
u64_u64_u32 bsatn 100 690.3±0.76ns 704.9±3.63ns 138.2 Mtx/sec 135.3 Mtx/sec
u64_u64_u32 json 100 3.1±0.03µs 3.1±0.02µs 30.3 Mtx/sec 30.5 Mtx/sec
u64_u64_u32 json 100 6.3±0.18µs 6.0±0.13µs 15.1 Mtx/sec 16.0 Mtx/sec
u64_u64_u32 product_value 100 1017.0±0.58ns 1015.3±0.84ns 93.8 Mtx/sec 93.9 Mtx/sec

stdb_module_large_arguments

arg size new latency old latency new throughput old throughput
64KiB 101.4±9.09µs 100.8±7.71µs - -

stdb_module_print_bulk

line count new latency old latency new throughput old throughput
1 42.0±4.27µs 51.2±5.00µs - -
100 595.7±12.65µs 614.3±6.29µs - -
1000 5.4±0.09ms 5.5±0.03ms - -

remaining

name new latency old latency new throughput old throughput
special/db_game/circles/load=10 38.0±5.08ms 42.0±7.15ms - -
special/db_game/circles/load=100 52.4±6.92ms 37.7±1.01ms - -
special/db_game/ia_loop/load=500 147.3±1.25ms 148.2±1.12ms - -
special/db_game/ia_loop/load=5000 5.3±0.03s 5.2±0.03s - -
sqlite/💿/update_bulk/u32_u64_str/unique_0/load=2048/count=256 52.5±0.12µs 52.8±0.10µs 18.6 Ktx/sec 18.5 Ktx/sec
sqlite/💿/update_bulk/u32_u64_u64/unique_0/load=2048/count=256 44.9±0.04µs 45.6±0.17µs 21.7 Ktx/sec 21.4 Ktx/sec
sqlite/🧠/update_bulk/u32_u64_str/unique_0/load=2048/count=256 37.2±0.10µs 38.7±0.05µs 26.2 Ktx/sec 25.2 Ktx/sec
sqlite/🧠/update_bulk/u32_u64_u64/unique_0/load=2048/count=256 34.0±0.11µs 35.7±0.14µs 28.7 Ktx/sec 27.4 Ktx/sec
stdb_module/💿/update_bulk/u32_u64_str/unique_0/load=2048/count=256 1282.8±7.00µs 1258.8±7.44µs 779 tx/sec 794 tx/sec
stdb_module/💿/update_bulk/u32_u64_u64/unique_0/load=2048/count=256 995.7±11.27µs 1020.5±3.70µs 1004 tx/sec 979 tx/sec
stdb_raw/💿/update_bulk/u32_u64_str/unique_0/load=2048/count=256 628.2±19.07µs 523.6±11.84µs 1591 tx/sec 1909 tx/sec
stdb_raw/💿/update_bulk/u32_u64_u64/unique_0/load=2048/count=256 479.0±8.01µs 478.5±8.88µs 2.0 Ktx/sec 2.0 Ktx/sec
stdb_raw/🧠/update_bulk/u32_u64_str/unique_0/load=2048/count=256 361.9±0.31µs 361.4±0.50µs 2.7 Ktx/sec 2.7 Ktx/sec
stdb_raw/🧠/update_bulk/u32_u64_u64/unique_0/load=2048/count=256 324.1±0.41µs 322.6±0.96µs 3.0 Ktx/sec 3.0 Ktx/sec

@github-actions
Copy link

@github-actions github-actions bot commented on 97c8c26 Nov 7, 2024

Choose a reason for hiding this comment

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

Callgrind benchmark results

Callgrind Benchmark Report

These benchmarks were run using callgrind,
an instruction-level profiler. They allow comparisons between sqlite (sqlite), SpacetimeDB running through a module (stdb_module), and the underlying SpacetimeDB data storage engine (stdb_raw). Callgrind emulates a CPU to collect the below estimates.

Measurement changes larger than five percent are in bold.

In-memory benchmarks

callgrind: empty transaction

db total reads + writes old total reads + writes Δrw estimated cycles old estimated cycles Δcycles
stdb_raw 6399 6399 0.00% 6491 6491 0.00%
sqlite 5579 5579 0.00% 6051 6051 0.00%

callgrind: filter

db schema indices count preload _column data_type total reads + writes old total reads + writes Δrw estimated cycles old estimated cycles Δcycles
stdb_raw u32_u64_str no_index 64 128 1 u64 76593 76593 0.00% 77037 77045 -0.01%
stdb_raw u32_u64_str no_index 64 128 2 string 119091 120180 -0.91% 119923 120968 -0.86%
stdb_raw u32_u64_str btree_each_column 64 128 2 string 25083 25083 0.00% 25727 25667 0.23%
stdb_raw u32_u64_str btree_each_column 64 128 1 u64 24051 24051 0.00% 24479 24467 0.05%
sqlite u32_u64_str no_index 64 128 2 string 144695 144695 0.00% 146215 146215 0.00%
sqlite u32_u64_str no_index 64 128 1 u64 124044 124044 0.00% 125320 125320 0.00%
sqlite u32_u64_str btree_each_column 64 128 1 u64 131361 131361 0.00% 132813 132817 -0.00%
sqlite u32_u64_str btree_each_column 64 128 2 string 134500 134494 0.00% 136212 136206 0.00%

callgrind: insert bulk

db schema indices count preload total reads + writes old total reads + writes Δrw estimated cycles old estimated cycles Δcycles
stdb_raw u32_u64_str unique_0 64 128 876906 876862 0.01% 901218 931914 -3.29%
stdb_raw u32_u64_str btree_each_column 64 128 1024140 1029125 -0.48% 1048840 1053805 -0.47%
sqlite u32_u64_str unique_0 64 128 398320 398320 0.00% 413316 413308 0.00%
sqlite u32_u64_str btree_each_column 64 128 983637 983637 0.00% 1018735 1018731 0.00%

callgrind: iterate

db schema indices count total reads + writes old total reads + writes Δrw estimated cycles old estimated cycles Δcycles
stdb_raw u32_u64_str unique_0 1024 153726 153726 0.00% 153800 153800 0.00%
stdb_raw u32_u64_str unique_0 64 16751 16751 0.00% 16809 16833 -0.14%
sqlite u32_u64_str unique_0 1024 1067255 1067255 0.00% 1070583 1070583 0.00%
sqlite u32_u64_str unique_0 64 76201 76201 0.00% 77195 77195 0.00%

callgrind: serialize_product_value

count format total reads + writes old total reads + writes Δrw estimated cycles old estimated cycles Δcycles
64 json 47528 47528 0.00% 50146 50146 0.00%
64 bsatn 25509 25509 0.00% 27685 27685 0.00%
16 bsatn 8200 8200 0.00% 9492 9492 0.00%
16 json 12188 12188 0.00% 14058 14058 0.00%

callgrind: update bulk

db schema indices count preload total reads + writes old total reads + writes Δrw estimated cycles old estimated cycles Δcycles
stdb_raw u32_u64_str unique_0 1024 1024 20491290 20086103 2.02% 21121342 20665167 2.21%
stdb_raw u32_u64_str unique_0 64 128 1284809 1284124 0.05% 1327735 1357694 -2.21%
sqlite u32_u64_str unique_0 1024 1024 1802200 1802182 0.00% 1811480 1811458 0.00%
sqlite u32_u64_str unique_0 64 128 128528 128528 0.00% 131412 131412 0.00%
On-disk benchmarks

callgrind: empty transaction

db total reads + writes old total reads + writes Δrw estimated cycles old estimated cycles Δcycles
stdb_raw 6404 6404 0.00% 6512 6512 0.00%
sqlite 5621 5621 0.00% 6153 6153 0.00%

callgrind: filter

db schema indices count preload _column data_type total reads + writes old total reads + writes Δrw estimated cycles old estimated cycles Δcycles
stdb_raw u32_u64_str no_index 64 128 1 u64 76598 76598 0.00% 77038 77026 0.02%
stdb_raw u32_u64_str no_index 64 128 2 string 119088 119096 -0.01% 119864 119896 -0.03%
stdb_raw u32_u64_str btree_each_column 64 128 2 string 25089 25088 0.00% 25637 25632 0.02%
stdb_raw u32_u64_str btree_each_column 64 128 1 u64 24056 24056 0.00% 24456 24456 0.00%
sqlite u32_u64_str no_index 64 128 1 u64 125965 125965 0.00% 127637 127633 0.00%
sqlite u32_u64_str no_index 64 128 2 string 146616 146616 0.00% 148500 148496 0.00%
sqlite u32_u64_str btree_each_column 64 128 2 string 136616 136616 0.00% 138786 138782 0.00%
sqlite u32_u64_str btree_each_column 64 128 1 u64 133457 133457 0.00% 135259 135263 -0.00%

callgrind: insert bulk

db schema indices count preload total reads + writes old total reads + writes Δrw estimated cycles old estimated cycles Δcycles
stdb_raw u32_u64_str unique_0 64 128 825503 825964 -0.06% 848737 880078 -3.56%
stdb_raw u32_u64_str btree_each_column 64 128 976580 977328 -0.08% 1030650 1031134 -0.05%
sqlite u32_u64_str unique_0 64 128 415857 415857 0.00% 430131 430139 -0.00%
sqlite u32_u64_str btree_each_column 64 128 1021898 1021898 0.00% 1056380 1056380 0.00%

callgrind: iterate

db schema indices count total reads + writes old total reads + writes Δrw estimated cycles old estimated cycles Δcycles
stdb_raw u32_u64_str unique_0 1024 153731 153731 0.00% 153785 153785 0.00%
stdb_raw u32_u64_str unique_0 64 16756 16756 0.00% 16810 16810 0.00%
sqlite u32_u64_str unique_0 1024 1070323 1070323 0.00% 1074041 1074041 0.00%
sqlite u32_u64_str unique_0 64 77973 77973 0.00% 79211 79211 0.00%

callgrind: serialize_product_value

count format total reads + writes old total reads + writes Δrw estimated cycles old estimated cycles Δcycles
64 json 47528 47528 0.00% 50146 50146 0.00%
64 bsatn 25509 25509 0.00% 27685 27685 0.00%
16 bsatn 8200 8200 0.00% 9492 9492 0.00%
16 json 12188 12188 0.00% 14058 14058 0.00%

callgrind: update bulk

db schema indices count preload total reads + writes old total reads + writes Δrw estimated cycles old estimated cycles Δcycles
stdb_raw u32_u64_str unique_0 1024 1024 19002188 19004206 -0.01% 19660380 19672796 -0.06%
stdb_raw u32_u64_str unique_0 64 128 1237387 1237950 -0.05% 1309539 1310060 -0.04%
sqlite u32_u64_str unique_0 1024 1024 1809743 1809743 0.00% 1818387 1818387 0.00%
sqlite u32_u64_str unique_0 64 128 132660 132654 0.00% 135596 135590 0.00%

Please sign in to comment.