-
Notifications
You must be signed in to change notification settings - Fork 999
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
feat(kad): use Bytes
for Record::value
#4753
base: master
Are you sure you want to change the base?
Conversation
dcc2036
to
6074c1e
Compare
Similar in scope to #4751 This should make end user handling of Records much lighter |
6074c1e
to
caffe74
Compare
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.
Looks good, one more suggestion :)
Bytes
for Record::value
Updated 🙇 |
@@ -314,7 +314,7 @@ pub enum KadResponseMsg { | |||
/// The key of the record. | |||
key: record::Key, | |||
/// Value of the record. | |||
value: Vec<u8>, | |||
value: Bytes, |
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.
I just explored this a bit more and KadResponseMsg
is actually never cloned so we can probably just remove the trait and this here.
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.
Ah sorry I think I posted this to the wrong thread here.
@@ -422,7 +422,7 @@ fn resp_msg_to_proto(kad_msg: KadResponseMsg) -> proto::Message { | |||
key: key.to_vec(), | |||
record: Some(proto::Record { | |||
key: key.to_vec(), | |||
value, | |||
value: value.to_vec(), |
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.
Same as with the gossipsub branch, I am a bit doubtful that this actually yields improvements because we are copying here again.
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.
Hmmm, the knock on is that we're reading from the Record
which is and can be cloned in kad and user space. So we'll end up allocating to just have vecs in here ( if the Record contains Bytes
for the value
which I think it should...).
That comes in
HandlerIn::PutRecordRes {
key: record.key,
value: record.value, // <- we'd have to convert _from_ Bytes here,
request_id,
},```
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.
Sorry the above was for another comment response.
We are still having to convert to vec
here, but that should become the only clone, vs a variety of clone
ing that happens in the kad layers at the moment.
So this should still yield reduce mem.
This pull request has merge conflicts. Could you please resolve them @joshuef? 🙏 |
9bef5dc
to
16b1ee5
Compare
Small update/rebase there. |
16b1ee5
to
2c14ba1
Compare
This pull request has merge conflicts. Could you please resolve them @joshuef? 🙏 |
2c14ba1
to
5468e0e
Compare
What's the proper way w/r/t version bumping here? Should I be bumping in the cargo.toml already? Or just noting the unreleased nature in the changelog? |
This pull request has merge conflicts. Could you please resolve them @joshuef? 🙏 |
@thomaseizinger Are there any blockers to landing this at the moment? Are we looking at the protobuf |
Two things:
As a first step, we should probably prepare for making all fields of I understand that you probably don't want to wait for that to land as we've just cut a breaking release :) |
That's fine, I can explore a bit more easily now that we're atop 0.53 in our repo anyway. I can understand wanting to know more concretely what's afoot and the benefits we'd get here. Do you have a recommended test setup/bench for allocations at the moment? (You can something in another thread, but I don't recall where that was). Also makes sense w/r/t Record APIs 👍
I don't think so? It converts every kad-space clone of Plus any user space gains when handling Records? I'll try and form a minimal change from our codebase (with the libp2p branch being the only diff) and get some numbers / repro steps if that's helpful 👍 |
That would be great! |
This should help avoid potentially costly clones
5468e0e
to
44c94ae
Compare
Description
This should help avoid potentially costly clones over
Record
.Notes & open questions
Change checklist