-
Type: Task
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
4 - L (<= 1 quarter)
-
6228
Goals
Fast and non-lagging application
Actual Results
I met certain performance issues with 'ResultsNotifier' logic in my app.
So, I was create new project and test different issues.
Start info:
1) About 20k objects of type 'Message' in realm
2) 5 RLMResult's which subscribe of notifications of this messages
3) On each new step of tests - I add 5 times (5 write transactions), of 200 messages to realm
4) When I add new part of 200 messages, I immediately, inject one of them into another object 'Conversation' by separate write transaction
Steps to Reproduce
So, I have different amount of lags in this cases. I experimented with:
1) I try add or remove indexed properties for message, which used for fetch and sort, but, I think, this two cases is equal. How can I make sure, that 'IndexedProperties' worked correctly?
2) I try to change amount of RLMResults subscribed on my messages, as I expected - decrease amount to 1, - greatly increase performance up to 4x times. Increase amount to 100, - totally kill my app =)
3) I figure out that this is 3 function which eat all my CPU:
a) 'find_all'
b) 'calculate_changes'
c) 'do_sort', so without sort app working more better, but not so sure
4) In next test, I change query string for my fetches, and all of my lags gone, if I subscribe messages, from another conversation. (in this conversation no one messages)
5) After some test I'm discover that same tests are produce more laggy, even though amount of messages in base remains the same.
Here tests with inject newly messages as property of conversation (separate writeTransaction)
It gives a win by 2 times! Why is that?
Is it normal behaviour for this amount of objects in realm?
And, how can I improve my performance in this cases?
What about 'find_all' - how can I improve it? (and how it works? In my main app - it eat greatly more performance than in test project (and than 'do_sort' \ 'calculate_changes')
Code Sample
This is full of my code:
https://gist.github.com/Daivest/c6b5dfe9453124ffff8549131b52748e
This is xcodeproject:
TestPerformanceProject.zip
Version of Realm and Tooling
Realm framework version: 3.17.3
Xcode version: 10.2
iOS/OSX version: 10.14.4
Dependency manager + version: Cocoapods 1.7.1