Skip to content

Commit

Permalink
[C#] Fix table view names and duplicate table registration (#1757)
Browse files Browse the repository at this point in the history
  • Loading branch information
RReverser authored Sep 30, 2024
1 parent b7d2e3d commit 37ac4a4
Show file tree
Hide file tree
Showing 15 changed files with 348 additions and 92 deletions.

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

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

22 changes: 22 additions & 0 deletions crates/bindings-csharp/Codegen.Tests/fixtures/server/Lib.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,25 @@ public static void Init(ReducerContext ctx)
);
}
}

[Table(Name = "MultiTable1", Public = true)]
[Table(Name = "MultiTable2")]
public partial struct MultiTableRow
{
public string Name;

[AutoInc]
[PrimaryKey(Table = "MultiTable1")]
public uint Foo;

[Unique(Table = "MultiTable2")]
public uint Bar;

[SpacetimeDB.Reducer]
public static void InsertMultiData(ReducerContext ctx, MultiTableRow data)
{
// Verify that we have both tables generated on the context.
ctx.Db.MultiTable1.Insert(data);
ctx.Db.MultiTable2.Insert(data);
}
}

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

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

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

Loading

2 comments on commit 37ac4a4

@github-actions
Copy link

@github-actions github-actions bot commented on 37ac4a4 Sep 30, 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.6±2.58ns 426.0±3.25ns - -
sqlite 🧠 413.0±6.41ns 420.2±3.53ns - -
stdb_raw 💿 624.5±3.45ns 632.8±3.72ns - -
stdb_raw 🧠 623.9±0.93ns 632.4±0.65ns - -

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 580.3±0.84µs 584.0±0.76µs 1723 tx/sec 1712 tx/sec
sqlite 💿 u32_u64_str unique_0 2048 256 149.8±0.36µs 151.0±0.96µs 6.5 Ktx/sec 6.5 Ktx/sec
sqlite 💿 u32_u64_u64 btree_each_column 2048 256 460.4±0.74µs 464.0±0.63µs 2.1 Ktx/sec 2.1 Ktx/sec
sqlite 💿 u32_u64_u64 unique_0 2048 256 137.6±1.63µs 138.2±1.67µs 7.1 Ktx/sec 7.1 Ktx/sec
sqlite 🧠 u32_u64_str btree_each_column 2048 256 441.8±0.72µs 444.5±0.59µs 2.2 Ktx/sec 2.2 Ktx/sec
sqlite 🧠 u32_u64_str unique_0 2048 256 121.2±0.76µs 124.6±0.39µs 8.1 Ktx/sec 7.8 Ktx/sec
sqlite 🧠 u32_u64_u64 btree_each_column 2048 256 358.5±0.47µs 361.5±1.05µs 2.7 Ktx/sec 2.7 Ktx/sec
sqlite 🧠 u32_u64_u64 unique_0 2048 256 106.0±0.62µs 108.3±0.55µs 9.2 Ktx/sec 9.0 Ktx/sec
stdb_raw 💿 u32_u64_str btree_each_column 2048 256 646.2±19.90µs 601.8±14.03µs 1547 tx/sec 1661 tx/sec
stdb_raw 💿 u32_u64_str unique_0 2048 256 502.7±22.67µs 412.8±13.87µs 1989 tx/sec 2.4 Ktx/sec
stdb_raw 💿 u32_u64_u64 btree_each_column 2048 256 335.9±5.56µs 399.2±4.42µs 2.9 Ktx/sec 2.4 Ktx/sec
stdb_raw 💿 u32_u64_u64 unique_0 2048 256 353.1±6.95µs 354.1±8.86µs 2.8 Ktx/sec 2.8 Ktx/sec
stdb_raw 🧠 u32_u64_str btree_each_column 2048 256 310.8±1.69µs 318.8±0.19µs 3.1 Ktx/sec 3.1 Ktx/sec
stdb_raw 🧠 u32_u64_str unique_0 2048 256 239.3±0.23µs 248.9±0.33µs 4.1 Ktx/sec 3.9 Ktx/sec
stdb_raw 🧠 u32_u64_u64 btree_each_column 2048 256 250.3±0.17µs 252.5±0.19µs 3.9 Ktx/sec 3.9 Ktx/sec
stdb_raw 🧠 u32_u64_u64 unique_0 2048 256 222.3±0.24µs 222.9±0.12µ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 23.5±0.17µs 23.1±0.16µs 41.6 Ktx/sec 42.2 Ktx/sec
sqlite 💿 u32_u64_u64 unique_0 22.3±0.19µs 22.5±0.25µs 43.9 Ktx/sec 43.4 Ktx/sec
sqlite 🧠 u32_u64_str unique_0 20.9±0.21µs 20.7±0.16µs 46.6 Ktx/sec 47.3 Ktx/sec
sqlite 🧠 u32_u64_u64 unique_0 19.6±0.16µs 19.7±0.17µs 49.8 Ktx/sec 49.6 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.6 Ktx/sec 263.4 Ktx/sec
stdb_raw 🧠 u32_u64_str unique_0 4.7±0.00µs 3.8±0.01µs 207.0 Ktx/sec 257.2 Ktx/sec
stdb_raw 🧠 u32_u64_u64 unique_0 4.6±0.00µs 3.7±0.00µs 211.5 Ktx/sec 263.7 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 69.2±0.12µs 70.5±0.20µs 14.1 Ktx/sec 13.8 Ktx/sec
sqlite 💿 u64 index 2048 256 67.5±0.15µs 68.2±0.10µs 14.5 Ktx/sec 14.3 Ktx/sec
sqlite 🧠 string index 2048 256 65.3±0.16µs 65.9±0.23µs 15.0 Ktx/sec 14.8 Ktx/sec
sqlite 🧠 u64 index 2048 256 61.7±0.09µs 62.1±0.14µs 15.8 Ktx/sec 15.7 Ktx/sec
stdb_raw 💿 string index 2048 256 4.8±0.00µs 5.0±0.00µs 202.4 Ktx/sec 194.9 Ktx/sec
stdb_raw 💿 u64 index 2048 256 4.7±0.00µs 4.9±0.00µs 205.8 Ktx/sec 198.0 Ktx/sec
stdb_raw 🧠 string index 2048 256 4.8±0.00µs 5.0±0.00µs 202.3 Ktx/sec 194.9 Ktx/sec
stdb_raw 🧠 u64 index 2048 256 4.7±0.00µs 4.9±0.00µs 205.8 Ktx/sec 197.6 Ktx/sec

serialize

schema format count new latency old latency new throughput old throughput
u32_u64_str bflatn_to_bsatn_fast_path 100 3.4±0.06µs 3.4±0.03µs 27.8 Mtx/sec 28.4 Mtx/sec
u32_u64_str bflatn_to_bsatn_slow_path 100 3.4±0.00µs 3.4±0.00µs 27.9 Mtx/sec 27.9 Mtx/sec
u32_u64_str bsatn 100 2.4±0.02µs 2.4±0.02µs 39.9 Mtx/sec 39.7 Mtx/sec
u32_u64_str bsatn 100 40.4±0.09ns 40.4±0.10ns 2.3 Gtx/sec 2.3 Gtx/sec
u32_u64_str json 100 4.7±0.04µs 5.0±0.07µs 20.1 Mtx/sec 19.2 Mtx/sec
u32_u64_str json 100 6.8±0.04µs 6.7±0.04µs 14.1 Mtx/sec 14.2 Mtx/sec
u32_u64_str product_value 100 1016.0±0.71ns 1015.0±0.84ns 93.9 Mtx/sec 94.0 Mtx/sec
u32_u64_u64 bflatn_to_bsatn_fast_path 100 1142.2±14.99ns 1144.8±6.32ns 83.5 Mtx/sec 83.3 Mtx/sec
u32_u64_u64 bflatn_to_bsatn_slow_path 100 2.8±0.04µs 2.8±0.01µs 34.3 Mtx/sec 34.3 Mtx/sec
u32_u64_u64 bsatn 100 1751.5±33.98ns 1766.2±34.79ns 54.5 Mtx/sec 54.0 Mtx/sec
u32_u64_u64 bsatn 100 39.4±0.04ns 39.3±0.05ns 2.4 Gtx/sec 2.4 Gtx/sec
u32_u64_u64 json 100 3.2±0.04µs 3.3±0.09µs 29.8 Mtx/sec 28.7 Mtx/sec
u32_u64_u64 json 100 4.5±0.32µs 4.3±0.07µs 21.0 Mtx/sec 22.0 Mtx/sec
u32_u64_u64 product_value 100 1013.8±1.40ns 1013.2±1.41ns 94.1 Mtx/sec 94.1 Mtx/sec
u64_u64_u32 bflatn_to_bsatn_fast_path 100 904.8±1.56ns 905.7±2.39ns 105.4 Mtx/sec 105.3 Mtx/sec
u64_u64_u32 bflatn_to_bsatn_slow_path 100 2.8±0.00µs 2.8±0.00µs 34.1 Mtx/sec 34.0 Mtx/sec
u64_u64_u32 bsatn 100 1780.1±29.16ns 1754.9±33.30ns 53.6 Mtx/sec 54.3 Mtx/sec
u64_u64_u32 bsatn 100 751.6±0.46ns 751.5±0.33ns 126.9 Mtx/sec 126.9 Mtx/sec
u64_u64_u32 json 100 3.1±0.02µs 3.4±0.04µs 30.8 Mtx/sec 27.8 Mtx/sec
u64_u64_u32 json 100 4.5±0.00µs 4.6±0.05µs 21.4 Mtx/sec 21.0 Mtx/sec
u64_u64_u32 product_value 100 1015.2±0.53ns 1015.9±0.49ns 93.9 Mtx/sec 93.9 Mtx/sec

stdb_module_large_arguments

arg size new latency old latency new throughput old throughput
64KiB 110.0±8.03µs 115.4±9.07µs - -

stdb_module_print_bulk

line count new latency old latency new throughput old throughput
1 52.2±7.14µs 56.3±7.61µs - -
100 600.2±4.54µs 594.2±3.62µs - -
1000 4.2±0.83ms 5.3±0.03ms - -

remaining

name new latency old latency new throughput old throughput
special/db_game/circles/load=10 290.3±2.26µs 289.1±2.10µs - -
special/db_game/circles/load=100 289.6±3.01µs 287.8±1.67µ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 53.7±0.29µs 54.4±0.49µs 18.2 Ktx/sec 18.0 Ktx/sec
sqlite/💿/update_bulk/u32_u64_u64/unique_0/load=2048/count=256 46.4±0.13µs 48.0±0.16µs 21.1 Ktx/sec 20.4 Ktx/sec
sqlite/🧠/update_bulk/u32_u64_str/unique_0/load=2048/count=256 39.1±0.12µs 39.6±0.16µs 25.0 Ktx/sec 24.7 Ktx/sec
sqlite/🧠/update_bulk/u32_u64_u64/unique_0/load=2048/count=256 35.4±0.08µs 36.4±0.20µs 27.6 Ktx/sec 26.8 Ktx/sec
stdb_module/💿/update_bulk/u32_u64_str/unique_0/load=2048/count=256 1271.9±16.36µs 1250.0±13.45µs 786 tx/sec 799 tx/sec
stdb_module/💿/update_bulk/u32_u64_u64/unique_0/load=2048/count=256 1006.5±12.31µs 984.7±10.49µs 993 tx/sec 1015 tx/sec
stdb_raw/💿/update_bulk/u32_u64_str/unique_0/load=2048/count=256 533.1±34.54µs 548.7±16.41µs 1875 tx/sec 1822 tx/sec
stdb_raw/💿/update_bulk/u32_u64_u64/unique_0/load=2048/count=256 488.0±6.85µs 503.0±7.49µs 2.0 Ktx/sec 1987 tx/sec
stdb_raw/🧠/update_bulk/u32_u64_str/unique_0/load=2048/count=256 370.6±0.31µs 380.5±0.20µs 2.6 Ktx/sec 2.6 Ktx/sec
stdb_raw/🧠/update_bulk/u32_u64_u64/unique_0/load=2048/count=256 338.4±0.71µs 341.0±0.57µs 2.9 Ktx/sec 2.9 Ktx/sec

@github-actions
Copy link

