-
Type: Bug
-
Resolution: Cannot Reproduce
-
Priority: Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: None
What happened?
Background: We are currently using Realm 3.3.0 and from time to time we are measuring times of db operations (inserts, reads, updates, deletes) in several devices both on iOS and Android platforms. The overall conclusion is that Realm has performance degradation on reads and updates operations but in general inserts and delete op are faster. I've compared Realm 3.3.0 against several versions 5.1.2, 10.1.2 and 10.10.0 Performance degradation is main reason why we don't update Realm version, because it's significant especially on older devices.
On version 10.8.0 there is huge performance drop on updates in newer apple devices like iphone X / iphone 12 on updates with many transactions. On version 10.7.1 my test case on iphone X took 200ms and 10.8.0 over 11000ms, thats over 50-times slower. The same problem is with delete operations with many transactions.
On Iphone 6+ update in version 3.3.0 took 3800ms and in version 10.10.0 8000ms which is 2 times slower, but still faster than on new iphones
Repro steps
My test case is:
- create db
- insert 1000 objects to db
- measure 500 updates, (each update is in separate transaction, this way I simulate actual usage of an app by user)
- delete db
I perform the test 15 times and only step 3 is measured.
Version
Mono 6.12.0.93 / Xamarin.iOS 15.0.0.6
What SDK flavour are you using?
Local Database only
What type of application is this?
Xamarin
Client OS and version
iphone X (15.2) / iphone 12 (15.4)
Code snippets
My data structure is simple:
public class Publication : RealmObject, IPublication { [PrimaryKey] public string Id { get; set; } public string Title { get; set; } public string CoverUrl { get; set; } public int Version { get; set; } [Indexed] public int RemoteId { get; set; } public bool HasCover => string.IsNullOrEmpty(CoverUrl) == false; public int DownloadPercentage { get; set; } public string SomeDescription { get; set; } [Backlink(nameof(PublicationCollection.Publications))] public IQueryable<PublicationCollection> Collections { get; } } public class PublicationCollection : RealmObject, IPublicationCollection { [PrimaryKey] public string Id { get; set; } public string Name { get; set; } [Indexed] public int RemoteId { get; set; } public IList<Publication> Publications { get; } public int PublicationsCount => Publications.Count; public string CoverUrl => Publications.FirstOrDefault(x => x.CoverUrl != null)?.CoverUrl; public bool HasCover => CoverUrl != null; }
Code which is measured in this case:
public override int UpdatePublicationsInManyTransactions() { var total = 0; var publications = _realm.All<Publication>().Where(x => x.Version == 1).ToList(); foreach (var publication in publications) { _realm.Write(() => { publication.Version = 2; }); total++; } return total; }
Stacktrace of the exception/crash you're getting
No response
Relevant log output
No response