Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: Remove redundant heap allocation in kv_store::Value type definition #2379

Open
netrome opened this issue Oct 22, 2024 · 0 comments · May be fixed by #2411
Open

perf: Remove redundant heap allocation in kv_store::Value type definition #2379

netrome opened this issue Oct 22, 2024 · 0 comments · May be fixed by #2411
Assignees

Comments

@netrome
Copy link
Contributor

netrome commented Oct 22, 2024

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

@netrome netrome self-assigned this Oct 22, 2024
@netrome netrome linked a pull request Oct 30, 2024 that will close this issue
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant