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

Limit request size per peer #4692

Closed
wants to merge 1 commit into from
Closed

Conversation

asdacap
Copy link
Contributor

@asdacap asdacap commented Oct 3, 2022

Fixes | Closes | Resolves #

Anything marked as optional that you didn't need to fill in, please remove it from the PR description. Choose one of the keywords above to refer to the issue this PR solves, followed by the issue number (e.g Fixes # 666). If there is no issue, remove the line. Remove this note after reading.

Changes:

Types of changes

What types of changes does your code introduce?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Other (please describe):

Testing

Requires testing

  • Yes
  • No

In case you checked yes, did you write tests??

  • Yes
  • No

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...

@asdacap asdacap force-pushed the perf/limited-request-size branch from 936bcc3 to f078842 Compare October 18, 2022 00:18
Copy link
Member

@LukaszRozmej LukaszRozmej left a 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?

Comment on lines +9 to +12
if (length > readOnlyList.Count)
{
return readOnlyList;
}
Copy link
Member

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

Copy link
Contributor Author

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?

Comment on lines +154 to 188
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;
}
}
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Probably

@asdacap
Copy link
Contributor Author

asdacap commented Oct 26, 2022

Are we progressing with this?

I thought I should push a PR for sync metrics first to see the reduced timeout, if any on server.

@asdacap asdacap closed this Mar 5, 2023
@rubo rubo deleted the perf/limited-request-size branch December 20, 2023 21:30
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.

2 participants