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

Performance refactors for Posts feed #1527

Merged
merged 18 commits into from
Jun 1, 2024

Conversation

MV-GH
Copy link
Collaborator

@MV-GH MV-GH commented May 27, 2024

Refactor to use SnapshotStateList instead of List

Before what we did was create a new list each time we change something in that list. Since compose checks on equality the list is now different and fully recomposes the entire list. Instead use SnapshotStateList which emits events for only the changes made to the list.

Many changes have made to the postlisting so that when a vote changes it doesn't recompose the entire postlisting but just the votes. This was only successful for postlisting as the card modes use postview to deeply into the "onAction" lambdas which trigger recompose as the postview has different equality.

It no longer recomposes the feed when adding/updating postviews

The collapsible header also causes recompositions as it changes the innerpadding which is applied to the lazy column. Not sure if anything can be done for that. (But only when it moves, so when u scroll down once its up, no recompositions happen) (This has been solved)

I am also going to refactor the comments. (I'll do that in a separate PR)

@MV-GH MV-GH changed the title Recomposition experiments Performance refactors for Posts feed May 27, 2024
@MV-GH MV-GH marked this pull request as ready for review May 31, 2024 14:10
@MV-GH MV-GH requested a review from dessalines as a code owner May 31, 2024 14:10
Copy link
Member

@dessalines dessalines left a comment

Choose a reason for hiding this comment

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

Check the comments below, but my biggest concern is the fact that there are now two lists to keep track of, rather than a single snapshotstatelist.

Also the remembers are potentially bug-worthy, since source data changes might not be reflected properly. If they're necessary that's okay, but maybe they should be keyed.

app/src/main/java/com/jerboa/feed/FeedController.kt Outdated Show resolved Hide resolved
app/src/main/java/com/jerboa/model/PostsViewModel.kt Outdated Show resolved Hide resolved
compose_compiler_config.conf Outdated Show resolved Hide resolved
MV-GH added 3 commits May 31, 2024 20:13
# Conflicts:
#	app/src/main/java/com/jerboa/model/PostsViewModel.kt
MV-GH added 6 commits May 31, 2024 20:58
# Conflicts:
#	app/src/main/java/com/jerboa/ui/components/post/PostListing.kt
#	app/src/main/java/com/jerboa/ui/components/post/composables/PostOptionsDropdown.kt
# Conflicts:
#	app/src/main/java/com/jerboa/ui/components/community/CommunityActivity.kt
#	app/src/main/java/com/jerboa/ui/components/home/HomeActivity.kt
#	app/src/main/java/com/jerboa/ui/components/post/PostActivity.kt
#	app/src/main/java/com/jerboa/ui/components/post/PostListings.kt
@dessalines dessalines merged commit 461f264 into LemmyNet:main Jun 1, 2024
1 check passed
@MV-GH MV-GH deleted the recomposition-experiments branch June 1, 2024 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants