-
Notifications
You must be signed in to change notification settings - Fork 837
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(net): adaptable request timeouts #789
feat(net): adaptable request timeouts #789
Conversation
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.
amazing, tysm for picking this up
/// Amount of RTTs before timeout | ||
const TIMER_MULTIPLIER: u32 = 4; | ||
|
||
// TODO: use a more sophisticated formula |
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.
worth having a look how geth does 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.
Just checked. They use the same formula.
Codecov Report
@@ Coverage Diff @@
## main #789 +/- ##
==========================================
- Coverage 73.13% 73.10% -0.03%
==========================================
Files 274 275 +1
Lines 28251 28653 +402
==========================================
+ Hits 20660 20946 +286
- Misses 7591 7707 +116
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it 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.
awesome
@@ -159,31 +172,31 @@ impl ActiveSession { | |||
on_request!(req, BlockHeaders, GetBlockHeaders); | |||
} | |||
EthMessage::BlockHeaders(resp) => { | |||
on_response!(self, resp, GetBlockHeaders); | |||
on_response!(resp, GetBlockHeaders); |
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.
oh nice
req.request.send_err_response(RequestError::Timeout); | ||
} | ||
} | ||
|
||
/// Updates the request timeout with a request's timestamps | ||
fn update_request_timeout(&mut self, sent: Instant, received: Instant) { |
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.
this makes sense to me,
I'd like to see some sanity tests for this, I think we can split this into to parts:
- standalone,testable function that does the computation
update_request_timeout
calls this function and updates the time out
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.
Done! Should we #[inline]
the helper function?
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.
sg, let's do that!
and add tests for it
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,
one idea I have is to add an Atomic
into the ActiveSessionHandle
which holds the timeout, this way we can make use of the value when selecting peers, wdyt?
It would be useful. You mean something like this? // handle.rs
pub(crate) struct ActiveSessionHandle<'a> {
...
pub(crate) request_timeout: &'a AtomicU64,
}
// active.rs
pub(crate) struct ActiveSession {
...
pub(crate) request_timeout: AtomicU64,
} |
yeh |
Added! |
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.
thanks,
can we extract the whole shared atomic from this PR and add this separately? because there some things we need to figure out while doing so
This reverts last two commits
Yeah, sure. Just pushed the changes. Now i'm going to open an issue. |
Closes: #689
This PR adds timeout adapting via RTT estimation for each peer.