New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Loading a CHW area is slow #4445
Comments
Hi @dianabarsan, Please ensure this ticket has a Priority, Status and Type label. (See triaging old issues for more detail) |
I mapped out the Application-Database interactions along with the paint timings for the contact's tab. This is profiling just the scenario for a Muso heavy user experiencing slow performance, so there could be scenarios on the tab not profiled here. In general, things are pretty tight but there are a few optimization ideas below. "Contacts" - Left-Panel PAINT THE CONTACTS PAGE WITH SPINNERS L4. Use view(contact_by_type) for type "clinic" > Returns all "clinics" (40 of them for this user) PAINT THE LEFT PANEL "Contact-Content" - Right-Panel R1. Get org.couchdb.user:adamayo doc for its facility_id. Select that clinic. PAINT RIGHT PANEL WITH SPINNER R5. View(docs_by_id_lineage) for selected clinic's primary contact. Returns clinic's contact's doc and area's contact's doc. PAINT CHILDREN (after 4982) R8. View(reports_by_subject) passing in the ids of all children. PAINT THE REPORTS Optimization Ideas
|
@kennsippell Good write up, thanks! What version did you do this analysis on? There have been improvements made between the version MUSO is on and the latest and greatest, eg: #4669 Point 3: Do you mean "R9" and "R8"? |
@garethbowen This is on master since Muso has a concrete timeline to get 3.2. I have
Yes I did! Edited above for accuracy. Are any of these things you think are higher potential, or are notinterested to pursue (eg. 5?), or have looked into already? |
I like the idea of dropping the primary contact information from the LHS and RHS but this will need to be discussed with design if this is feasible or not. Consolidation of data fetching is another one I like. Some of these decisions were made so we could have reuse of the services but we may be able to include additional parameters to keep information from being thrown away or we may have to drop the idea of reuse in favour of performance. I'm also wondering if we could hide the Children, Reports, and Tasks sections of the Contacts RHS in an accordion (or similar) and only fetch the data when the accordion is expanded. I wouldn't worry too much about tablets as they're not very common in the field and they generally have a bit more grunt anyway - prioritise the phone experience for now. |
The contact's tab fetches the org.couchdb.user document three times just to render. Although it isn't a particularly expensive operation, it is done frequently. Since this document has very low churn, it should be safe to cache it in UserSettings() in a similar style to Settings(). #4445
Performance optimizations for the Live-List class as-used in the contacts tab. Contact controller currently calls livelist.update once per list item and then livelist.refresh after all items are added. This change updates the interface livelist.set to avoid the incremental dom changes from livelist.update and then the full re-paint from livelist.refresh. The proposed change inserts the items each item into the model once, sorts the full list once, and then draws everything once. To avoid unnecessary scanning, update livelist.dom to a hashmap. livelist.set() accepts an optional flag reuseExistingDom which can avoid expensive calls to listItemFor when the contents of the DOM are being reused and not updated (eg. pagination). #4445
This is a very minor performance tweak to avoid an unnecessary PouchDB.get() for a place's primary contact when the document is already in the place's children. In my limited exposure to project data, the primary contact is often a child of the place. Looks like the in-memory lookup is ~0-1ms and PouchDB lookup ranges from 10-45ms. Not impressive... but I'm here cause it's on my list, and it doesn't add much compexity. Very open to just closing this as won't fix due to insufficient gains. "The data fetched in right-panel step R6 was already fetched in step R4. Can we consolidate?" from #4445
Recommend closing this issue - I believe all planned work is now tracked in linked issues. |
@alxndrsn Did you have anything outstanding to commit against this issue, or can we close as @kennsippell suggests? |
Loading a CHW area takes 10s of seconds on a reasonable phone. I imagine this is proportionate to the number of families that CHW has. It's not clear if this is just how it is, or if we're doing something inefficient.
Perhaps we shouldn't render every single family under the area in the UI straight away.
For reference:
The text was updated successfully, but these errors were encountered: