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

perf: improve mem reading in Memory #2667

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft

perf: improve mem reading in Memory #2667

wants to merge 5 commits into from

Conversation

Vovchyk
Copy link
Contributor

@Vovchyk Vovchyk commented Aug 2, 2024

Description

Motivation and Context

How Has This Been Tested?

Types of changes

  • 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)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • Tests for the changes have been added (for bug fixes / features)
  • Requires Activation Code (Hard Fork)
  • Other information:

Copy link

sonarcloud bot commented Aug 5, 2024

Copy link
Contributor

@fmacleal fmacleal left a comment

Choose a reason for hiding this comment

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

Nice job. I have a few comments, mostly cosmetics and nitpicks. Doesn't prevent the approval.

Question, I didn't see any test regarding some classes you created. Like the ones to convert to HexString or the arraycopy on MemorySlice. Do we already have these operations covered in other tests and wasn't necessary to add one?

return toHexString(0, length());
}

default String toHexStringV2(int off, int length) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need this v2 method? Can not we just use the default String toHexString(int off, int length) method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

just to emphasise that this is another version comparing to ByteUtil#toHexString(), which uses a 3rd-party lib. Added javadoc here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

also added jmh test here

@@ -128,6 +128,42 @@ default Bytes copyBytes() {
default BytesSlice slice(int from, int to) {
return new BytesSliceImpl(this, from, to);
}

Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think about convert this class to an abstract class? I think it could give us various advantages:

  • We could make both equals and hashcode methods part of the class and not implemented as static.
  • We can force the usage of BoundaryUtils.checkArrayIndexParam(length(), index)
  • Stop using default methods for defining common implementations and facilitate the testing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd rather use interface here. I guess it's quite similar to CharSequence interface that's being used for chars without concrete implementation of equals and hashCode

@Vovchyk Vovchyk changed the base branch from vovchyk/rlp-impv to vovchyk/native-cont-impv September 30, 2024 08:41
@Vovchyk Vovchyk marked this pull request as ready for review September 30, 2024 09:35
fmacleal
fmacleal previously approved these changes Sep 30, 2024
Copy link
Contributor

@fmacleal fmacleal left a comment

Choose a reason for hiding this comment

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

Nice test addition and refactor. Looks good.

asoto-iov
asoto-iov previously approved these changes Sep 30, 2024
@Vovchyk Vovchyk changed the base branch from vovchyk/native-cont-impv to master October 4, 2024 11:44
@Vovchyk Vovchyk dismissed stale reviews from asoto-iov and fmacleal October 4, 2024 11:44

The base branch was changed.

@@ -181,21 +185,20 @@
}

/** @see org.ethereum.crypto.cryptohash.Digest */
public void update(byte[] input)
public void update(BytesSlice input)

Check notice

Code scanning / CodeQL

Missing Override annotation Note

This method overrides
Digest.update
; it is advisable to add an Override annotation.
}

/** @see org.ethereum.crypto.cryptohash.Digest */
public void update(byte[] input, int offset, int len)
public void update(BytesSlice input, int offset, int len)

Check notice

Code scanning / CodeQL

Missing Override annotation Note

This method overrides
Digest.update
; it is advisable to add an Override annotation.
@Vovchyk Vovchyk force-pushed the vovchyk/mem-impv branch 2 times, most recently from dfaf622 to bc1b4b6 Compare October 9, 2024 09:01
Copy link

sonarcloud bot commented Oct 9, 2024

fmacleal
fmacleal previously approved these changes Oct 9, 2024
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.

3 participants