scylladb/scylla-rust-driver

scylla-cql: Prevent allocations when deserializing custom_payload.

Opened this issue · 0 comments

custom payload deserialization uses types::read_bytes_map which returns HashMap<String, Vec<u8>>.
Those allocations are unnecessary because we don't return custom payload to the user - and even if we did it could be done in more clever way.

Deserializing to HashMap<String, Bytes> would improve the situation without very deep changes. Alternatively we could deserialize to HashMap<String, &[u8]> or even HashMap<&str, &[u8]>, but that may require deeper changes.

Custom payload is a rarely used feature, so this overhead is not problematic for now.
With tablets it would cause 2 additional allocations when tablet feedback is received - not too bad, but it would be nice to fix it.