element-web icon indicating copy to clipboard operation
element-web copied to clipboard

batching of `m.room_key` to-device messages is suboptimal

Open richvdh opened this issue 2 years ago • 3 comments

When we send out m.room_key messages to share a new encryption session, we attempt to batch those messages into groups of 20 per call to /sendToDevice. However the batching logic is distinctly suboptimal and we often end up creating much smaller batches.

I'm also not really sure why 20 was chosen as the target.

This leads to lots of requests to the /sendToDevice endpoint and general slowness in sending out room keys, potentially causing unable-to-decrypt errors (https://github.com/vector-im/element-meta/issues/245) and causing the recipient to start sending out m.room_key_request messages, exacerbating the problem.

richvdh avatar Feb 27 '23 12:02 richvdh

Likely we will fix this as part of https://github.com/vector-im/element-web/issues/21972 rather than spending time fixing it in an implementation that will be thrown away.

richvdh avatar Feb 27 '23 12:02 richvdh

Rust SDK limit is set to 250

Added a task in regression test list to later implement.

BillCarsonFr avatar Feb 27 '24 14:02 BillCarsonFr

Rust SDK limit is set to 250

... and, more importantly, its batching logic looks sensible

richvdh avatar Feb 27 '24 14:02 richvdh

Pending complement-crypto test to check that we batch in as large a chunk as possible i.e 250.

kegsay avatar Mar 15 '24 12:03 kegsay

This was done.

kegsay avatar May 17 '24 11:05 kegsay