fuel-core
fuel-core copied to clipboard
perf: Remove redundant heap allocation in `kv_store::Value` type definition
Context
The Value type is currently defined as
/// The value of the storage. It is wrapped into the `Arc` to provide less cloning of massive objects.
pub type Value = alloc::sync::Arc<Vec<u8>>;
Both the Arc and Vec are pointers to heap-allocated data, which means that we do two heap-lookups every time we read data from this type. We could skip the second heap allocation by replacing this type with Arc<[u8]>.
Definition of done
The kv_store::Value type is defined as an Arc<[u8]>.
References
Logan Smith has an interesting video on the topic which elaborates more on this https://www.youtube.com/watch?v=A4cKi7PTJSs