@github-actions github-actions bot commented on 37ac4a4 Sep 30, 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 5395 5395 0.00% 5471 5471 0.00%
sqlite 5555 5555 0.00% 6043 6043 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 117797 117797 0.00% 118193 118257 -0.05%
stdb_raw u32_u64_str no_index 64 128 1 u64 75385 75385 0.00% 75663 75659 0.01%
stdb_raw u32_u64_str btree_each_column 64 128 2 string 24067 24055 0.05% 24439 24431 0.03%
stdb_raw u32_u64_str btree_each_column 64 128 1 u64 23021 23021 0.00% 23399 23395 0.02%
sqlite u32_u64_str no_index 64 128 2 string 144677 144677 0.00% 146211 146211 0.00%
sqlite u32_u64_str no_index 64 128 1 u64 124026 124026 0.00% 125346 125342 0.00%
sqlite u32_u64_str btree_each_column 64 128 2 string 134476 134476 0.00% 136126 136134 -0.01%
sqlite u32_u64_str btree_each_column 64 128 1 u64 131343 131343 0.00% 132863 132871 -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 902184 902562 -0.04% 953790 954370 -0.06%
stdb_raw u32_u64_str btree_each_column 64 128 1053682 1053713 -0.00% 1118860 1087961 2.84%
sqlite u32_u64_str unique_0 64 128 398292 398292 0.00% 414900 414904 -0.00%
sqlite u32_u64_str btree_each_column 64 128 983609 983609 0.00% 1020467 1020467 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 152681 152681 0.00% 152719 152719 0.00%
stdb_raw u32_u64_str unique_0 64 15706 15706 0.00% 15748 15744 0.03%
sqlite u32_u64_str unique_0 1024 1068223 1068241 -0.00% 1071583 1071621 -0.00%
sqlite u32_u64_str unique_0 64 76209 76227 -0.02% 77251 77269 -0.02%

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% 28028 28028 0.00%
16 json 12062 12062 0.00% 14000 14000 0.00%
16 bsatn 8117 8117 0.00% 9545 9545 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 20713844 20713407 0.00% 21521712 21521563 0.00%
stdb_raw u32_u64_str unique_0 64 128 1307227 1307457 -0.02% 1362459 1362769 -0.02%
sqlite u32_u64_str unique_0 1024 1024 1802091 1802091 0.00% 1811427 1811427 0.00%
sqlite u32_u64_str unique_0 64 128 128437 128437 0.00% 131167 131167 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 5405 5405 0.00% 5485 5485 0.00%
sqlite 5613 5613 0.00% 6213 6213 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 117807 117807 0.00% 118171 118143 0.02%
stdb_raw u32_u64_str no_index 64 128 1 u64 75395 75395 0.00% 75665 75665 0.00%
stdb_raw u32_u64_str btree_each_column 64 128 2 string 24064 24065 -0.00% 24436 24437 -0.00%
stdb_raw u32_u64_str btree_each_column 64 128 1 u64 23031 23031 0.00% 23401 23401 0.00%
sqlite u32_u64_str no_index 64 128 2 string 146598 146598 0.00% 148472 148472 0.00%
sqlite u32_u64_str no_index 64 128 1 u64 125947 125947 0.00% 127687 127687 0.00%
sqlite u32_u64_str btree_each_column 64 128 2 string 136598 136598 0.00% 138798 138794 0.00%
sqlite u32_u64_str btree_each_column 64 128 1 u64 133439 133439 0.00% 135437 135433 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 852476 851964 0.06% 906052 905432 0.07%
stdb_raw u32_u64_str btree_each_column 64 128 1003844 1003640 0.02% 1069376 1069034 0.03%
sqlite u32_u64_str unique_0 64 128 415829 415829 0.00% 431707 431719 -0.00%
sqlite u32_u64_str btree_each_column 64 128 1021870 1021870 0.00% 1057902 1057894 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 152691 152691 0.00% 152725 152725 0.00%
stdb_raw u32_u64_str unique_0 64 15716 15716 0.00% 15750 15750 0.00%
sqlite u32_u64_str unique_0 1024 1071291 1071291 0.00% 1075037 1075037 0.00%
sqlite u32_u64_str unique_0 64 77981 77981 0.00% 79263 79263 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% 28028 28028 0.00%
16 json 12062 12062 0.00% 14000 14000 0.00%
16 bsatn 8117 8117 0.00% 9545 9545 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 19420945 19417858 0.02% 20315931 20310984 0.02%
stdb_raw u32_u64_str unique_0 64 128 1260320 1260316 0.00% 1346020 1346090 -0.01%
sqlite u32_u64_str unique_0 1024 1024 1809652 1809652 0.00% 1818240 1818240 0.00%
sqlite u32_u64_str unique_0 64 128 132563 132563 0.00% 135537 135537 0.00%

Please sign in to comment.