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

Resolves #1923: Avoid copying continuation byte arrays by using ByteString internally #1924

Merged
merged 1 commit into from Nov 21, 2022

Conversation

alecgrieser
Copy link
Contributor

This updates the logic in the RecordCursorContinuation objects to avoid serializing a continuation all the way to a byte[] if it is not necessary. For example, when constructing protobuf objects that back continuations, child continuations can be constructed by calling .toByteString() on the continuation and passing that to the protobuf builder instead of serializing all the to a byte[] and then wrapping it back in a ByteString. This also makes sure that (as much as possible) the cursor implementations are more efficient when constructing a ByteString. For example, for the proto-based continuations, it should be able to return .toByteString() on the protobuf object instead of serializing the protobuf all the way to a byte[] and then wrapping it back up, which some implementations did previously.

Adopters who need a ByteString rather than a byte[] (for example, to pack the continuation into a protobuf) are also encouraged to switch to the newer method.

This resolves #1923. This also follows up from #1921, which introduced the zero copy ByteString to avoid copying immutable arrays.

@foundationdb-ci
Copy link
Contributor

Result of fdb-record-layer-pr-proto2 on Linux CentOS 7

  • Commit ID: f3ea6ba
  • Duration 0:07:43
  • Result: ❌ FAILED
  • Error: Error while executing command: ./gradlew --no-daemon --console=plain -b ./build.gradle build destructiveTest sonarqube -PcoreNotStrict -PreleaseBuild=false -PpublishBuild=false -PspotbugsEnableHtmlReport. Reason: exit status 1
  • Build Logs (available for 30 days)
  • Build Artifact (available for 30 days)

@foundationdb-ci
Copy link
Contributor

Result of fdb-record-layer-pr-proto3 on Linux CentOS 7

  • Commit ID: f3ea6ba
  • Duration 0:07:55
  • Result: ❌ FAILED
  • Error: Error while executing command: ./gradlew --no-daemon --console=plain -b ./build.gradle build destructiveTest sonarqube -PcoreNotStrict -PreleaseBuild=false -PpublishBuild=false -PspotbugsEnableHtmlReport. Reason: exit status 1
  • Build Logs (available for 30 days)
  • Build Artifact (available for 30 days)

Copy link
Contributor

@MMcM MMcM left a comment

Choose a reason for hiding this comment

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

Changes look good, but some test failures look to be actual regressions.

… using ByteString internally

This updates the logic in the `RecordCursorContinuation` objects to avoid serializing a continuation all the way to a `byte[]` if it is not necessary. For example, when constructing protobuf objects that back continuations, child continuations can be constructed by calling `.toByteString()` on the continuation and passing that to the protobuf builder instead of serializing all the to a `byte[]` and then wrapping it back in a `ByteString`. This also makes sure that (as much as possible) the cursor implementations are more efficient when constructing a `ByteString`. For example, for the proto-based continuations, it should be able to return `.toByteString()` on the protobuf object instead of serializing the _protobuf_ all the way to a `byte[]` and then wrapping it back up, which some implementations did previously.

Adopters who need a `ByteString` rather than a `byte[]` (for example, to pack the continuation into a protobuf) are also encouraged to switch to the newer method.

This resolves FoundationDB#1923.
@sonarcloud
Copy link

sonarcloud bot commented Nov 21, 2022

Please retry analysis of this Pull-Request directly on SonarCloud.

@sonarcloud
Copy link

sonarcloud bot commented Nov 21, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

0.0% 0.0% Coverage
8.9% 8.9% Duplication

@foundationdb-ci
Copy link
Contributor

Result of fdb-record-layer-pr-proto3 on Linux CentOS 7

@foundationdb-ci
Copy link
Contributor

Result of fdb-record-layer-pr-proto2 on Linux CentOS 7

@MMcM MMcM merged commit b7d7f6d into FoundationDB:main Nov 21, 2022
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.

Avoid copying continuation byte arrays by using ByteString internally
3 participants