-
Notifications
You must be signed in to change notification settings - Fork 9
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
Use export_room_keys_stream to reduce export memory usage #105
Conversation
331474c
to
bcc13c2
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.
lgtm. Is it already tested or could it benefit from a new test, at least validating what the return type actually is? Thanks!
T: Serialize, | ||
S: Stream<Item = T>, | ||
{ | ||
let mut stream_json = vec![]; |
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.
Would initializing with an initial capacity make sense? Assuming the stream's not empty, we can likely avoid many reallocations by having a large initial size here?
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.
I think so, but I don't know how to estimate a good size here. Do we do anything similar anywhere else in the code? Do we have any rules of thumb?
It's already tested in machine.test.ts. |
bcc13c2
to
0861298
Compare
Signed-off-by: Andy Balaam <[email protected]>
0861298
to
66c6ddf
Compare
To reduce memory usage during export - see matrix-org/matrix-rust-sdk-crypto-wasm#105
To reduce memory usage during export - see matrix-org/matrix-rust-sdk-crypto-wasm#105
Applies on top of #106
Make use of the new
export_room_keys_stream
method from matrix-org/matrix-rust-sdk#3144 to avoid one copy of the keys in the export process, by directly serialising to a JSON string, without taking the intermediate step into aVec<ExportedRoomKey>
.Part of element-hq/element-web#26681