Skip to content
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

Fix slow paged room list regression #6233

Closed

Conversation

BillCarsonFr
Copy link
Member

Type of change

  • Bugfix

Content

A new parameter was added to resolve the list of parent summaries when loading the rooms paged list.
This param is affecting performances a lot when you have some decent space hierarchy. And it was called unproperly when displaying the regular room list (should only be needed for search/filter rooms).

Also the new added flattenParents field (that was slowing the queries) was never used. Instead the space parent was used. I think improperly because it only reflect the presence of a m.space.parentrelation, that is not used to decide hierarchy (m.space.child) are used for that.

@ericdecanini can you confirm?

See #3830 regarding recent degradation of performances.

Tested devices

  • Physical
  • Emulator
  • OS version(s):

Checklist

@BillCarsonFr BillCarsonFr added the Z-NextRelease For issues and PRs which should be included in the NextRelease. label Jun 3, 2022
@github-actions
Copy link

github-actions bot commented Jun 3, 2022

Unit Test Results

148 files  ±0  148 suites  ±0   2m 12s ⏱️ -32s
237 tests ±0  237 ✔️ ±0  0 💤 ±0  0 ±0 
790 runs  ±0  790 ✔️ ±0  0 💤 ±0  0 ±0 

Results for commit 89e528d. ± Comparison against base commit 0ef67b6.

♻️ This comment has been updated with latest results.

Copy link
Contributor

@ericdecanini ericdecanini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the doc change is very much needed. There's a similar method in RoomService called getPagedRoomSummariesLive that feels like the default method used while getFilteredPagedRoomSummariesLive sounds like it's only used in FilteredRoomsActivity. This issue highlights that this isn't the case, and it would be good to make that clearer in the code through these java docs

*/
fun getFilteredPagedRoomSummariesLive(
queryParams: RoomSummaryQueryParams,
pagedListConfig: PagedList.Config = defaultPagedListConfig,
sortOrder: RoomSortOrder = RoomSortOrder.ACTIVITY
sortOrder: RoomSortOrder = RoomSortOrder.ACTIVITY,
getFlattenParents: Boolean = false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
getFlattenParents: Boolean = false,
getFlattenParents: Boolean = false, // Heavily impacts performance when true. Only use when space parent is absolutely required

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, but please add this mention in the Kdoc and not here, or it will not be exported.

Comment on lines 229 to 235
* TODO Doc.
* @param getFlattenParents When true, the list of known parent and grand parent summaries will be resolved.
* This can have significant impact on performance, better be used only on manageable list (filtered by displayName, ..).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels weird to have a partial java doc covering only one parameter. I would resolve this TODO and complete the javadoc here (and preferably for the method above too, to avoid confusion later)

Suggested change
* TODO Doc.
* @param getFlattenParents When true, the list of known parent and grand parent summaries will be resolved.
* This can have significant impact on performance, better be used only on manageable list (filtered by displayName, ..).
* Gets filtered page of room summaries so that [insert use of filtered here]
*
* @param queryParams - tba
* @param pagedListConfig - tba
* @param sortOrder - tba
* @param getFlattenParents When true, the list of known parent and grand parent summaries will be resolved.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you use tba you should keep the TODO

val spaceName = roomSummary.spaceParents?.firstOrNull()?.roomSummary?.name
val spaceName = roomSummary.flattenParents
.takeIf { it.isNotEmpty() }
?.joinToString(", ") { it.name }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although this is nice, I'm thinking now to maintain parity with web, we only take the last element in flattenParents for the subtitle. If design would deem it's better to have all parents separated by comma, we can have a meta ticket to change that across all platforms

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't look to me what web is taking the last one only. What are the requirement exactly?
Can you take over it as I believe you are the one that initialy developed it?

@fedrunov
Copy link
Contributor

fedrunov commented Jun 6, 2022

@BillCarsonFr were you able to reproduce or you just assume that flattened parents is the cause? I've tested with many spaces and there were no problems with db read, so if you can reproduce, could you share your setup?

Also, issue was created before flatten parents flag was added (PR). So I'm not sure this actually fixes problem

@BillCarsonFr
Copy link
Member Author

@BillCarsonFr were you able to reproduce or you just assume that flattened parents is the cause? I've tested with many spaces and there were no problems with db read, so if you can reproduce, could you share your setup?

Also, issue was created before flatten parents flag was added (PR). So I'm not sure this actually fixes problem

I can reproduce 100% with my personal account.

Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a file for the changelog

@BillCarsonFr BillCarsonFr force-pushed the feature/bca/fix_slow_space_switch_regression branch from 3dfeeda to adf8c5f Compare June 7, 2022 07:39
Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM after a static review.
Please do not merge on develop, I will create a hotfix, as it's blocking the release 1.4.18.

@ericdecanini ericdecanini force-pushed the feature/bca/fix_slow_space_switch_regression branch from 3835755 to 89e528d Compare June 7, 2022 10:44
@ericdecanini
Copy link
Contributor

(force push to revert commit made on the wrong branch)

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jun 7, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@bmarty bmarty mentioned this pull request Jun 7, 2022
61 tasks
@bmarty
Copy link
Member

bmarty commented Jun 7, 2022

All the 4 commits have been cherry-picked to create the hotfix 1.4.19. The changes are now on develop and on main.

@bmarty bmarty closed this Jun 7, 2022
@waclaw66
Copy link
Contributor

waclaw66 commented Jun 9, 2022

Another regression #6272 that didn't make it to 1.4.19...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Z-NextRelease For issues and PRs which should be included in the NextRelease.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants