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

feat: MConnection prioritizes received messages based on their channel ID priority #1228

Closed
wants to merge 26 commits into from

Conversation

staheri14
Copy link
Collaborator

@staheri14 staheri14 commented Feb 14, 2024

Closes #1192

@staheri14 staheri14 self-assigned this Feb 14, 2024
@staheri14 staheri14 force-pushed the sanaz/asyn-onreaceive branch from 03782fa to 6fc3cee Compare February 15, 2024 01:33
@@ -869,7 +984,10 @@ func (ch *Channel) recvPacketMsg(packet tmp2p.PacketMsg) ([]byte, error) {
// suggests this could be a memory leak, but we might as well keep the memory for the channel until it closes,
// at which point the recving slice stops being used and should be garbage collected
ch.recving = ch.recving[:0] // make([]byte, 0, ch.desc.RecvBufferCapacity)
return msgBytes, nil

msgCopy := make([]byte, len(msgBytes))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[To reviewers] Without creating a new copy, the original output of this function msgBytes and the ch.recving slice would reference the same memory address. Consequently, if msgBytes is passed to another goroutine, it can lead to a race condition [and it does]. Therefore, it's necessary to create a fresh copy to prevent this issue.

@staheri14 staheri14 changed the title feat: async processing of incoming messages feat: MConnection prioritizes received messages based on their channel ID priority Feb 16, 2024
@staheri14
Copy link
Collaborator Author

The TestReactorConcurrency has become flaky, so investigating it.

@staheri14
Copy link
Collaborator Author

This PR is ready for review. I am currently waiting for the results from testground to confirm our plan to merge this new logic. Once confirmed, I will mark it as ready for review. In the meantime, please feel free to leave any comments or feedback you may have.

@evan-forbes
Copy link
Member

can we close this draft?

fixing the receive priority is a good idea, but imo we should instead focus on unblocking each channel/reactor, so something similar to cometbft/cometbft#3230

@staheri14
Copy link
Collaborator Author

can we close this draft?

fixing the receive priority is a good idea, but imo we should instead focus on unblocking each channel/reactor, so something similar to cometbft/cometbft#3230

Fine with me, if needed we can reopen it later perhaps.

@staheri14 staheri14 closed this Aug 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lack of channel ID prioritization in MConnection's message receiving process
3 participants