-
Notifications
You must be signed in to change notification settings - Fork 14
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
[Investigation] See if there are optimizations we can make in our use of Core Data to improve app performance #1443
Comments
I have noticed and fixed the following issues as a result of this investigation (#1471):
|
Suggestions from this investigation that I wanted to get feedback on from other devs before creating tickets or implementing:
|
Thanks Bryan! It's great to have fresh eyes on this stuff. Responding to each of these individually:
This is one of my least favorite parts of Core Data, as we have no way for the compiler to enforce the thread isolation requirements of NSManagedObjectContexts. Except now we do have actor isolation in Swift 5. @joshuatbrown and I were noodling on whether it would be possible to isolate each of our background contexts to its own Can you do some research to see if there is prior art here? Surely someone has tried actor-isolating contexts or maybe people have done crazy things with property wrappers or macros that can help us here. We have done audits for this in the past but a pre-launch one sounds like a good idea. Can you write up a ticket for that?
I am actually exploring this now as part of #1426. The main problem I am running into is that the app can terminate before the cleanup has finished, but it might be a good part of the overall solution.
I actually did turn this on in the past, but it really hurt the scroll performance in the simulator, and sometimes caused long freezes. Aside from being annoying it also makes it harder to notice regressions in scroll performance during development. However, now that we are prioritizing #1459 we won't need to rely on subjective feelings of scroll performance so much. I'm game to try this again and if it's too annoying we'll just turn it off again. We have a Nos Diagnostics scheme that builds the app with this flag as well as
No, I don't think so. In general I think it's a best practice not to save inside NSManagedObject functions. This gives callers the freedom to use
Good question. I think I left some of those there on purpose, and others were added later. I could go either way on this. I guess I would rather just update the doc comment for now. Could you go ahead and do that? Some of those properties are nice to keep around, and as long as we delete enough stuff to make
This sounds good to me. Feel free to make that change if it won't take long or file another ticket.
Great point. Go ahead!
Agreed! I think @martindsq actually just created type like "EventPublisher" in a recent PR. Maybe you could file a separate ticket for this one as its some heavier refactoring and it would be a good opportunity to write some tests for these. |
Thanks, @mplorentz!
I didn't find too much about actor-isolation used with Core Data. Here's a Swift forums post where someone was struggling with it a bit: https://forums.swift.org/t/using-nsmanagedobjectcontext-background-context-with-actors/72546
5/6/7. I'll put these in a follow-up PR to avoid adding to an already-approved PR.
|
fixes and improvements related to Core Data usage #1443
minor refactor of Event+CoreDataClass #1443
I filed #1515 to look into actor-isolating Core Data contexts in the future. |
@bryanmontz @mplorentz - Is this ticket done and a new one has been created for the remaining work? |
@setch-l Yes, I believe this one could be closed. |
We've identified several critical areas of the app that we cannot continue to break. The goal of this ticket is to spend some time investigating our use of Core Data to see if there are optimizations we can make to improve performance in critical areas or in the app overall.
Some options for Deliverables:
The text was updated successfully, but these errors were encountered: