-
Notifications
You must be signed in to change notification settings - Fork 499
Improve risklevel result data access performance (DEV) #1953
Improve risklevel result data access performance (DEV) #1953
Conversation
…e to performance impact when logging.
The delay when switching from Home to RiskDetails fragment will be bridged and no re-loading necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm unsure whether these changes will be sufficent for the mentioned problem.
Issue should be kept in mind. @kolyaopahle
Code lgtm.
I concur that we should keep an 👁️ on this. I added some debug code that multiplied the processed windows by 100 and it was better, there may be issues where the amount of scan instances is high. The next step would probably be to created combined SQL queries, this was problematic at first because we only care about There may be further optimizations by increasing the "replay duration" i.e. how long the timeout is during which the last value will be replayed, but that's a different topic, where we have to check if there are certain constellations where the data is accessed via |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Add unit tests for SQL queries.
Also do a lookup in Android Studio on where each |
Corona-Warn-App/src/main/java/de/rki/coronawarnapp/risk/storage/internal/RiskResultDatabase.kt
Show resolved
Hide resolved
…erformance # Conflicts: # Corona-Warn-App/src/deviceForTesters/java/de/rki/coronawarnapp/test/risklevel/ui/TestRiskLevelCalculationFragmentCWAViewModel.kt # Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/tracing/card/TracingCardStateProvider.kt # Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/tracing/details/TracingDetailsStateProvider.kt
looking good so far. |
Done. The HomeFragment test does not pass since the big refactoring of the home screen, but the other tests can be run again. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌
Kudos, SonarCloud Quality Gate passed! |
Got pinged by testers about the app taking longer to load, further investigation showed several issues that this PR fixes. The underlying issues are not present (or only to a lot lesser degree) on production:
Exposure Window data was being explicitly logged in tester builds, due to much larger scan instance counts, the logging slowed down data emission by
Flow
that printed the log output.toString
, reducing it to only show the item count.RiskLevel result history size is much larger for the tester builds, and tester builds store the exposure window data. We only had a single way of accessing the stored risk result which meant that the access triggered retrieval of all results (and required mapping matching exposure windows to each result).
latestRiskLevelResults
that uses SQL queries to prefilter the data (faster than in kotlin) a return only the latest two results (which is what the UI is mostly interested in, except for test screens)Multiple data access was happening, where we could have reused the results, switching from home to the risk details screen, caused 2 sepperate retrieval events.
stateIn
to share the flow subscription. Currently it's onlyWhileSubscribed
with a replay value of0ms
but due to async viewmodel teardown when leaving the home screen this is already enough to prevent double flow subscription.Testing
Also do a lookup in Android Studio on where each
Flow
is accessed from and whether it's the correct data being supplied.