Closed kroikie closed 3 years ago
@ribrdb
The issue at https://github.com/flutter/flutter/issues/17247 has been closed and moved here. Future collaboration on this issue will be done here.
Hi @ribrdb
If you are still experiencing this issue
with the latest version of Flutter and FlutterFire plugin
can you please provide your updated flutter doctor -v
and your and your flutter run --verbose
/flutter build --verbose
?
Also, to better address the issue, would be helpful
if you could post a self contained app on github
or the steps to reproduce it.
Thank you
I don't have an app, I was reading your source code to see if I want to use it. You still do the same thing of serializing every document for every QuerySnapshot even if only a single document is added.
@ribrdb Thanks for bringing this up, we could indeed reduce the amount of serialization however that would also require significant book keeping and additional memory usage for caching documents on the Dart side. We would need to find the right balance, we are open to suggestions and PRs if you have a solution in mind.
This is indeed a problem in non-trivial realtime kind of use cases. For instance, if the result set is more then a few documents (say near to 50-60 documents) and a realtime listener is setup to keep a track of changes in this result set, there is a huge hit on the CPU and a bunch of frames start dropping.
I tried to do a very unscientific benchmark to compare Firebase Realtime DB to Cloud Firestore. If you look at the Firestore flame graph, most of the time is spent on decodeMethodCall
doing a bunch of deserializations
On the other hand, realtime database does not break a sweat
These were rough benchmarks by me clicking around and generating events in a dummy app at roughly the same speed. But I think the difference is evident and it can be clearly felt in skipped frames in the UI in case of Firestore.
To be honest, I am a bit surprised that this is not higher priority. I feel a lot of users who complain about Firebase (Firestore) being slow might be getting affected by something like this unknowingly too.
Given the age of this issue and that Firestore has had a major rework since and has had a few improvements around serialisation and use of threading to improve performance; I'm going to close this issue in favour of trying the latest release.
The firestore plugin serializes the entire document list for each query update. Wouldn't it be more efficient to only serializes the deltas and apply them in the dart code? Especially for large queries.