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

Callback interface speedup #1497

Merged
merged 10 commits into from
Mar 24, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Doc fixes from review
  • Loading branch information
bendk committed Mar 23, 2023
commit e19e265a22845c2948b6f1b09186edb60199e5fe
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
[All changes in [[UnreleasedVersion]]](https://github.com/mozilla/uniffi-rs/compare/v0.23.0...HEAD).

### ⚠️ Breaking Changes ⚠️
- Implemented a new callback-interface ABI that signifacantly improves performance on Python and Kotlin.
- ABI: Implemented a new callback-interface ABI that significantly improves performance on Python and Kotlin. UniFFI users will automatically get the benefits of this without any code changes. This is a breaking change because the new generated code is not compatible with code generated with UniFFI 0.23.x.

### What's changed

Expand Down
12 changes: 6 additions & 6 deletions fixtures/benchmarks/src/benchmarks.udl
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
namespace benchmarks {
// Run all benchmarks and print the results to stdout
void run_benchmarks(string language_name, TestCallbackInterface cb);
// Run all benchmarks and print the results to stdout
void run_benchmarks(string language_name, TestCallbackInterface cb);

// Test functions
// Test functions
//
// These are intented to test the overhead of Rust function calls including:
// popping arguments from the stack, unpacking RustBuffers, pushing return
// values back to the stack, etc.

string test_function(i32 a, i32 b, TestData data); // Should return data.bar
void test_void_return(i32 a, i32 b, TestData data);
void test_no_args_void_return();
string test_function(i32 a, i32 b, TestData data); // Should return data.bar
void test_void_return(i32 a, i32 b, TestData data);
void test_no_args_void_return();
};

dictionary TestData {
Expand Down
5 changes: 3 additions & 2 deletions uniffi_core/src/ffi/foreigncallbacks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,9 @@ use std::sync::atomic::{AtomicUsize, Ordering};
/// * The `method` selector specifies the method that will be called on the object, by looking it up in a list of methods from
/// the IDL. The index is 1 indexed. Note that the list of methods is generated by at uniffi from the IDL and used in all
/// bindings: so we can rely on the method list being stable within the same run of uniffi.
badboy marked this conversation as resolved.
Show resolved Hide resolved
/// * `args_data` and `args_len` represents a serialized buffer of arguments to the function.
/// UniFFI will deserialize it before passing individual arguments to the user's callback.
/// * `args_data` and `args_len` represents a serialized buffer of arguments to the function. The scaffolding code
/// writes the callback arguments to this buffer, in order, using `FfiConverter.write()`. The bindings code reads the
/// arguments from the buffer and passes them to the user's callback.
/// * `buf_ptr` is a pointer to where the resulting buffer will be written. UniFFI will allocate a
/// buffer to write the result into.
/// * A callback returns:
Expand Down