-
Notifications
You must be signed in to change notification settings - Fork 21
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
Performance: the react-native SDK seems slower than the Webview with JS SDK #33
Comments
Hi @nmalzieu, thanks for reporting this! We have work in the pipeline to improve performance as we move beyond pre-preview. Your performance numbers don't align with some of our internal benchmarks. I have a couple questions to help us drill down to the core performance issue. Note: as you noticed, the new RN SDK is powered by https://github.com/xmtp/xmtp-ios which does not return self-conversations.
Thanks for your input! As you mentioned we also believe the react-native SDK should outperform webview, but we have some optimization work to do. |
Hi @michaelx11 , thanks for your answer!
Conclusions:
I have multiple |
Thanks @nmalzieu for the explanation. I just published a new package that has a few performance improvements. On iOS we point to our latest cocopod which we've confirmed sped up conversation list by almost double. And on android I was able to fix the conversation list only showing the last 100 convos to now showing all. Here are the performance benchmarks I'm seeing on the latest package on first load Android: Loaded 2001 conversations in 28321ms (28.321s) Be curious to know if you see any improvements on the latest package? There's definitely more improvements here first being hunting down what's causing the near triple load time on android and second being caching so that the second load isn't as long. |
Hey @nplasterer thanks! iOS: Listing 236 conversations took 1.582 seconds I will test on a newer Android device soon but I can confirm the new SDK show all convos on android and a big perf improvement on iOS, with still no caching Keep me posted on further improvements as well! |
@nmalzieu Just wanted to give you an update on the performance work here. I was able to hunt down the slowness on android to these cryptography lines of code (that get called 3 times per conversation) https://github.com/xmtp/xmtp-android/blob/main/library/src/main/java/org/xmtp/android/library/messages/PrivateKeyBundleV2.kt#L47-L51. I've tried some experimental things to speed it up with no success so we may have to go the rust route like iOS is doing. https://github.com/xmtp/libxmtp/blob/main/xmtp_crypto/src/k256_helper.rs#L14:L14. We've got some work moving along on the rust bindings for kotlin currently and I should hopefully know more by Monday. |
We need to expose the Rust-backed Diffie-Hellman operation to unblock performance improvements in Android, context [here](xmtp/xmtp-react-native#33 (comment)). To keep binary size and build-times low, as well as to avoid significant time overhauling `xmtp_swift`, I've made a separate crate called `xmtp_dh` that only contains the single `diffie_hellman_k256` API that is needed for now. There are three pieces here: - The `xmtp_dh` crate. The `README.md` describes how to integrate it into an Android app. - An example Android app (`xmtp_dh/examples`). Used to run an end-to-end test. - The `uniffi_bindgen_generator` crate. A boilerplate binary crate used to [generate the platform-specific bindings](https://mozilla.github.io/uniffi-rs/tutorial/foreign_language_bindings.html#multi-crate-workspaces) in the other crates. Will be used for `bindings_ffi` soon as well. This review is not as big as it looks - **you can ignore everything in the Android example app under `xmtp_dh/examples` except for `MainActivity.kt`**. Credit to @michaelx11 - I reused a lot of the structure from his vmac prototype here.
Hey @nplasterer , thanks, tell me when you need me to do more tests! |
@nmalzieu Correct the performance issue we were seeing on the android side was actually coming from the KotlinSDK. The React Native SDK is mostly a thin wrapper around the Kotlin and Swift SDKs. So the performance fixes are down a few levels. I just pushed up a major performance boost for cold loads on Android shaving off about 1/3 of the time for 2001 conversations. Wondering if you can give it another spin to see if Android has improved for you? I'm hoping that this current version of the React Native SDK should be faster or similar to the webview for iOS and Android on cold loads. Please let me know if that's not the case? As for cached loads @dmccartney is working on that right now. |
Hey @nplasterer I just tested again with an account with 1290 convos (in production), on a newer android device! With the RN SDK: First load : listing 1290 conversations took 15 seconds Same account but in a webview: First load: 15.679 seconds for 1300 conversations => So I get the same perf in webview & RN SDK, not better though! Also, I wanted to compare with the same account on iOS in production, but I can't make the RN SDK work with |
Going to close this out as we've improved cold load and cached load times substantially. Please let me know if you are still seeing issues here:
|
Describe the bug
Webview side
How it works: I pass the XMTP Key to a Webview that contains the JS SDK and I instantiate a client using
Then I do
I get "Listing 240 conversations took 2.986 seconds" then "Re-listing 240 conversations took 0.76 seconds", which shows that there is some caching happening since the second call is so much faster!
React Native side
I get "Listing 236 conversations took 5.781 seconds" then "Re-listing 236 conversations took 5.923 seconds"
ConversationV1
or it doesn't return conversations with myself (I have a few)Expected behavior
I would expect the RN SDK to be at least as fast as the JS SDK in a webview
I would expect both SDKs to return the same # of conversations
I would expect the RN SDK to have some caching as well
Steps to reproduce the bug
No response
The text was updated successfully, but these errors were encountered: