-
Notifications
You must be signed in to change notification settings - Fork 1k
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
refactor(gossipsub): don't store messages within Arc
#3243
Conversation
So originally it came from here: #898 (comment) I think the idea was that we were allocating Looking at the current code it does seem like we are just cloning the raw GossipsubRpc. I believe at one point we were just cloning the Arc. See for example here: https://github.com/libp2p/rust-libp2p/blob/master/protocols/gossipsub/src/behaviour.rs#L539 I think somewhere along the line it has changed. The I'm indifferent if we want to keep the Arc to avoid the allocation or just remove it all together. I think this has come up quite a few times in the past, so its probably better to remove it so we don't forget again in the future. |
Thanks for digging up the conversation! I tried to check whether we are cloning the message some where by removing It compiled without errors which puzzled me initially but it makes sense if we are cloning the entire RPC message. I think I have an idea how to implement this in a more obvious way that isn't accidentally refactored away as easily. |
I opted to revert the commits again. The tests were broken because they only check the |
Yeah sounds good to me. The optimization was never benched and its dubious as to how much it is saving us. |
CI is broken because of #3252. |
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.
LGTM!
Description
Currently, we store messages to be sent to the
ConnectionHandler
in anArc
. However, we never actually clone these messages as we can see with this patch, hence we remove this wrapping.Related: #3242
Notes
@AgeManning I think we talked about this at some point but I forget the reasoning for why this is done. Can you recall it?
Links to any relevant issues
Open Questions
Change checklist