-
Notifications
You must be signed in to change notification settings - Fork 171
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
Improve performance when resurrecting an object with many backlinks #7218
Conversation
The process of first removing the backlink from the tombstone and then creating it again in the live object took a long time. As the backlinks will end up being identical, we can just move the whole structure from the tombstone to the new object and then just replace the link in the linking object without worring about backlinks. This change is only done for link and linklist properties.
4ede8fa
to
04b746f
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.
Very smart.
Pull Request Test Coverage Report for Build jorgen.edelbo_12
💛 - Coveralls |
auto t = m_table->get_opposite_table(col); | ||
auto c = m_table->get_opposite_column(col); | ||
auto backlinks = other.get_all_backlinks(col); | ||
|
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.
Clever idea. It leaks the implementation of backlinks storage a bit here, but we have accepted worse in the name of performance.
@@ -614,7 +612,7 @@ void SyncReplication::set_clear(const CollectionBase& set) | |||
void SyncReplication::dictionary_update(const CollectionBase& dict, const Mixed& key, const Mixed& value) | |||
{ | |||
// If link is unresolved, it should not be communicated. | |||
if (value.is_type(type_Link, type_TypedLink) && value.get<ObjKey>().is_unresolved()) { | |||
if (value.is_unresolved_link()) { |
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.
👍
@@ -794,4 +806,69 @@ TEST(Links_ManyObjects) | |||
tr->commit(); | |||
} | |||
|
|||
TEST(Unresolved_PerformanceLinks) |
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.
It would be ideal to have a micro benchmark for this so we can track it long term to detect regressions, but that's not blocking for me.
Co-authored-by: James Stone <[email protected]>
Is there any reason this change might have introduced a performance regression for very large initial sync jobs? Note that the changesets go from taking ~430ms to ~3000ms after a number of them have been processed. If I terminate my app (built with the Realm Swift SDK) and run it again, the changesets again process in about 430ms. The only change made to the app was updating Realm from 10.44.x to 10.45.2. I did not observe this slowdown during initial bootstrapping on 10.44.x. |
The process of first removing the backlink from the tombstone and then creating it again in the live object took a long time. As the backlinks will end up being identical, we can just move the whole structure from the tombstone to the new object and then just replace the link in the linking object without worring about backlinks.
This change is only done for link and linklist properties.
Fixes #7217
What, How & Why?
☑️ ToDos
bindgen/spec.yml
, if public C++ API changed