Skip to content

Commit

Permalink
Cached query execution plan (#1923)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshua-spacetime authored Nov 1, 2024
1 parent 3afa1e0 commit f199ba5
Show file tree
Hide file tree
Showing 3 changed files with 407 additions and 256 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions crates/execution/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ description = "The SpacetimeDB query engine"
[dependencies]
spacetimedb-expr.workspace = true
spacetimedb-lib.workspace = true
spacetimedb-primitives.workspace = true
spacetimedb-table.workspace = true
Loading

2 comments on commit f199ba5

@github-actions
Copy link

@github-actions github-actions bot commented on f199ba5 Nov 1, 2024

Choose a reason for hiding this comment

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

Benchmarking failed. Please check the workflow run for details.

@github-actions
Copy link

@github-actions github-actions bot commented on f199ba5 Nov 1, 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 6890 6890 0.00% 6982 6982 0.00%
sqlite 5579 5579 0.00% 5979 5979 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 77086 77086 0.00% 77634 77618 0.02%
stdb_raw u32_u64_str no_index 64 128 2 string 119585 119585 0.00% 120439 120371 0.06%
stdb_raw u32_u64_str btree_each_column 64 128 2 string 25576 25575 0.00% 26238 26245 -0.03%
stdb_raw u32_u64_str btree_each_column 64 128 1 u64 24543 24543 0.00% 25035 25035 0.00%
sqlite u32_u64_str no_index 64 128 2 string 144707 144701 0.00% 146235 146229 0.00%
sqlite u32_u64_str no_index 64 128 1 u64 124050 124062 -0.01% 125296 125308 -0.01%
sqlite u32_u64_str btree_each_column 64 128 1 u64 131361 131361 0.00% 132717 132721 -0.00%
sqlite u32_u64_str btree_each_column 64 128 2 string 134494 134494 0.00% 136160 136168 -0.01%

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 879214 878517 0.08% 898076 928183 -3.24%
stdb_raw u32_u64_str btree_each_column 64 128 1028099 1027693 0.04% 1085455 1054561 2.93%
sqlite u32_u64_str unique_0 64 128 398320 398320 0.00% 419026 419030 -0.00%
sqlite u32_u64_str btree_each_column 64 128 983649 983643 0.00% 1025371 1025361 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 154220 154220 0.00% 154306 154306 0.00%
stdb_raw u32_u64_str unique_0 64 17243 17243 0.00% 17313 17313 0.00%
sqlite u32_u64_str unique_0 1024 1067255 1067255 0.00% 1070575 1070575 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% 50180 50180 0.00%
64 bsatn 25509 25509 0.00% 27787 27787 0.00%
16 bsatn 8200 8200 0.00% 9594 9594 0.00%
16 json 12188 12188 0.00% 14092 14092 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 20121921 20122626 -0.00% 20582939 20579100 0.02%
stdb_raw u32_u64_str unique_0 64 128 1286037 1287317 -0.10% 1320241 1352289 -2.37%
sqlite u32_u64_str unique_0 1024 1024 1802206 1802188 0.00% 1811592 1811562 0.00%
sqlite u32_u64_str unique_0 64 128 128534 128534 0.00% 131426 131426 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 6895 6895 0.00% 7003 7003 0.00%
sqlite 5621 5621 0.00% 6085 6085 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 77091 77091 0.00% 77627 77591 0.05%
stdb_raw u32_u64_str no_index 64 128 2 string 120679 120679 0.00% 121489 121557 -0.06%
stdb_raw u32_u64_str btree_each_column 64 128 2 string 25580 25581 -0.00% 26174 26183 -0.03%
stdb_raw u32_u64_str btree_each_column 64 128 1 u64 24548 24548 0.00% 24996 24996 0.00%
sqlite u32_u64_str no_index 64 128 1 u64 125965 125965 0.00% 127461 127457 0.00%
sqlite u32_u64_str no_index 64 128 2 string 146616 146616 0.00% 148374 148370 0.00%
sqlite u32_u64_str btree_each_column 64 128 2 string 136616 136616 0.00% 138748 138744 0.00%
sqlite u32_u64_str btree_each_column 64 128 1 u64 133457 133457 0.00% 135231 135231 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 828859 829240 -0.05% 879359 879896 -0.06%
stdb_raw u32_u64_str btree_each_column 64 128 978162 977587 0.06% 1034814 1033961 0.08%
sqlite u32_u64_str unique_0 64 128 415857 415857 0.00% 435925 435913 0.00%
sqlite u32_u64_str btree_each_column 64 128 1021908 1021908 0.00% 1063030 1063022 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 154225 154225 0.00% 154311 154295 0.01%
stdb_raw u32_u64_str unique_0 64 17248 17248 0.00% 17310 17314 -0.02%
sqlite u32_u64_str unique_0 1024 1070323 1070323 0.00% 1074093 1074093 0.00%
sqlite u32_u64_str unique_0 64 77973 77973 0.00% 79243 79243 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% 50180 50180 0.00%
64 bsatn 25509 25509 0.00% 27787 27787 0.00%
16 bsatn 8200 8200 0.00% 9594 9594 0.00%
16 json 12188 12188 0.00% 14092 14092 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 19042281 19034238 0.04% 19605753 19581212 0.13%
stdb_raw u32_u64_str unique_0 64 128 1240680 1240052 0.05% 1306054 1307652 -0.12%
sqlite u32_u64_str unique_0 1024 1024 1809743 1809743 0.00% 1818383 1818383 0.00%
sqlite u32_u64_str unique_0 64 128 132654 132654 0.00% 135524 135524 0.00%

Please sign in to comment.