Code Monkey home page Code Monkey logo

Comments (6)

sync-by-unito avatar sync-by-unito commented on July 3, 2024

➤ PM Bot commented:

Jira ticket: RCOCOA-2306

from realm-swift.

nirinchev avatar nirinchev commented on July 3, 2024

Do you think you can get the Realm file that reproduces the issue and either share it with us or get a profile to help us understand where the app is spending time? As a temporary workaround you could try shipping a version that doesn't compact the Realm file at launch.

@finnschiermer this is updating from Core 13.20.1 to 13.26.0 - I tried skimming through the changelog entries and there was nothing that jumped at me as having potentially large performance impact.

from realm-swift.

macdrevx avatar macdrevx commented on July 3, 2024

As a temporary workaround you could try shipping a version that doesn't compact the Realm file at launch.

How do you do this? Will the realm never be compacted, or just not while it's being opened?

Do you think you can get the Realm file that reproduces the issue and either share it with us or get a profile to help us understand where the app is spending time?

I won't be able to get the exact realm file. We'll likely need to see whether we can create one artificially.

from realm-swift.

nirinchev avatar nirinchev commented on July 3, 2024

You can return false in the shouldCompactOnLaunch callback skipping compaction for the Realm file. You can also use a heuristic where it returns true for smaller files, but not for those large ones, which take a long time.

In terms of whether the file it'll compact, the answer is yes-ish. By that, I mean, that we now have automatic compaction enabled on every commit where we'll do certain cheap storage optimizations continuously. This is not as effective as running a compact on launch but it gets close in a lot of scenarios.

Alternatively, you could restructure your app so that it doesn't open the Realm file as part of the AppDelegate.application call and instead do it after that the app has loaded (possibly adding a loading indicator in case the file size is beyond a certain threshold).

from realm-swift.

nirinchev avatar nirinchev commented on July 3, 2024

Ok, I spoke with @finnschiermer and there's nothing obvious that would cause significant performance degradation between these versions of Core. It's possible that this was already fairly slow and a small write performance regression just pushed it over the 17 seconds limit. If you can provide a repro case, we can run a profile and try to see what's taking more time now.

That being said, compacting such a large file on app initialization would be a bad idea, regardless of the version of the SDK as it would require write speeds of >270 MB/s in the worst case scenario to fit in under 17s, and even then it would be a bad user experience to stare at a blank screen for so long. As suggested above, one approach would be disable compact on launch for files above a certain threshold or if you need to run it, you should try and open the Realm on a background thread after the app has finished initializing, then after that has succeeded, open it on the main thread.

from realm-swift.

Related Issues (20)

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.