-
Notifications
You must be signed in to change notification settings - Fork 465
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
Limit request size per peer #4692
Conversation
936bcc3
to
f078842
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.
Are we progressing with this?
if (length > readOnlyList.Count) | ||
{ | ||
return readOnlyList; | ||
} |
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.
The original type like List<>
can still grow, so we shouldn't ever use this path
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.
Why? Its a read only list?
int startingReceiptsCountLimit = _getReceiptsCurrentBatchSize; | ||
GetReceiptsMessage msg = new(blockHashes.CappedTo(startingReceiptsCountLimit)); | ||
|
||
try | ||
{ | ||
Stopwatch sw = Stopwatch.StartNew(); | ||
TxReceipt[][] txReceipts = await SendRequest(msg, token); | ||
|
||
long elapsed = sw.ElapsedMilliseconds; | ||
if (elapsed < GetReceiptsLatencyLowWatermark && txReceipts.Length == startingReceiptsCountLimit) | ||
{ | ||
_getReceiptsCurrentBatchSize = Math.Min( | ||
(int)Math.Ceiling(startingReceiptsCountLimit * GetReceiptsBatchSizeAdjustmentFactor), | ||
GetReceiptsMaxBatchSize | ||
); | ||
} | ||
else if (elapsed > GetReceiptsLatencyHighWatermark) | ||
{ | ||
_getReceiptsCurrentBatchSize = Math.Max( | ||
(int)Math.Floor(startingReceiptsCountLimit / GetReceiptsBatchSizeAdjustmentFactor), | ||
GetReceiptsMinBatchSize | ||
); | ||
} | ||
|
||
return txReceipts; | ||
} | ||
catch (Exception) | ||
{ | ||
_getReceiptsCurrentBatchSize = Math.Max( | ||
(int)Math.Floor(startingReceiptsCountLimit / GetReceiptsBatchSizeAdjustmentFactor), | ||
GetReceiptsMinBatchSize | ||
); | ||
throw; | ||
} | ||
} |
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.
We have this code very similar in two places, should we make it reusable somehow?
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.
Probably
I thought I should push a PR for sync metrics first to see the reduced timeout, if any on server. |
Fixes | Closes | Resolves #
Changes:
Types of changes
What types of changes does your code introduce?
Put an
x
in the boxes that applyTesting
Requires testing
In case you checked yes, did you write tests??
Comments about testing , should you have some (optional)
Further comments (optional)
If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...