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

New improvements in Dart 3.5 #408

Closed
ganeshrvel opened this issue Aug 7, 2024 · 4 comments
Closed

New improvements in Dart 3.5 #408

ganeshrvel opened this issue Aug 7, 2024 · 4 comments

Comments

@ganeshrvel
Copy link

Do you think that the package could benefit from the newest version of Dart which was released yesterday? Maybe this could help in copy protobuf performance?

Blog: https://medium.com/dartlang/dart-3-5-6ca36259fa2f

Dart native interoperability
In Dart 3.5, we’ve made incremental improvements to support passing a pointer from Dart TypedData objects directly to FFI, avoiding having to first copy the memory from Dart to Native (details).

An interesting protobuf performance comment: dart-lang/sdk#44589 (comment)

@temeddix
Copy link
Member

At a glance, it looks like the memory copy of messages being sent from Dart to Rust is now avoidable. Applying this new method of calling native C functions would be a great task for the next Rinf release. Thank you for sharing!

Also, we are open to any kind of PR for this issue if anyone wants a faster release of this feature.

@ganeshrvel
Copy link
Author

From your comment on performance in this link here, how will the new change affect the performance metrics in the table below?

Your table:

Operation and Data PB Serialization Mem Copy Details
Dart >> Rust (Message) O O Dart mallocs on heap, Rust deserializes from its slice
Dart >> Rust (Raw Binary) X O Dart mallocs on heap, Rust copies it
Rust >> Dart (Message) O X Rust gives ownership, Dart deserializes from it
Rust >> Dart (Raw Binary) X X Rust gives ownership

@temeddix
Copy link
Member

temeddix commented Aug 11, 2024

If I understood the content that you provided correctly, the table would be like this after we make the change:

Operation and Data PB Serialization Mem Copy Details
Dart >> Rust (Message) O X Rust deserializes from Uint8List
Dart >> Rust (Raw Binary) X O Rust copies Uint8List
Rust >> Dart (Message) O X Rust gives ownership, Dart deserializes from it
Rust >> Dart (Raw Binary) X X Rust gives ownership

'Dart >> Rust (Raw Binary)' would also benefit from reduced memory copy.

@temeddix
Copy link
Member

With #425, leaf FFI call was implemented. Now memory copy from Dart to Rust has decreased.

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

Successfully merging a pull request may close this issue.

2 participants