-
An implementation of a feature in our project that uses realm leans pretty heavily into keypath-filtered change subscriptions. That implementation will instantiate one keypath-filtered subscription per instance of a model type called a "collection". I am worried about the performance implications of this, and how far this will push the subscription system. Is there some concrete data about how many active subscriptions we can have concurrently active without performance breaking down? What would the worst usage pattern with respect to subscriptions be? For an estimation of scale, currently in the project we'd have about ~20 ambient subscriptions active at any given time, and for power users this one-subscription-per-collection assumption could push the number of ambient subscriptions well into the hundreds. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
I'm not super familiar with the Osu codebase, but if I understand the code correctly, this feature doesn't take advantage of keypath filtering at all. The way I read the intent, it can be roughly simplified to: List<IDisposable> tokens = new();
foreach (var collection in realm.All<BeatmapCollection>())
{
tokens.Add(collection.BeatmapMD5Hashes.SubscribeForNotifications(...));
} Since If my understanding is correct, then the main question is whether having 80-800 idle-ish subscriptions (I'm assuming the |
Beta Was this translation helpful? Give feedback.
Cool - I spoke with the team and we don't have explicit performance tests for this, but the overhead of individual subscriptions should scale linearly with a small constant factor for collections which don't see changes. Beyond 100(s) of individual subscriptions, we expect a single subscription with keypath filtering to be more efficient though, so once #3501 is released, you could optimize the use case like: