-
Notifications
You must be signed in to change notification settings - Fork 35
RSCBC-32: Reduce allocations on KV hot paths #473
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,13 +16,15 @@ | |
| * | ||
| */ | ||
|
|
||
| use bytes::Bytes; | ||
|
|
||
| use crate::error; | ||
| use crate::mutationtoken::MutationToken; | ||
| use std::time::Duration; | ||
|
|
||
| #[derive(Clone, Debug, Eq, PartialEq, Hash)] | ||
| pub struct GetResult { | ||
| pub value: Vec<u8>, | ||
| pub value: Bytes, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would be a serious breaking change. I'm not sure you can change this without a v2 release?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's in core, which is basically labelled as "do not use" so should be very low risk. |
||
| pub flags: u32, | ||
| pub datatype: u8, | ||
| pub cas: u64, | ||
|
|
@@ -32,7 +34,7 @@ pub struct GetResult { | |
| pub struct GetMetaResult { | ||
| pub cas: u64, | ||
| pub flags: u32, | ||
| pub value: Vec<u8>, | ||
| pub value: Bytes, | ||
| pub datatype: u8, | ||
| pub server_duration: Option<Duration>, | ||
| pub expiry: u32, | ||
|
|
@@ -54,15 +56,15 @@ pub struct DeleteResult { | |
|
|
||
| #[derive(Clone, Debug, Eq, PartialEq, Hash)] | ||
| pub struct GetAndLockResult { | ||
| pub value: Vec<u8>, | ||
| pub value: Bytes, | ||
| pub flags: u32, | ||
| pub datatype: u8, | ||
| pub cas: u64, | ||
| } | ||
|
|
||
| #[derive(Clone, Debug, Eq, PartialEq, Hash)] | ||
| pub struct GetAndTouchResult { | ||
| pub value: Vec<u8>, | ||
| pub value: Bytes, | ||
| pub flags: u32, | ||
| pub datatype: u8, | ||
| pub cas: u64, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you're considering leveraging Bytes elsewhere, why not use it here as well? One issue with using Cow when you use Bytes elsewhere is that you do not get the ability to maintain the same Bytes object through a function like this without resorting to some hackery.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason for Cow here is that we return actually either a borrow or an owned value. In the case of Bytes i think we'd need to allocate in the borrow case.