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-733] Load expensive CoreData properties lazily #906
Conversation
c12c00d
to
11d81ac
Compare
Codecov Report
@@ Coverage Diff @@
## main #906 +/- ##
==========================================
- Coverage 87.21% 87.14% -0.07%
==========================================
Files 238 238
Lines 9102 9147 +45
==========================================
+ Hits 7938 7971 +33
- Misses 1164 1176 +12
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
86b80d7
to
61936f9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great 🎉 Before merging this, let's address the regressions to our internal API.
Sources/StreamChat/Controllers/ChannelController/ChannelController+SwiftUI_Tests.swift
Outdated
Show resolved
Hide resolved
b0f6559
to
844f116
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At first, this spinned my head around. After seeing the bigger picture of @Cached
property wrapper and the implementation I see this is awesome 👍
$_latestReactions = { | ||
Set( | ||
MessageReactionDTO | ||
.loadLatestReactions(for: dto.id, limit: 5, context: context) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hardcoded limit is okay? Same for line 459.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure, just moved the original code to make compiler happy. In ChannelDTO
there is originally a TODO for that.
844f116
to
fcded8b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great 👍 Just a couple of nit comments and then please merge 🎉
fcded8b
to
f463c08
Compare
Improve some
asModel
function performance by loading expensive top level properties lazily. This means that affected model structs are now thread-confined which should be addressed later as it does not make much sense for value types.Some other changes were necessary:
@Cached
wrapper now hascomputeValue
closure asprojectedValue
as otherwise it cannot be set from outside as_cachedWrapper
property is private ➡️ this will not be possible as__mentionedUsers
is inaccessible because it is private automaticallyI consider the semantic change of
_ChatChannel
and_ChatMessage
to be breaking so it is marked this way in changelog, even though the API remains unchanged.