Skip to content
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

Implement the native async fn in trait to replace our dependency of the crate async trait #48

Open
TheRustifyer opened this issue Dec 10, 2023 · 0 comments

Comments

@TheRustifyer
Copy link
Member

Refactor

When Rust 1.75 will be released, a new major change that will impact our codebase will be out async fn in trait.

This is a long awaited feature in the Rust ecosystem, since it was only possible to use async trait with the nightly version of the compiler using the cfg features that will allow their usage.

Since Canyon-SQL codebase is mandatory stable flavour based, we need to use the async trait crate, which provides a workaround to be able to use async functions in traits. This workaround is based on macros that ultimately will use dynamic dispatch along with fat pointers to sugar the concept that we're discussing. That means that we are losing performance (since the code relies on runtime functionality) and also we're losing perfomance because the usage of dynamic dispatch.
This will improve cache locality (less cache misses in consecuence) and will help us to avoid false sharing.

This change improves the performance of the heart of Canyon and now that the async API will be stabilized for this concrete feature in the release version mentioned above, it's time to refactor this part to include native async support when the version will be out.

NOTE: Also, in this release, there's other amazing feature out. Allow impl Trait on return position. We could watch and review our codebase, and see when we could change the code written up until this point to take advantage in this feature, because this will allows us to reduce the inherent complexity of the return types used on the Canyon methods of the Transaction<T> and CrudOperations<T>: Transaction<T> traits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant