opensrp / fhircore

FHIR Core / OpenSRP 2 is a Kotlin application for delivering offline-capable, mobile-first healthcare project implementations from local community to national and international scale using FHIR and WHO Smart Guidelines on Android.
https://smartregister.org
Apache License 2.0
50 stars 39 forks source link

Volume Testing on the FHIR Core client app #3181

Open ndegwamartin opened 3 months ago

ndegwamartin commented 3 months ago

Overview We need to conduct Volume Testing to see how the app scales with a lot of data. This testing will help highlight the various bottlenecks with the app.

Initial Test Data

We can gradually increase the data set size as we optimize and improve.

Tasks

Mstjamush commented 1 month ago

Device Specs

Phone - Techno Spark 7
RAM - 3GB
ROM - 64GB
Android Version - 11

WiFi - 20Mbps Number of Households - 1025 Number of Clients - 10250 Number of tasks - 3075

Results

ellykits commented 1 month ago

@Mstjamush Can you explicitly define the time format for the starts shared above? e.g. HH:MM:ss

Mstjamush commented 1 month ago

@ellykits it's in HH:MM:ss format

pld commented 1 month ago

@Mstjamush can you share the same results for 10k households please?

Mstjamush commented 1 month ago

@pld Let me generate the HHs and share

ndegwamartin commented 1 month ago

Findings investigating the MWCore app:

ndegwamartin commented 1 month ago

Observation on the Search Query:

  1. It uses the same Index to sort by as the register
  2. Removing the index improves the performance as well
  3. Search performance latency is directly proportional to the size of the resulting data set

Opportunities for improvement

  1. Change search index to a non String type index e.g. last updated
  2. Remove the index entirely - search narrows down the records enough
  3. Limit triggering the db search until a minimum limit of characters is input by the user e.g. 3 chars
ndegwamartin commented 1 month ago

Ticket to track performance optimizations on the FHIR SDK engine - https://github.com/google/android-fhir/issues/2547

ndegwamartin commented 1 month ago

For the form loading, after profiling MWCore made the following observations for the Registration form:

  1. First time load of the Registration form is quite fast. Subsequent attempts take 12 to 13 seconds
  2. Loading the Questionnaire resource from the DB seems to introduce this latency

We can implement a caching mechanism for the resources once loaded the first time and figure out an appropriate cache invalidation mechanism. This can be informed by various factors like we don't expect Questionnaire resources to change frequently during use.

LZRS commented 1 month ago

For the page registers, after doing some further tests, we've realized that there are three types of queries that are run

  1. Query to populate the actual registers, including subqueries used to populate specific fields
  2. Query to get total count of pages, used for navigation at the bottom
  3. Query to populate counts for the sidenav bar menu items

The last two are the most costly, since they'd need to go through entire db rows to get the total count.

Also, to note, is that all queries in the sdk are wrapped within db transactions. From Room's documentation

Room will only perform at most one transaction at a time, additional transactions are queued and executed on a first come, first serve order.

So, a query can seem to take long because it's queued and waiting for other transactions to finish. That is, regardless of whether the queries are in different coroutines, and were running concurrently. For example, in our case assuming the 3 different query types are ran in 3 different coroutines, the order in which the transactions are called can be somewhat arbitrary and when in order of either 2 - 3 - 1 or 3 - 2 - 1 the query to populate the register would be the last one called and the register would seem to take too long to load/show

LZRS commented 1 month ago

Separate ticket to track select query being queued, instead of running concurrently: https://github.com/google/android-fhir/issues/2552

Mstjamush commented 1 month ago

Device Specs

Phone - SAMSUNG A12
RAM - 3GB
ROM - 64GB
Android Version - 12

_WiFi - 20Mbps Number of Clients - 7661

Results

Mstjamush commented 1 month ago

Tests after refactors

Device Specs

Phone - SAMSUNG A12
RAM - 3GB
ROM - 64GB
Android Version - 12

_WiFi - 20Mbps Number of Clients - 7661

Results

Mstjamush commented 3 weeks ago

Tests after refactors

Device Specs

Phone - SAMSUNG A12
RAM - 3GB
ROM - 64GB
Android Version - 12

_WiFi - 20Mbps Number of Clients - 7661

Results

Mstjamush commented 1 week ago

Tests after refactors (Includes cache on forms)

Device Specs

Phone - SAMSUNG A12
RAM - 3GB
ROM - 64GB
Android Version - 12

_WiFi - 20Mbps Number of Clients - 7584

Results

Save forms has a questionnaire issue

pld commented 1 week ago

was this performed on a version of the SDK with this PR included? https://github.com/google/android-fhir/pull/2565/files

LZRS commented 4 days ago

was this performed on a version of the SDK with this PR included? https://github.com/google/android-fhir/pull/2565/files

No, the sdk versions didn't include the PR...we instead used chunking of the parameters from the app's side to prevent the error

Mstjamush commented 4 days ago

Tests after refactors (Includes cache on forms)

Device Specs

Phone - SAMSUNG A12
RAM - 3GB
ROM - 64GB
Android Version - 12

_WiFi - 20Mbps Number of Clients - 7584

Results

@Gental-Giant the issue was fixed

pld commented 3 days ago

Interesting that load time jumped up so much