-
Notifications
You must be signed in to change notification settings - Fork 109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ABI] Remove the special first element of iterator #420
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
Yes, we used to expose out of the Rust bindings a non-strongly-typed iteration. I don't know if it was ever actually used, but I think for Chesteron's fence type reasons, someone should speak to why it was ok to remove but to leave the code commented out in the bindings: https://github.com/clockworklabs/SpacetimeDB/blob/master/crates/bindings/src/lib.rs#L272 and so on (and all the commented out code which used that, like the delete_filter etc functions). |
217979a
to
a7f3604
Compare
Rebased & fixed conflicts. |
I'm not sure why we're sending encoded schema as this special first element of iteration. There is some commented out code that suggests it might have been used in the past, but at least nowadays modules (both Rust and C#) are strongly typed and already know the schema of the tables they asked to iterate over, and ignore the first element returned from the iteration. As a result, we've been unnecessarily reading schema, encoding it into binary, taking care to allocate it as individual small blob, stored in list of buffers and sent it between Wasm and Rust just for it to be ignored. Removing it simplifies code and if we ever want to get table schema, we can do that via a dedicated method rather than send it automatically on beginning of each iteration. This is an ABI breaking change, but likely worth it.
a7f3604
to
1dbc958
Compare
IIRC it was like this because |
I just synced with Noa as well. TL;DR this is approx how it used to work in psuedo code: let algebraic_type = AlgebraicType::decode_from_bytes(algebraic_type_bytes);
let algebraic_value = AlgebraicValue::decode_from_bytes(bytes, algebraic_type);
let my_table: MyTable = MyTable::from_algebraic_value(algebraic_value); So we actually used to use both the static and dynamic type information. @coolreader18 switched it to be: let my_table: MyTable = MyTable::from_bytes(bytes); but left the dynamically sent AlgebraicType bytes in there in case it was used eventually. Ultimately if we were to have a dynamic API though, you probably wouldn't want it to be mandatory with every iter call, you'd want to have a separate API/ABI sys call for getting the |
Glad to hear :) Can one of you set an approval tick please? |
This reverts commit 469dff6.
Description of Changes
I'm not sure why we're sending encoded schema as this special first element of iteration.
There is some commented out code that suggests it might have been used in the past, but at least nowadays modules (both Rust and C#) are strongly typed and already know the schema of the tables they asked to iterate over, and ignore the first element returned from the iteration.
As a result, we've been unnecessarily reading schema, encoding it into binary, taking care to allocate it as individual small blob, stored in list of buffers and sent it between Wasm and Rust just for it to be ignored.
Removing it simplifies code and if we ever want to get table schema, we can do that via a dedicated method rather than send it automatically on beginning of each iteration.
This is an ABI breaking change, but likely worth it.
API and ABI
If the API is breaking, please state below what will break
Expected complexity level and risk
How complicated do you think these changes are? Grade on a scale from 1 to 5,
where 1 is a trivial change, and 5 is a deep-reaching and complex change.
This complexity rating applies not only to the complexity apparent in the diff,
but also to its interactions with existing and future code.
If you answered more than a 2, explain what is complex about the PR,
and what other components it interacts with in potentially concerning ways.