-
Notifications
You must be signed in to change notification settings - Fork 269
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
fix(sdk): Improve performance of RoomEvents::maybe_apply_new_redaction
#4616
fix(sdk): Improve performance of RoomEvents::maybe_apply_new_redaction
#4616
Conversation
…on`. This patch improves the performance of `RoomEvents::maybe_apply_new_redaction`. This method deserialises all the events it receives, entirely. If the event is not an `m.room.redaction`, then the method returns early. Most of the time, the event is deserialised for nothing because most events aren't of kind `m.room.redaction`! This patch first uses `Raw::get_field("type")` to detect the type of the event. If it's a `m.room.redaction`, then the event is entirely deserialized, otherwise the method returns. When running the `test_lazy_back_pagination` from matrix-org#4594 with 10'000 events, prior to this patch, this method takes 11% of the execution time. With this patch, this method takes 2.5%.
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.
LGTM!
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #4616 +/- ##
=======================================
Coverage 85.73% 85.73%
=======================================
Files 291 291
Lines 33309 33311 +2
=======================================
+ Hits 28557 28559 +2
Misses 4752 4752 ☔ View full report in Codecov by Sentry. |
Nice. This calls for a deserialization cache, because we keep deserializing events all over the place… |
Indeed. I was working on this but stopped due to lack of time, but it's definitely something that may improve the performance. |
This patch adds matrix-org#4601, matrix-org#4608, matrix-org#4612 and matrix-org#4616 in their respective `CHANGELOG.md`s. +
This patch adds matrix-org#4601, matrix-org#4608, matrix-org#4612 and matrix-org#4616 in their respective `CHANGELOG.md`s.
This patch adds matrix-org#4601, matrix-org#4608, matrix-org#4612 and matrix-org#4616 in their respective `CHANGELOG.md`s.
This patch improves the performance of
RoomEvents::maybe_apply_new_redaction
. This method deserialises all the events it receives, entirely. If the event is not anm.room.redaction
, then the method returns early. Most of the time, the event is deserialised for nothing because most events aren't of kindm.room.redaction
!This patch first uses
Raw::get_field("type")
to detect the type of the event. If it's am.room.redaction
, then the event is entirely deserialised, otherwise the method returns.When running the
test_lazy_back_pagination
from#4594 with 10'000 events, prior to this patch, this method takes 11% of the execution time. With this patch, this method takes 2.5%.
Call tree before this patch:
After this patch:
EventCache
storage #3280