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

Updated KeyBuilder Fast Access #3768

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

cschuchardt88
Copy link
Member

Description

Fixed with Disposing MemoryStream on ToArray(). Made a lot faster as well. Enforced Overflows and other lengths.

Type of change

  • Optimization (the change is only an optimization)
  • Style (the change is only a code style for better maintenance or standard purpose)
  • Bug fix (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)
  • This change requires a documentation update

How Has This Been Tested?

  • Unit Testing

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@nan01ab
Copy link
Contributor

nan01ab commented Feb 15, 2025

Any benchmark data?

_stream.WriteByte(prefix);
private void CheckLength(int length)
{
if ((length + _keyLength) > _cacheData.Length)
Copy link
Member

Choose a reason for hiding this comment

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

Increase it?

Copy link
Member Author

@cschuchardt88 cschuchardt88 Feb 15, 2025

Choose a reason for hiding this comment

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

why? Is not >= or what do you mean

Copy link
Member

Choose a reason for hiding this comment

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

I mean, increase the array instead of throw an error

Copy link
Member Author

@cschuchardt88 cschuchardt88 Feb 15, 2025

Choose a reason for hiding this comment

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

Since the Length is passed in, we need to enforce that length. 99% of the time we know the length up front?

Copy link
Member

Choose a reason for hiding this comment

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

Otherwise is not a hint, and is not working as before, it should not happen so it won't have any impact in the performance

Copy link
Member Author

Choose a reason for hiding this comment

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

I had @superboyiii test this on mainnet and testnet, no key is bigger than 64 bytes. So we need to enforce. If you want bigger key you must know the size before hand.

#3705 (review)

Copy link
Member

Choose a reason for hiding this comment

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

It haven't got any sense to me, throw an exception when is possible to increase the buffer, usability vs optimization? Could you clarify why we should not increase the buffer and preserve the previous behavior?

Copy link
Member Author

@cschuchardt88 cschuchardt88 Feb 16, 2025

Choose a reason for hiding this comment

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

I already did state that. You pass in a LENGTH. What's the point of doing that if it not enforced? Im sick of everything being programmed around these bugs. It needs to stop. Have some discipline.

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

Successfully merging this pull request may close these issues.

3 participants