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

[CIS-265] Lazy model transformation for LLC #776

Merged
merged 4 commits into from Feb 3, 2021
Merged

Conversation

ManWithBear
Copy link
Contributor

@ManWithBear ManWithBear commented Jan 29, 2021

Improve performance of CoreData observers by introducing LazyCachedMapCollection, data structure that applies transformations to underlying sequence on read access.

Decrease amount of DB queries on DTO -> Model transformation when possible.

Huge FPS drop on channel open happens not because of message list layout or message load (affects it, but not critical).
Apparently when we open channel, channel list observer overload CPU by making useless job.
Screenshot 2021-01-29 at 4 20 39

@ManWithBear ManWithBear added the 🌐 SDK: StreamChat (LLC) Tasks related to the StreamChat LLC SDK label Jan 29, 2021
.loadReplies(for: dto.id, limit: 25, context: context)
.map(_ChatMessage.init)

if dto.replies.isEmpty {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don;t do DB queries, when here no need. It's super expensive.

@codecov
Copy link

codecov bot commented Jan 29, 2021

Codecov Report

Merging #776 (9846d96) into main (8f72ede) will decrease coverage by 0.47%.
The diff coverage is 96.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #776      +/-   ##
==========================================
- Coverage   89.13%   88.65%   -0.48%     
==========================================
  Files         218      219       +1     
  Lines        8533     8570      +37     
==========================================
- Hits         7606     7598       -8     
- Misses        927      972      +45     
Impacted Files Coverage Δ
...ces/StreamChat/Utils/LazyCachedMapCollection.swift 92.59% <92.59%> (ø)
.../ChannelController/ChannelController+SwiftUI.swift 100.00% <100.00%> (ø)
...trollers/ChannelController/ChannelController.swift 91.21% <100.00%> (ø)
...ListController/ChannelListController+SwiftUI.swift 100.00% <100.00%> (ø)
.../ChannelListController/ChannelListController.swift 94.66% <100.00%> (ø)
.../StreamChat/Controllers/ListDatabaseObserver.swift 92.71% <100.00%> (+0.04%) ⬆️
...rListController/MemberListController+SwiftUI.swift 100.00% <100.00%> (ø)
...rs/MemberListController/MemberListController.swift 97.70% <100.00%> (ø)
.../MessageController/MessageController+SwiftUI.swift 100.00% <100.00%> (ø)
...trollers/MessageController/MessageController.swift 95.18% <100.00%> (ø)
... and 10 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8f72ede...9846d96. Read the comment docs.

@ManWithBear ManWithBear force-pushed the CIS-256-lazy-data branch 2 times, most recently from 434a27a to 070a974 Compare February 2, 2021 01:53
@ManWithBear ManWithBear changed the title [CIS-256] Lazy data loading fro LLC [CIS-256] Lazy model transformation for LLC Feb 2, 2021
@ManWithBear ManWithBear marked this pull request as ready for review February 2, 2021 01:56
@VojtaStavik
Copy link
Contributor

@b-onc Since Denis has a day off today, I finished the PR. Can you please review it?

@VojtaStavik VojtaStavik removed their request for review February 3, 2021 11:07
Copy link
Contributor

@b-onc b-onc left a comment

Choose a reason for hiding this comment

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

:shipit:

@VojtaStavik VojtaStavik merged commit 9f042d0 into main Feb 3, 2021
@VojtaStavik VojtaStavik deleted the CIS-256-lazy-data branch February 3, 2021 12:01
@VojtaStavik VojtaStavik changed the title [CIS-256] Lazy model transformation for LLC [CIS-265] Lazy model transformation for LLC Feb 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🌐 SDK: StreamChat (LLC) Tasks related to the StreamChat LLC SDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants