-
Notifications
You must be signed in to change notification settings - Fork 23
Description
TL;DR; SharedPrefsSummaryEventStore sometimes causes performance issues. Would you consider providing an in-memory only implementation and allowing to use it via a configuration option?
Is your feature request related to a problem? Please describe.
Our app uses Launchdarkly extensively (many feature flags, evaluated often). We noticed a lot of ANRs on lower end devices caused by SharedPrefsSummaryEventStore. The ANRs mostly fall into two categories: serialization of the summary data structure when called from the main thread and the activity lifecycle waiting for SharedPreferences' fsync to complete (a known, unfortunate side effect of using SharedPreferences).
Describe the solution you'd like
We've implemented an in-memory SummaryEventStore, which looks exactly like SharedPrefsSummaryEventStore but backed by a simple map instead of SharedPreferences and observed a huge improvement. Of course, the tradeoff here is durability of events - if the app restarts, unflushed event summary is lost; for us, the performance benefits are definitely worth it.
Happy to open a PR with our patch.
Describe alternatives you've considered
It's possible to improve durability in offline scenarios by periodically snapshotting the in-memory event summary to disk in the background. This will not make much of a difference when the device is online, because the summary is periodically flushed back to the LD webservice anyway, and may not be worth the added complexity.