Fix large table issues #179
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of Changes
Changes were made to handle large data table changes. Changes and why they were made are outlined in this discord chat.
https://discord.com/channels/1037340874172014652/1363015282381033613/1363972150922444935
Main changes are modifying the applyTableUpdates and applyOperations to handle larger row counts. Currently a million rows will completely fail in the sdk. This is due to a bug causing a stack overflow & the OperationMap having very poor performance characteristics.
I fixed this by not allocating all the pendingCallbacks on the stack and changing the applyOperations to use a normal Map rather than the OperationMap which uses an internal list for its data structure.
To make complex keys compatible with a normal map I introduced the
toPrimaryKey
on complex key types like connectionId and Identity. This converts them to a hashable format and allows them to pas all existing tests.API
This changes no interface so should not be a breaking change. It has been tested with all key types as far as I can tell so do not believe it should break any underlying functionality.
Requires SpacetimeDB PRs
This is the only PR required.
Testing
I compiled this code and tested it in my app for testing and it worked great.
https://github.com/ChaseLewis/place-rs
I also ran all existing automated testing which it passed locally on my machine.