-
Notifications
You must be signed in to change notification settings - Fork 461
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
Less allocations for node processing #6967
Conversation
src/Nethermind/Nethermind.Network.Discovery/RoutingTable/NodeTable.cs
Outdated
Show resolved
Hide resolved
src/Nethermind/Nethermind.Network.Discovery/RoutingTable/NodeBucket.cs
Outdated
Show resolved
Hide resolved
if (count < _capacity / 2) | ||
{ | ||
// Reduced to less than half of the capacity, resize the array. | ||
T[] newArray = _arrayPool.Rent(count); | ||
_array.AsSpan(0, count).CopyTo(newArray); | ||
T[] oldArray = Interlocked.Exchange(ref _array, newArray); | ||
_capacity = newArray.Length; | ||
_arrayPool.Return(oldArray); |
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.
Is it worth it, to potentially copy over this data to the new buffer?
I expect this data to be consumed fairly quickly and the whole buffer would return.
IMO probably not worth it at
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 consumers only want 12 or 16 elements by default; so copy isn't that big, but can be hundreds or thousands of nodes
Changes
Addresses the following allocations
Types of changes
What types of changes does your code introduce?
Testing
Requires testing