Skip to content

Commit

Permalink
client-api: Fix publish error reporting (#1750)
Browse files Browse the repository at this point in the history
  • Loading branch information
kim authored Sep 27, 2024
1 parent dd699c4 commit 1e31b23
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions crates/client-api/src/routes/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -754,8 +754,20 @@ pub async fn publish<S: NodeDelegate + ControlStateDelegate>(
.await
.map_err(log_and_500)?;

if let Some(UpdateDatabaseResult::AutoMigrateError(errs)) = maybe_updated {
return Err((StatusCode::BAD_REQUEST, format!("Database update rejected: {errs}")).into());
if let Some(updated) = maybe_updated {
match updated {
UpdateDatabaseResult::AutoMigrateError(errs) => {
return Err((StatusCode::BAD_REQUEST, format!("Database update rejected: {errs}")).into());
}
UpdateDatabaseResult::ErrorExecutingMigration(err) => {
return Err((
StatusCode::BAD_REQUEST,
format!("Failed to create or update the database: {err}"),
)
.into());
}
UpdateDatabaseResult::NoUpdateNeeded | UpdateDatabaseResult::UpdatePerformed => {}
}
}

Ok(axum::Json(PublishResult::Success {
Expand Down

2 comments on commit 1e31b23

@github-actions
Copy link

@github-actions github-actions bot commented on 1e31b23 Sep 27, 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 💿 417.8±2.63ns 430.2±2.24ns - -
sqlite 🧠 408.8±1.96ns 421.1±5.65ns - -
stdb_raw 💿 625.6±0.68ns 618.7±0.58ns - -
stdb_raw 🧠 625.7±0.68ns 618.5±0.25ns - -

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 587.8±1.05µs 580.7±1.45µs 1701 tx/sec 1721 tx/sec
sqlite 💿 u32_u64_str unique_0 2048 256 154.1±9.47µs 146.4±0.46µs 6.3 Ktx/sec 6.7 Ktx/sec
sqlite 💿 u32_u64_u64 btree_each_column 2048 256 466.3±0.62µs 461.6±0.55µs 2.1 Ktx/sec 2.1 Ktx/sec
sqlite 💿 u32_u64_u64 unique_0 2048 256 133.5±0.55µs 132.3±0.74µs 7.3 Ktx/sec 7.4 Ktx/sec
sqlite 🧠 u32_u64_str btree_each_column 2048 256 449.8±0.51µs 441.2±0.48µs 2.2 Ktx/sec 2.2 Ktx/sec
sqlite 🧠 u32_u64_str unique_0 2048 256 122.6±1.45µs 121.0±0.50µs 8.0 Ktx/sec 8.1 Ktx/sec
sqlite 🧠 u32_u64_u64 btree_each_column 2048 256 364.0±0.89µs 363.0±1.29µs 2.7 Ktx/sec 2.7 Ktx/sec
sqlite 🧠 u32_u64_u64 unique_0 2048 256 103.0±0.69µs 103.9±0.26µs 9.5 Ktx/sec 9.4 Ktx/sec
stdb_raw 💿 u32_u64_str btree_each_column 2048 256 579.4±31.29µs 594.7±26.69µs 1725 tx/sec 1681 tx/sec
stdb_raw 💿 u32_u64_str unique_0 2048 256 492.4±26.05µs 504.4±26.33µs 2030 tx/sec 1982 tx/sec
stdb_raw 💿 u32_u64_u64 btree_each_column 2048 256 379.3±8.15µs 336.7±4.60µs 2.6 Ktx/sec 2.9 Ktx/sec
stdb_raw 💿 u32_u64_u64 unique_0 2048 256 350.8±13.10µs 356.4±5.35µs 2.8 Ktx/sec 2.7 Ktx/sec
stdb_raw 🧠 u32_u64_str btree_each_column 2048 256 313.0±0.89µs 310.9±0.38µs 3.1 Ktx/sec 3.1 Ktx/sec
stdb_raw 🧠 u32_u64_str unique_0 2048 256 244.7±0.18µs 245.3±0.21µs 4.0 Ktx/sec 4.0 Ktx/sec
stdb_raw 🧠 u32_u64_u64 btree_each_column 2048 256 251.4±0.29µs 246.5±0.17µs 3.9 Ktx/sec 4.0 Ktx/sec
stdb_raw 🧠 u32_u64_u64 unique_0 2048 256 222.7±0.24µs 223.2±0.15µs 4.4 Ktx/sec 4.4 Ktx/sec

iterate

db on disk schema indices new latency old latency new throughput old throughput
sqlite 💿 u32_u64_str unique_0 20.8±0.16µs 21.9±0.28µs 47.0 Ktx/sec 44.5 Ktx/sec
sqlite 💿 u32_u64_u64 unique_0 20.1±0.05µs 20.4±0.14µs 48.7 Ktx/sec 48.0 Ktx/sec
sqlite 🧠 u32_u64_str unique_0 18.3±0.25µs 19.7±0.25µs 53.3 Ktx/sec 49.6 Ktx/sec
sqlite 🧠 u32_u64_u64 unique_0 17.6±0.06µs 17.9±0.14µs 55.6 Ktx/sec 54.7 Ktx/sec
stdb_raw 💿 u32_u64_str unique_0 4.7±0.00µs 3.8±0.00µs 206.9 Ktx/sec 257.2 Ktx/sec
stdb_raw 💿 u32_u64_u64 unique_0 4.6±0.00µs 3.7±0.00µs 211.1 Ktx/sec 264.4 Ktx/sec
stdb_raw 🧠 u32_u64_str unique_0 4.7±0.00µs 3.8±0.00µs 206.9 Ktx/sec 257.2 Ktx/sec
stdb_raw 🧠 u32_u64_u64 unique_0 4.6±0.00µs 3.7±0.00µs 211.0 Ktx/sec 264.4 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 66.6±0.14µs 67.3±0.23µs 14.7 Ktx/sec 14.5 Ktx/sec
sqlite 💿 u64 index 2048 256 65.5±0.12µs 64.8±0.26µs 14.9 Ktx/sec 15.1 Ktx/sec
sqlite 🧠 string index 2048 256 63.9±0.12µs 63.8±0.14µs 15.3 Ktx/sec 15.3 Ktx/sec
sqlite 🧠 u64 index 2048 256 59.9±0.05µs 59.6±0.10µs 16.3 Ktx/sec 16.4 Ktx/sec
stdb_raw 💿 string index 2048 256 4.8±0.00µs 4.9±0.00µs 202.2 Ktx/sec 199.2 Ktx/sec
stdb_raw 💿 u64 index 2048 256 4.8±0.00µs 4.8±0.00µs 205.1 Ktx/sec 202.3 Ktx/sec
stdb_raw 🧠 string index 2048 256 4.8±0.00µs 4.9±0.00µs 202.4 Ktx/sec 199.4 Ktx/sec
stdb_raw 🧠 u64 index 2048 256 4.8±0.00µs 4.8±0.00µs 205.3 Ktx/sec 202.1 Ktx/sec

serialize

schema format count new latency old latency new throughput old throughput
u32_u64_str bflatn_to_bsatn_fast_path 100 3.3±0.01µs 3.3±0.01µs 28.7 Mtx/sec 28.6 Mtx/sec
u32_u64_str bflatn_to_bsatn_slow_path 100 3.8±0.11µs 3.8±0.13µs 25.2 Mtx/sec 25.0 Mtx/sec
u32_u64_str bsatn 100 2.3±0.01µs 2.3±0.01µs 42.2 Mtx/sec 42.0 Mtx/sec
u32_u64_str bsatn 100 40.4±0.10ns 40.5±0.10ns 2.3 Gtx/sec 2.3 Gtx/sec
u32_u64_str json 100 4.8±0.02µs 4.9±0.03µs 19.9 Mtx/sec 19.4 Mtx/sec
u32_u64_str json 100 6.9±0.11µs 6.8±0.07µs 13.9 Mtx/sec 14.0 Mtx/sec
u32_u64_str product_value 100 1015.1±1.08ns 1014.3±0.68ns 93.9 Mtx/sec 94.0 Mtx/sec
u32_u64_u64 bflatn_to_bsatn_fast_path 100 1132.7±3.10ns 1145.1±13.57ns 84.2 Mtx/sec 83.3 Mtx/sec
u32_u64_u64 bflatn_to_bsatn_slow_path 100 2.8±0.01µs 2.8±0.00µs 34.4 Mtx/sec 34.3 Mtx/sec
u32_u64_u64 bsatn 100 1545.7±14.74ns 1542.4±11.47ns 61.7 Mtx/sec 61.8 Mtx/sec
u32_u64_u64 bsatn 100 39.3±0.04ns 39.4±0.07ns 2.4 Gtx/sec 2.4 Gtx/sec
u32_u64_u64 json 100 3.3±0.15µs 3.5±0.05µs 28.5 Mtx/sec 27.6 Mtx/sec
u32_u64_u64 json 100 4.8±0.03µs 4.7±0.00µs 20.0 Mtx/sec 20.1 Mtx/sec
u32_u64_u64 product_value 100 1013.7±1.16ns 1013.5±1.60ns 94.1 Mtx/sec 94.1 Mtx/sec
u64_u64_u32 bflatn_to_bsatn_fast_path 100 894.6±2.71ns 900.1±2.29ns 106.6 Mtx/sec 106.0 Mtx/sec
u64_u64_u32 bflatn_to_bsatn_slow_path 100 2.8±0.00µs 2.8±0.01µs 34.3 Mtx/sec 34.3 Mtx/sec
u64_u64_u32 bsatn 100 1542.4±8.83ns 1550.8±8.54ns 61.8 Mtx/sec 61.5 Mtx/sec
u64_u64_u32 bsatn 100 749.4±7.06ns 752.3±0.50ns 127.3 Mtx/sec 126.8 Mtx/sec
u64_u64_u32 json 100 3.6±0.03µs 3.5±0.03µs 26.3 Mtx/sec 27.1 Mtx/sec
u64_u64_u32 json 100 4.7±0.04µs 4.7±0.00µs 20.3 Mtx/sec 20.4 Mtx/sec
u64_u64_u32 product_value 100 1018.2±1.18ns 1025.9±0.48ns 93.7 Mtx/sec 93.0 Mtx/sec

stdb_module_large_arguments

arg size new latency old latency new throughput old throughput
64KiB 108.4±8.18µs 113.4±6.89µs - -

stdb_module_print_bulk

line count new latency old latency new throughput old throughput
1 55.3±5.69µs 53.2±4.14µs - -
100 606.6±4.59µs 605.8±9.47µs - -
1000 5.1±0.78ms 5.0±0.82ms - -

remaining

name new latency old latency new throughput old throughput
special/db_game/circles/load=10 272.6±3.13µs 279.4±5.90µs - -
special/db_game/circles/load=100 271.2±4.81µs 281.8±3.98µs - -
special/db_game/ia_loop/load=10 0.0±0.00ns 0.0±0.00ns - -
special/db_game/ia_loop/load=100 0.0±0.00ns 0.0±0.00ns - -
sqlite/💿/update_bulk/u32_u64_str/unique_0/load=2048/count=256 54.2±0.19µs 53.0±0.16µs 18.0 Ktx/sec 18.4 Ktx/sec
sqlite/💿/update_bulk/u32_u64_u64/unique_0/load=2048/count=256 46.5±0.06µs 49.7±13.98µs 21.0 Ktx/sec 19.6 Ktx/sec
sqlite/🧠/update_bulk/u32_u64_str/unique_0/load=2048/count=256 39.1±0.44µs 38.5±0.29µs 25.0 Ktx/sec 25.3 Ktx/sec
sqlite/🧠/update_bulk/u32_u64_u64/unique_0/load=2048/count=256 35.7±0.15µs 34.5±0.09µs 27.4 Ktx/sec 28.3 Ktx/sec
stdb_module/💿/update_bulk/u32_u64_str/unique_0/load=2048/count=256 1246.4±24.64µs 1229.8±15.52µs 802 tx/sec 813 tx/sec
stdb_module/💿/update_bulk/u32_u64_u64/unique_0/load=2048/count=256 988.0±13.00µs 977.5±3.39µs 1012 tx/sec 1023 tx/sec
stdb_raw/💿/update_bulk/u32_u64_str/unique_0/load=2048/count=256 626.4±23.69µs 642.6±19.11µs 1596 tx/sec 1556 tx/sec
stdb_raw/💿/update_bulk/u32_u64_u64/unique_0/load=2048/count=256 487.6±14.00µs 487.1±18.68µs 2.0 Ktx/sec 2.0 Ktx/sec
stdb_raw/🧠/update_bulk/u32_u64_str/unique_0/load=2048/count=256 378.6±0.97µs 377.5±0.37µs 2.6 Ktx/sec 2.6 Ktx/sec
stdb_raw/🧠/update_bulk/u32_u64_u64/unique_0/load=2048/count=256 336.3±0.49µs 339.1±1.66µs 2.9 Ktx/sec 2.9 Ktx/sec

@github-actions
Copy link

@github-actions github-actions bot commented on 1e31b23 Sep 27, 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 5409 5409 0.00% 5569 5569 0.00%
sqlite 5555 5555 0.00% 5971 5971 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 2 string 117832 117811 0.02% 118548 118623 -0.06%
stdb_raw u32_u64_str no_index 64 128 1 u64 75399 75399 0.00% 76069 76061 0.01%
stdb_raw u32_u64_str btree_each_column 64 128 2 string 24068 24068 0.00% 24636 24644 -0.03%
stdb_raw u32_u64_str btree_each_column 64 128 1 u64 23035 23035 0.00% 23577 23577 0.00%
sqlite u32_u64_str no_index 64 128 2 string 144677 144677 0.00% 146087 146091 -0.00%
sqlite u32_u64_str no_index 64 128 1 u64 124026 124026 0.00% 125234 125234 0.00%
sqlite u32_u64_str btree_each_column 64 128 2 string 134494 134476 0.01% 136084 136066 0.01%
sqlite u32_u64_str btree_each_column 64 128 1 u64 131343 131343 0.00% 132831 132835 -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 902752 901857 0.10% 958002 956991 0.11%
stdb_raw u32_u64_str btree_each_column 64 128 1056772 1053738 0.29% 1097812 1095240 0.23%
sqlite u32_u64_str unique_0 64 128 398292 398292 0.00% 415568 415560 0.00%
sqlite u32_u64_str btree_each_column 64 128 983609 983627 -0.00% 1023511 1023533 -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 152695 152695 0.00% 152853 152853 0.00%
stdb_raw u32_u64_str unique_0 64 15720 15720 0.00% 15878 15870 0.05%
sqlite u32_u64_str unique_0 1024 1068223 1068223 0.00% 1071623 1071623 0.00%
sqlite u32_u64_str unique_0 64 76209 76209 0.00% 77331 77331 0.00%

callgrind: serialize_product_value

count format total reads + writes old total reads + writes Δrw estimated cycles old estimated cycles Δcycles
64 json 47118 47118 0.00% 49804 49804 0.00%
64 bsatn 25716 25716 0.00% 27994 27994 0.00%
16 json 12062 12062 0.00% 14000 14000 0.00%
16 bsatn 8117 8117 0.00% 9511 9511 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 20714193 20673127 0.20% 21464241 21427101 0.17%
stdb_raw u32_u64_str unique_0 64 128 1307357 1307218 0.01% 1359219 1390338 -2.24%
sqlite u32_u64_str unique_0 1024 1024 1802091 1802091 0.00% 1811253 1811253 0.00%
sqlite u32_u64_str unique_0 64 128 128437 128437 0.00% 131263 131263 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 5419 5419 0.00% 5583 5583 0.00%
sqlite 5603 5603 0.00% 6193 6193 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 2 string 117821 117821 0.00% 118581 118609 -0.02%
stdb_raw u32_u64_str no_index 64 128 1 u64 75409 75409 0.00% 76067 76091 -0.03%
stdb_raw u32_u64_str btree_each_column 64 128 2 string 24079 24078 0.00% 24643 24674 -0.13%
stdb_raw u32_u64_str btree_each_column 64 128 1 u64 23045 23045 0.00% 23603 23579 0.10%
sqlite u32_u64_str no_index 64 128 2 string 146598 146598 0.00% 148332 148332 0.00%
sqlite u32_u64_str no_index 64 128 1 u64 125947 125947 0.00% 127535 127539 -0.00%
sqlite u32_u64_str btree_each_column 64 128 2 string 136598 136598 0.00% 138674 138678 -0.00%
sqlite u32_u64_str btree_each_column 64 128 1 u64 133439 133445 -0.00% 135265 135271 -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 851804 852089 -0.03% 906228 906465 -0.03%
stdb_raw u32_u64_str btree_each_column 64 128 1004541 1004152 0.04% 1076947 1076568 0.04%
sqlite u32_u64_str unique_0 64 128 415829 415829 0.00% 432339 432343 -0.00%
sqlite u32_u64_str btree_each_column 64 128 1021870 1021870 0.00% 1060852 1060848 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 152705 152705 0.00% 152855 152855 0.00%
stdb_raw u32_u64_str unique_0 64 15730 15730 0.00% 15880 15880 0.00%
sqlite u32_u64_str unique_0 1024 1071291 1071291 0.00% 1075081 1075081 0.00%
sqlite u32_u64_str unique_0 64 77981 77981 0.00% 79375 79375 0.00%

callgrind: serialize_product_value

count format total reads + writes old total reads + writes Δrw estimated cycles old estimated cycles Δcycles
64 json 47118 47118 0.00% 49804 49804 0.00%
64 bsatn 25716 25716 0.00% 27994 27994 0.00%
16 json 12062 12062 0.00% 14000 14000 0.00%
16 bsatn 8117 8117 0.00% 9511 9511 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 19417210 19414188 0.02% 20233794 20230432 0.02%
stdb_raw u32_u64_str unique_0 64 128 1259757 1259747 0.00% 1341037 1341069 -0.00%
sqlite u32_u64_str unique_0 1024 1024 1809652 1809652 0.00% 1818254 1818254 0.00%
sqlite u32_u64_str unique_0 64 128 132563 132563 0.00% 135525 135525 0.00%

Please sign in to comment.