Commit Graph

3186 Commits

Author SHA1 Message Date
Mario Montoya f15a3be4ab Move optimizations from sql to vm (#484)
* Move optimizations from sql to vm

* Remove unused method
2023-10-30 11:46:02 -05:00
joshua-spacetime e12c26bedd perf(470): Add metrics for transaction cpu and elapsed time (#483)
Closes #470.
2023-10-28 03:21:14 +00:00
Ingvar Stepanyan 5f98d70da8 Fix wasm-opt for C# modules (#482) 2023-10-28 03:43:55 +01:00
joshua-spacetime 3c98b8d904 perf(468): Add metric counters for committed transactions and rollbacks (#478)
Closes #468.
2023-10-27 19:26:38 -07:00
joshua-spacetime 88952b3672 perf(473): Add db address label to reducer queue length (#489)
Closes #473.
2023-10-27 19:15:30 -07:00
joshua-spacetime feaba247d8 refactor(485): Label metrics with database address and reducer name (#486)
Fixes #485.

Previously we were labeling metrics with internal database and reducer IDs.
2023-10-27 17:42:47 -07:00
Noa 628dac120e Simplify/deabstract module_host_actor and wasmer_module (#417)
* Simplify/deabstract module_host_actor and wasmer_module

* DatabaseLogger doesn't need an external mutex
2023-10-27 15:53:55 -05:00
John Detter 3d37f1d07d Improved Clairity of CI Names (#455)
* Updated names, improved clarity

* Do not set latest by default

---------

Co-authored-by: John Detter <no-reply@boppygames.gg>
2023-10-27 13:27:56 -05:00
Noa cbbd998424 Fix benchmarks please 100% (#481) 2023-10-26 15:56:38 -04:00
Noa c34ace3b11 Ok NOW fix benchmarks please (#480) 2023-10-26 18:04:53 +00:00
Noa 3a1be087e0 Fix benchmarks please contributor check (#479) 2023-10-26 13:33:34 -04:00
John Detter 7f1b1565e6 Fix syntax highlighting (#10)
Co-authored-by: John Detter <no-reply@boppygames.gg>
2023-10-26 10:53:49 -05:00
Ingvar Stepanyan 6eff34b7d9 Fix C# generics support (#475) 2023-10-26 14:42:49 +00:00
Noa 427270c1b0 Use gh actions for benchmarks please (#464) 2023-10-25 23:36:09 -05:00
joshua-spacetime b9abfe2635 chore: Add _cumulative suffix to counter metrics (#474) 2023-10-26 00:52:06 +00:00
joshua-spacetime fce9477e81 perf(463): Add metric for the number of rows fetched from the database (#467)
Closes #463.

This metric is maintained by the datastore iterator.
It is written to the metric store when the iterator is dropped.
Only committed rows are counted.
2023-10-25 16:00:11 -07:00
joshua-spacetime 23b2e6c713 perf(461): Record metrics for rows [inserted|deleted] on commit (#462)
Closes #456.
Closes #461.

Define an execution context for database operations.
Store the database id in RelationalDB.
Record metrics for rows [inserted|deleted] on commit.
2023-10-25 15:28:26 -07:00
Kim Altintop cb32c83e37 core: Fix commit log concurrency
Previously, constructing the commit payload to append to the message log
was done without holding the lock on the latter. This meant that commits
could be written to the log out-of-order.

Indeed, this could be observed on deployed databases by virtue of
verifying the hash chain (the parent hash is computed in
`generate_commit`).

To fix this, the lock is now acquired immediately and held until the
message is written (and potentially fsync'ed).
2023-10-25 20:27:01 +02:00
Kim Altintop 3838c8965c vm: Make UPDATE actually update
Previously, an UPDATE statement would be the identity function. Fix this
by threading through the assignments (SET clause) and transforming the
rows matching the query.
2023-10-25 20:26:33 +02:00
Ingvar Stepanyan 17c3c12b4e Update C# docs for connect/disconnect (#9)
Update after the change in https://github.com/clockworklabs/SpacetimeDB/pull/309.
2023-10-25 11:53:25 +01:00
Noa bc54b735b5 Update/upgrade dependencies (#266)
* Update and dedup some deps

* Upgrade dependencies
2023-10-25 01:19:29 +01:00
Phoebe Goldman 60b77aeeb8 Fix "identity not yet recieved" intermittent failure in tests (#445)
This error turns out to have been a legitimate, albeit rare, race condition,
which could have (but apparently didn't) manifested in user code.

The cause, ultimately, was holding locks for too-short scopes
while initializing the connection.
It was possible for a new connection to receive and completely process
its `IdentityToken` message before calling `maybe_set_credentials`,
which would then clobber the received identity.

This is now fixed (hopefully) by holding the `CredentialStore` lock
for the duration of `BackgroundDbConnection::connect`.
Two other locks, on `ClientCache` and `ReducerCallbacks`,
are also newly held for the duration to avoid similar issues.

In addition, this commit adds a call to `disconnect` to the beginning of `connect`.
This will prevent pathological user code
which connects twice in a row without an intervening disconnect
from encountering bizarre errors
caused by the first connection's background workers staying active.

This commit also bumps the `RUST_LOG` env variable for the SDK test clients to `trace`,
and adds several trace-level logs to the SDK,
which were instrumental in pinning down the failure.
This does mean that log output of failed SDK tests will now be much noisier.
2023-10-23 17:15:37 -04:00
Noa b78ae84f30 Replace hex Strings with Identity/Address where applicable (#300) 2023-10-20 17:51:50 +00:00
Ingvar Stepanyan 0a55646773 Switch allocator to mimalloc for the DB CLI (#447) 2023-10-19 19:22:55 +00:00
Mazdak Farrokhzad c8f9a29e89 DataRef: borrow for great perf (#434)
* DataRef: borrow for great perf

* address review comments

* Optimize `drop_table`, `rename_table`, `delete_by_col_eq`, and `clear_table` (#436)

* optimize delete, drop, rename

* address review comments

* even less cloning

* more refactoring
2023-10-19 18:36:21 +00:00
Mazdak Farrokhzad cba518d90e Use newtypes ColId, TableId, IndexId, SequenceId everywhere (*) (#408)
* Use newtypes ColId, TableId, IndexId, SequenceId everywhere (*)

* Addressing some PR comments

---------

Co-authored-by: Mario Alejandro Montoya Cortés <mamcx@elmalabarista.com>
2023-10-19 11:18:50 -05:00
Kim Altintop 759a9eebf7 subscriptions: Inline incremental join design doc 2023-10-19 17:42:47 +02:00
Kim Altintop db457e13d3 subscriptions: Reject unsupported queries early
Instead of never returning any incremental updates, fail the subscribe
call for the client if the queries contain any unsupported ones.
2023-10-19 17:42:47 +02:00
Kim Altintop 2a1d4cfcd0 subscriptions: Add commentary for incremental join evaluation 2023-10-19 17:42:47 +02:00
Kim Altintop fca6cf3cb6 lib: Don't panic in RelValueRef::get (#450)
There is no guarantee that a named field is in the supplied table
header, nor that it is in the row. Panicking at this location can be
disastrous, while all call sites are inside Result already. So, return
Result.
2023-10-19 10:42:30 -05:00
Ingvar Stepanyan a817acbbe1 Switch rows to IndexMap (#448) 2023-10-18 23:08:59 +01:00
George Kulakowski 18bab3d04f Remove commented out code (#444)
This removes very unused, commented out code. One category is for
unused plumbing from the bindings towards the instance. The other
is a bit of unused performance instrumentation.
2023-10-18 16:58:01 +00:00
John Detter 5864bfa8d7 Version upgrade: v0.7.1-beta (#441)
Co-authored-by: John Detter <no-reply@boppygames.gg>
2023-10-17 16:57:36 -07:00
Noa ac24ff0205 Prometheus stuff (#301) 2023-10-17 20:45:15 +02:00
George Kulakowski b9bfe2c3bf Track time spent in each wasm instance env call (#427)
Additionally, this further tidies the interface between the
host and the wasm instance env. In particular, reducer calls
are explicitly started and stopped, and the wasm instance env
becomes responsible for its own instrumentation.
2023-10-17 09:30:10 -07:00
Kim Altintop 63ef6eb66b db: Swap order of fsync and provide error context 2023-10-17 18:04:50 +02:00
Kim Altintop f9157d8122 datastore: Panic with message on missing ODB object
This condition _should_ be impossible, but has been observed. In case of
future occurrence, print out the hash of the missing object.
2023-10-17 18:04:50 +02:00
Ingvar Stepanyan 4f901ab538 Optimise binaries with wasm-opt (#423) 2023-10-17 16:25:20 +01:00
Piotr Sarnacki e19099d882 Run docker build on tags too (#421) 2023-10-17 09:04:10 +02:00
Ingvar Stepanyan 469dff6e68 [ABI] Remove the special first element of iterator (#420) 2023-10-16 22:45:32 +01:00
james gilles a952b19e5b Improve benchmark result reporting (#357)
* Add script to summarize benchmark results

* Mess with github actions benchmark script

* Formatting fixes

* Comment

* Bring back commit comments, upload to DO Spaces

* Remove cache

We now have servers for benchmarks outside of GH infrastructure and
downloading cache takes way more time than its worth it

* base and head refs are not needed anymore

* Run benchmarks only on master

* Test a branch build

* Fix branch becnhmarks path

* test

* Run only on master again

---------

Signed-off-by: Piotr Sarnacki <drogus@gmail.com>
Co-authored-by: Piotr Sarnacki <drogus@gmail.com>
2023-10-16 22:52:27 +02:00
joshua-spacetime d9540b4807 test(430): Incremental evaluation for semijoins 2023-10-16 22:02:08 +02:00
joshua-spacetime 7ed14fc14c fix(430): Incremental evaluation for semijoins
Fixes #430.

For inserts, under set semantics:

The formula for incrementally evaluating a join before a transaction
has been applied is as follows

{A+ join B} U {A join B+} U {A+ join B+}

The formula for incrementally evaluating a join after a transaction
has been applied is as follows

{A+ join B} U {A join B+}

For deletes, under set semantics:

The formula for incrementally evaluating a join before a transaction
has been applied is as follows

{A- join B} U {A join B-}

The formula for incrementally evaluating a join after a transaction
has been applied is as follows

{A- join B} U {A join B-} U {A- join B-}

Note that SpacetimeDB is operating under the latter model.
Evaluation after the updates have already been applied to the underlying tables.
Therefore the 2nd and 4th formulas apply.
2023-10-16 22:02:08 +02:00
joshua-spacetime 529760d2dc refactor(430): Simplify classification by only considering index joins 2023-10-16 22:02:08 +02:00
Kim Altintop 1790b6ddd0 Implement incremental join query evaluation 2023-10-16 22:02:08 +02:00
Kim Altintop bea72986a2 Flatten subscription query into an actual set
Although semantically dubious, it is apparently legal to request a
subscription of the form:

    [
        "SELECT * FROM a",
        "SELECT * FROM b; SELECT * FROM a",
    ]

That is, sidestep the list type in the request by specifying multiple
SQL statements in a single string. We would previously keep a nested
list and not deduplicate equal queries.

With this change, the above is flattened to:

    [
        "SELECT * FROM a",
        "SELECT * FROM b",
    ]
2023-10-16 22:02:08 +02:00
Kim Altintop 2f98adcfe7 WIP: classify subscription queries 2023-10-16 22:02:08 +02:00
Kim Altintop 41f9fac19e Fix authorization check for CrudCode (#431)
* Fix authorization check for CrudCode

Make all mutating SQL operations require the caller to be the database
owner.

* Add auth check tests + ensure all tables in a join are considered
2023-10-16 12:35:11 -07:00
Ingvar Stepanyan 6715b4c429 Collect iterator into chunks early (#433) 2023-10-16 18:23:44 +00:00
Ingvar Stepanyan 7478e78c97 Reuse Wasm-side buffer while reading iterators (#435) 2023-10-16 18:10:39 +00:00