-
-
Notifications
You must be signed in to change notification settings - Fork 590
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
Factor out ReceiptAccumulator #3319
Factor out ReceiptAccumulator #3319
Conversation
a393d28
to
6bc9128
Compare
6bc9128
to
ef22653
Compare
Added @weeman1337 as a potential reviewer |
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.
💯 ! Thank you
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.
Looks good. 👍 Some smaller notes.
@@ -43,6 +44,12 @@ export interface IMinimalEvent { | |||
unsigned?: IUnsigned; | |||
} | |||
|
|||
export interface AccumulatedReceipt { |
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.
Looks like this belongs to the ReceiptAccumulator
and should eventually be moved to the receipt-accumulator
module?
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.
Fixed in next PR: #3320
Thank you @weeman1337 - I will address all your comments in my next PR |
Part of element-hq/element-web#24629
In order to allow us to write simple unit tests, factor out the part of the sync accumulator that does receipt handling. Later changes may well make this more self-contained. This change is intended to be simple enough that we can convince ourselves by examining it that it has the same behaviour as before.
This code is performance-critical, so I added a couple of tests. When I increased the
testSize
in those tests to 10 million and 1 million, I got these results:With the old code:
With the new code:
So this change appears to slow us slightly when we have lots of redundant receipts, and speed us up when we have lots of receipts that we want to keep around.
I expect the speed changes are due to the use of a
Map
instead of an object.I think the this change is acceptable, and I think using a Map is better generally, but am interested in others' opinions.
This change is marked as an internal change (Task), so will not be included in the changelog.