-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Large increase in Firestore initialisation time in 8.8.0 #8791
Comments
A bit more detail: It looks like the first thing the SDK does on startup, that takes most of the delay is prepare a large transaction into levelDB (possibly of all the documents?):
|
kept everything else the same and reverted to 7.4.0 The first commit to levelDB is always empty and no significant delay:
|
@paulharter Thanks for reporting this. What you are seeing is the result of a schema migration. We sometimes perform these migrations to prepare for new features or to improve the overall usability of the SDK. The migration that runs here "Rewrite Targets Canonical Ids" improves the performance of Query evaluation once completed. These schema upgrades should only run once and once completed, startup should be as fast (if not faster) than before. Note that based on the number of changes written it appears that you have a lot of Query data in your cache. It might make sense for you to lower the cache size or to clear persisted data entirely before you perform the upgrade. |
Thank you for explaining but I think the migration mechanism isn't working properly. Rather than just running once it runs every time on startup, growing a little each time. It doesn't realise that it ran the previous time. So the app just get slower and slower on startup. Also is there a way to know that such a migration is going to happen? Do you document somewhere which versions will perform a migration? |
@paulharter Can you tell us whether the migrations ever finish? If you are able to use the SDK (write, read a document) then the migrations should have completed and should not run the next time around. You can also look for the log line "Start LevelDB." |
It appears to add and lots of changes to levelDB and then perform an empty commit. The SDK seems to work fine again after this.
|
This is really strange. I don't see how the SDK would function if it did not commit the schema changes beforehand. Is this issue isolated to a specific device? If so, have you tried to clear persistence to see if this is reproducible? We have been using the same schema upgrade logic since we launched the client initially. This does not mean that it is not broken, it just means that I am a bit perplexed. |
Very odd. The same thing happens on iPhone, iPad and catalyst. It happens after deleting and reinstalling app. Maybe I am doing something non-standard in how I'm setting up the app? I will have a look at this. Maybe there is something about my data that is causing the issue? I have a key "_id" (inherited from couchDB behaviour and helps pagination indexing) in every document that holds its id, might this clash with something? How does it know it should upgrade schema? Something persisted on device file system? Something missing from device file system? (maybe I'm deleting it accidentally?) |
I've just had a look at the migration code for levelDB - it looks like migration 7 is missing the call to |
@paulharter Oh no. Thanks for digging this up. |
no problem - thanks for getting fix into next build so quickly |
[REQUIRED] Step 1: Describe your environment
[REQUIRED] Step 2: Describe the problem
Steps to reproduce:
After updating (unfortunately several things at once) to iOS 14.8, xcode 13 and SDK 8.8.0 (from 7.4.0) I am getting a change in behaviour in startup and initialisation of the SDK.
I am now getting a long pause before the SDK responds to the first request. This request is a simple get on a ref and only checks that the user is authenticated at all, not fetching any other docs in the rules. With 7.4.0 this would complete in roughly 1s, now I am seeing delays of 6s in iPad, 28s on Catalyst. All subsequent gets take 50-80ms.
This makes the app almost unusable.
After deleting app and data the time goes back down to a little over a second in iOS, which implies that size/state of database can cause considerable delay on startup.
Is this something you are aware of?
Is there a new behaviour, maybe more indexing, on startup? If so can I turn it off?
I'm not sure if this is related just to the size of a healthy database or an indication that something is wrong (accumulation of failed writes?)
Is there any way I can debug this? I think there is an envar for verbose Firestore logging but cant remember it.
Thanks
The text was updated successfully, but these errors were encountered: