Skip to content

Commit ef429ee

Browse files
authored
Merge branch 'master' into bfops/pr-approval-check-again
2 parents 0dede81 + 7454329 commit ef429ee

105 files changed

Lines changed: 4620 additions & 10890 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 27 additions & 47 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ members = [
3838
"crates/table",
3939
"crates/testing",
4040
"crates/update",
41-
"crates/vm",
4241
"modules/benchmarks",
4342
"modules/keynote-benchmarks",
4443
"modules/perf-test",
@@ -143,7 +142,6 @@ spacetimedb-schema = { path = "crates/schema", version = "=2.0.5" }
143142
spacetimedb-standalone = { path = "crates/standalone", version = "=2.0.5" }
144143
spacetimedb-sql-parser = { path = "crates/sql-parser", version = "=2.0.5" }
145144
spacetimedb-table = { path = "crates/table", version = "=2.0.5" }
146-
spacetimedb-vm = { path = "crates/vm", version = "=2.0.5" }
147145
spacetimedb-fs-utils = { path = "crates/fs-utils", version = "=2.0.5" }
148146
spacetimedb-snapshot = { path = "crates/snapshot", version = "=2.0.5" }
149147
spacetimedb-subscription = { path = "crates/subscription", version = "=2.0.5" }
@@ -245,7 +243,7 @@ paste = "1.0"
245243
percent-encoding = "2.3"
246244
petgraph = { version = "0.6.5", default-features = false }
247245
pin-project-lite = "0.2.9"
248-
pgwire = { version = "0.34.2", default-features = false, features = ["server-api", "pg-ext-types"] }
246+
pgwire = { version = "0.37", default-features = false, features = ["server-api", "pg-ext-types"] }
249247
postgres-types = "0.2.5"
250248
pretty_assertions = { version = "1.4", features = ["unstable"] }
251249
proc-macro2 = "1.0"

crates/bench/benches/subscription.rs

Lines changed: 5 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,19 @@ use criterion::{black_box, criterion_group, criterion_main, Criterion};
22
use spacetimedb::client::consume_each_list::ConsumeEachBuffer;
33
use spacetimedb::db::relational_db::RelationalDB;
44
use spacetimedb::error::DBError;
5-
use spacetimedb::host::module_host::DatabaseTableUpdate;
65
use spacetimedb::identity::AuthCtx;
76
use spacetimedb::sql::ast::SchemaViewer;
8-
use spacetimedb::subscription::query::compile_read_only_queryset;
97
use spacetimedb::subscription::row_list_builder_pool::BsatnRowListBuilderPool;
10-
use spacetimedb::subscription::subscription::ExecutionSet;
118
use spacetimedb::subscription::tx::DeltaTx;
129
use spacetimedb::subscription::{collect_table_update, TableUpdateType};
1310
use spacetimedb_bench::database::BenchDatabase as _;
1411
use spacetimedb_bench::spacetime_raw::SpacetimeRaw;
15-
use spacetimedb_client_api_messages::websocket::v1::{BsatnFormat, Compression};
12+
use spacetimedb_client_api_messages::websocket::v1::BsatnFormat;
1613
use spacetimedb_datastore::execution_context::Workload;
1714
use spacetimedb_execution::pipelined::PipelinedProject;
1815
use spacetimedb_primitives::{col_list, TableId};
1916
use spacetimedb_query::compile_subscription;
20-
use spacetimedb_sats::{bsatn, product, AlgebraicType, AlgebraicValue, ProductValue};
21-
22-
use spacetimedb_schema::table_name::TableName;
17+
use spacetimedb_sats::{bsatn, product, AlgebraicType, AlgebraicValue};
2318
#[cfg(not(target_env = "msvc"))]
2419
use tikv_jemallocator::Jemalloc;
2520

@@ -52,15 +47,6 @@ fn create_table_footprint(db: &RelationalDB) -> Result<TableId, DBError> {
5247
db.create_table_for_test("footprint", schema, indexes)
5348
}
5449

55-
fn insert_op(table_id: TableId, table_name: &str, row: ProductValue) -> DatabaseTableUpdate {
56-
DatabaseTableUpdate {
57-
table_id,
58-
table_name: TableName::for_test(table_name),
59-
inserts: [row].into(),
60-
deletes: [].into(),
61-
}
62-
}
63-
6450
fn eval(c: &mut Criterion) {
6551
let raw = SpacetimeRaw::build(false).unwrap();
6652

@@ -115,16 +101,12 @@ fn eval(c: &mut Criterion) {
115101
let footprint = AlgebraicValue::sum(1, AlgebraicValue::unit());
116102
let owner = 6u64;
117103

118-
let new_lhs_row = product!(entity_id, owner, footprint);
119-
let new_rhs_row = product!(entity_id, chunk_index, x, z, dimension);
120-
121-
let ins_lhs = insert_op(lhs, "footprint", new_lhs_row);
122-
let ins_rhs = insert_op(rhs, "location", new_rhs_row);
123-
let update = [&ins_lhs, &ins_rhs];
104+
let _new_lhs_row = product!(entity_id, owner, footprint);
105+
let _new_rhs_row = product!(entity_id, chunk_index, x, z, dimension);
124106

125107
let bsatn_rlb_pool = black_box(BsatnRowListBuilderPool::new());
126108

127-
// A benchmark runner for the new query engine
109+
// A benchmark runner for the subscription engine.
128110
let bench_query = |c: &mut Criterion, name, sql| {
129111
c.bench_function(name, |b| {
130112
let tx = raw.db.begin_tx(Workload::Subscribe);
@@ -154,20 +136,6 @@ fn eval(c: &mut Criterion) {
154136
});
155137
};
156138

157-
let bench_eval = |c: &mut Criterion, name, sql| {
158-
c.bench_function(name, |b| {
159-
let tx = raw.db.begin_tx(Workload::Update);
160-
let query = compile_read_only_queryset(&raw.db, &AuthCtx::for_testing(), &tx, sql).unwrap();
161-
let query: ExecutionSet = query.into();
162-
163-
b.iter(|| {
164-
let updates =
165-
black_box(query.eval::<BsatnFormat>(&raw.db, &tx, &bsatn_rlb_pool, None, Compression::None));
166-
updates.consume_each_list(&mut |buffer| bsatn_rlb_pool.try_put(buffer));
167-
})
168-
});
169-
};
170-
171139
// Join 1M rows on the left with 12K rows on the right.
172140
// Note, this should use an index join so as not to read the entire footprint table.
173141
let semijoin = format!(
@@ -183,66 +151,6 @@ fn eval(c: &mut Criterion) {
183151
bench_query(c, "footprint-scan", "select * from footprint");
184152
bench_query(c, "footprint-semijoin", &semijoin);
185153
bench_query(c, "index-scan-multi", index_scan_multi);
186-
187-
// To profile this benchmark for 30s
188-
// samply record -r 10000000 cargo bench --bench=subscription --profile=profiling -- full-scan --exact --profile-time=30
189-
// Iterate 1M rows.
190-
bench_eval(c, "full-scan", "select * from footprint");
191-
192-
// To profile this benchmark for 30s
193-
// samply record -r 10000000 cargo bench --bench=subscription --profile=profiling -- full-join --exact --profile-time=30
194-
// Join 1M rows on the left with 12K rows on the right.
195-
// Note, this should use an index join so as not to read the entire footprint table.
196-
let name = format!(
197-
r#"
198-
select footprint.*
199-
from footprint join location on footprint.entity_id = location.entity_id
200-
where location.chunk_index = {chunk_index}
201-
"#
202-
);
203-
bench_eval(c, "full-join", &name);
204-
205-
// To profile this benchmark for 30s
206-
// samply record -r 10000000 cargo bench --bench=subscription --profile=profiling -- incr-select --exact --profile-time=30
207-
c.bench_function("incr-select", |b| {
208-
// A passthru executed independently of the database.
209-
let select_lhs = "select * from footprint";
210-
let select_rhs = "select * from location";
211-
let tx = &raw.db.begin_tx(Workload::Update);
212-
let query_lhs = compile_read_only_queryset(&raw.db, &AuthCtx::for_testing(), tx, select_lhs).unwrap();
213-
let query_rhs = compile_read_only_queryset(&raw.db, &AuthCtx::for_testing(), tx, select_rhs).unwrap();
214-
let query = ExecutionSet::from_iter(query_lhs.into_iter().chain(query_rhs));
215-
let tx = &tx.into();
216-
217-
b.iter(|| drop(black_box(query.eval_incr_for_test(&raw.db, tx, &update, None))))
218-
});
219-
220-
// To profile this benchmark for 30s
221-
// samply record -r 10000000 cargo bench --bench=subscription --profile=profiling -- incr-join --exact --profile-time=30
222-
c.bench_function("incr-join", |b| {
223-
// Not a passthru - requires reading of database state.
224-
let join = format!(
225-
"\
226-
select footprint.* \
227-
from footprint join location on footprint.entity_id = location.entity_id \
228-
where location.chunk_index = {chunk_index}"
229-
);
230-
let tx = &raw.db.begin_tx(Workload::Update);
231-
let query = compile_read_only_queryset(&raw.db, &AuthCtx::for_testing(), tx, &join).unwrap();
232-
let query: ExecutionSet = query.into();
233-
let tx = &tx.into();
234-
235-
b.iter(|| drop(black_box(query.eval_incr_for_test(&raw.db, tx, &update, None))));
236-
});
237-
238-
// To profile this benchmark for 30s
239-
// samply record -r 10000000 cargo bench --bench=subscription --profile=profiling -- query-indexes-multi --exact --profile-time=30
240-
// Iterate 1M rows.
241-
bench_eval(
242-
c,
243-
"query-indexes-multi",
244-
"select * from location WHERE x = 0 AND z = 10000 AND dimension = 0",
245-
);
246154
}
247155

248156
criterion_group!(benches, eval);

0 commit comments

Comments
 (0)