Giter Club home page Giter Club logo

Comments (7)

nmalzieu avatar nmalzieu commented on August 14, 2024

Doing further tests, I tried to split the two list methods here:
https://github.com/xmtp/xmtp-js/blob/main/src/conversations/Conversations.ts#L88-L89

and it seems that listV1Conversations takes like 25 seconds (I have just 4 of them) and listV2Conversations takes 5 seconds (I have 31 of them)

So probably an issue with v1 conversations, if that can help?

from example-chat-react-native.

elisealix22 avatar elisealix22 commented on August 14, 2024

@nmalzieu Thank you for filing this and I can reproduce the slowness very easily just calling conversations.list(). In one of my authenticated wallets it's taking 257 SECONDS 😱 . There are a few things that could be going on here:

  1. One or many of our polyfills acting slowly
  2. Maxing out CPU
  3. Something slow within Hermes as our JS engine

I'll take a quick look today to try and track down the slowness, but one alternative that might be worth investigating in the meantime is using the xmtp-js library directly in a webview to avoid the polyfills. Hopefully that is much more performant!

from example-chat-react-native.

elisealix22 avatar elisealix22 commented on August 14, 2024

I did some testing between using JavaScriptCore and Hermes on iOS and Hermes seems to be a big bottleneck here. If I disable Hermes in our Podfile, then I can get a cold load of 250 convos in ~3s with a follow-up call taking less than 1s due to caching in our SDK.

If I turn Hermes back on, I notice the cold conversations load significantly slows down to ~1m and even the cached version takes seconds.

With Hermes With JavaScriptCore
hermes jsc

Next steps: Try to get V8 JavaScript engine working for Android so we can move off Hermes and commit these changes. V8 and iOS 14 will be necessary since we require BigInts in our SDK and BigInt doesn't exist on JSC iOS prior to iOS 14 or on JSC Android at all.

from example-chat-react-native.

nmalzieu avatar nmalzieu commented on August 14, 2024

Hi @elisealix22 , thanks I'll try to reproduce!
Do you think the solution is to switch to JSC? Or do you think we could pinpoint what exactly is slow in Hermes (a network call? a serialization?) to maybe make it work with Hermes as it is supposed to be faster and more efficient?

from example-chat-react-native.

elisealix22 avatar elisealix22 commented on August 14, 2024

@nmalzieu Here's the diff of the branch where I had that working with the Generate wallet flow in case it helps!

Do you think the solution is to switch to JSC? Or do you think we could pinpoint what exactly is slow in Hermes (a network call? a serialization?) to maybe make it work with Hermes as it is supposed to be faster and more efficient?

Honestly too soon to call. I don't think either are going to be an easy lift. My instinct was that maybe it's time to switch to JSC/V8 because it's not the first time we've run into performance issues on Hermes. Also, it's noticeably faster to create the 250 convos in the loop on JSC for iOS as well. That said, I have yet to get Android up and running so I think both options are up in the air and need more investigation.

from example-chat-react-native.

elisealix22 avatar elisealix22 commented on August 14, 2024

Update: Using Hermes is a requirement for some so we're going to have to dig in more to figure out what calls are the bottleneck in that environment.

from example-chat-react-native.

nmalzieu avatar nmalzieu commented on August 14, 2024

Thanks @elisealix22
I actually can't see any difference in Converse by using Hermes or not.
It is a bit better now, but still I see great performance improvement if I disable the this.listV1Conversations in Conversation.ts - seems v2 convos are a lot faster to list…

Other issue: it seems to be a bit CPU-intensive and blocking the UI. Like, when doing conversation.list I can't navigate in the app until it's finished (and since it takes a bit of time it's not great)
It is a classic React Native issue but not sure how to fix it (run some stuff in sub threads?)

from example-chat-react-native.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.