Skip to content
This repository has been archived by the owner on Feb 1, 2023. It is now read-only.

Frequent allocations setting context deadlines #367

Closed
Stebalien opened this issue Apr 22, 2020 · 3 comments · Fixed by #369
Closed

Frequent allocations setting context deadlines #367

Stebalien opened this issue Apr 22, 2020 · 3 comments · Fixed by #369

Comments

@Stebalien
Copy link
Member

profile001

@dirkmc
Copy link
Contributor

dirkmc commented Apr 22, 2020

The reason for the allocation is that we set a timeout each time we send a message.
I believe we're getting so many of them because when we send a broadcast want or a cancel to thousands of peers we set a timeout for each one.

One idea that occurs to me is to keep a pool of contexts with timeout, where the timeouts are close to each other.
For example for a broadcast to peer A, peer B and peer C, the message timeout deadline will be roughly the same for all three. So before setting the timeout they check the pool to see if there's a context with timeout that falls within eg 10ms of the deadline they need.

@Stebalien
Copy link
Member Author

As far as I can tell, we only need this context in some special cases (e.g., when calling Connect). We don't do that every time. Can we create a context on demand?

@dirkmc
Copy link
Contributor

dirkmc commented Apr 22, 2020

That's true we only need it when calling connect and when opening a stream, but that should only happen once per peer. So actually I think we can avoid using WithDeadline altogether for most calls to SendMsg()

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants