ably / ably-js

Javascript, Node, Typescript, React, React Native client library SDK for Ably realtime messaging service
https://ably.com/download
Apache License 2.0
316 stars 55 forks source link

Investigate parallelizing `cipher.decrypt` calls when decoding regular/presence/state messages #1906

Open VeskeR opened 1 week ago

VeskeR commented 1 week ago

See discussion in PR comments.

When decoding regular/presence (and state in future) messages we end up calling cipher.decrypt, which based on our current documentation only supports AES algorithm in CBC mode. Presumably, decryption for AES in CBC mode can be parallelized, so we may be able to improve those decoding calls using await Promise.all instead of doing them sequantially.

┆Issue is synchronized with this Jira Task by Unito

VeskeR commented 1 week ago

ok, upon further investigation it seems that even though cipher.decrypt might not be a problem here, the vcdiff decoding depends on the previous recevied payload in enable to be able to decode the next one (see code), so the intended way to use decode function is to call it sequentially for each received message data and wait for a result.

I think we're not going to parallelize the decode calls, but it is a good idea to add corresponding comments in the code explaining that decode is intended to be called sequentially

VeskeR commented 1 week ago

@owenpearson ^