opensrp / opensrp-client-chw

Reference OpenSRP application for Community Health Workers (CHWs)
Other
3 stars 21 forks source link

Boresha Afya Fixes: Saving a Family takes more than 5mins #2077

Closed samkanga closed 2 years ago

samkanga commented 2 years ago

APK - Kituoni (Health Facility) Android version 7

Steps to reproduce: a) Click add family b) Fill in the fields c) Click Submit

See attached video

https://user-images.githubusercontent.com/5908630/176893365-b777aa23-bf32-4836-b0c5-1623c0ed27ed.mp4

.

owais-vd commented 2 years ago

processClient method is synchronized in CoreClientProcessor class.

https://github.com/opensrp/opensrp-client-chw-core/blob/0ad08cde606d7759bb29f6b04852859f6ef28a58/opensrp-chw-core/src/main/java/org/smartregister/chw/core/sync/CoreClientProcessor.java#L125

and initially when we launch the app the processClient method is blocked by thread IntentService[SyncClientEventsPerTaskIntentService].

cc: @samkanga

owais-vd commented 2 years ago

a suggestion here, can we remove synchronized keyword from the processClient method so other threads cannot block it. cc: @ekigamba

hilpitome commented 2 years ago

@owais-vd we can do that but there could be repercussions. The main question would be, why was the synchronized modifier added in the first place. I have traced it to this commit by @raihan-mpower. It would be a good place to start. cc @samkanga

ekigamba commented 2 years ago

I agree with @hilpitome.

I'd prefer we leave it as-is, unless there's a better alternative and good reason to remove it given that it relates to synchronizing multiple-threads.

@owais-vd Are there other performance improvements that you can suggest or identified causes for slowness?

Follow this documentation that will help you investigate further and implement previous fixes:

Here is a checklist

Other performance-related discussions for reference and perusal:

cc @samkanga

faith-mutua commented 2 years ago

@samkanga @owais-vd the issue has been resolved. Saving a family now takes less than a minute