parity-common
parity-common copied to clipboard
[rlp] consider adding a way to allocate less buffer space
Currently rlp
lists allocate a new RlpStream
which allocates a Vec<u8>
with a capacity of 1024. For many calls the size is much smaller than this and can often be calculated easily at the call site. Consider adding some way to ask for a bespoke buffer size something like new_list_with_capacity(4, 86)
(4 items, initial capacity of 86 bytes). Some calls likely need plenty more than 1024.
e.g. https://github.com/paritytech/parity-ethereum/blob/master/ethcore/sync/src/chain/requester.rs#L82 (from sync
) or https://github.com/paritytech/parity-ethereum/blob/master/util/patricia-trie-ethereum/src/rlp_node_codec.rs#L155 (from patricia-trie
).
Bonus points for collecting stats about RLP sizes actually used, maybe using historian
?