Uploaded image for project: 'Realm Java SDK'
  1. Realm Java SDK
  2. RJAVA-336

Realm initialization unnecessarily uses reflection, impacting startup performance

      I was profiling the startup performance of my app, and found that initializing Realm took around 100ms, and half of that time was spent on a single reflection call

      When calling Realm.init(), the following line is executed:
      https://github.com/realm/realm-java/blob/afc79e568d3f710fcdf99d30bf67b33c8134f6c6/realm/realm-library/src/main/java/io/realm/Realm.java#L270

      Because this configuration is created empty, build() is forced to call isRxJavaAvailable()
      https://github.com/realm/realm-java/blob/afc79e568d3f710fcdf99d30bf67b33c8134f6c6/realm/realm-library/src/main/java/io/realm/RealmConfiguration.java#L812-L814
      https://github.com/realm/realm-java/blob/afc79e568d3f710fcdf99d30bf67b33c8134f6c6/realm/realm-library/src/main/java/io/realm/RealmConfiguration.java#L422-L432

      We can avoid this reflection call when creating our own RealmConfiguration by providing it with an RxObservableFactory, but we don't have access to the one that's created inside of Realm.init(), forcing us to waste 50ms at app startup

      Proposed solution

      If we could provide our own RealmConfiguration to be used for Realm.init(), then this should help improve startup performance for apps who know that they will be using RxJava

            Assignee:
            Unassigned Unassigned
            Reporter:
            unitosyncbot Unito Sync Bot
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: