Skip to content

Use a more efficient serializer and write bytes directly to disk #2138

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

Merged
merged 1 commit into from
Aug 20, 2025

Conversation

tylerbenson
Copy link
Member

Instead of an intermediary byte array.

The OTel Java SDK has a hand-coded and optimized serializer implementation that is well tested and used extensively. This PR switches to using that serializer.

It is also more efficient to serialize directly to the file output stream instead of an intermediary byte array, so I used the same marshaling strategy used by the SDK and passed the marshaler down to the WritableFile.

See relevant discussion here:
#1911

Instead of an intermediary byte array.

The OTel Java SDK has a hand-coded and optimized serializer implementation that is well tested and used extensively. This PR switches to using that serializer.

It is also more efficient to serialize directly to the file output stream instead of an intermediary byte array, so I used the same marshaling strategy used by the SDK and passed the marshaler down to the WritableFile.
Copy link
Contributor

@LikeTheSalad LikeTheSalad left a comment

Choose a reason for hiding this comment

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

Thank you!

Copy link
Member

@zeitlinger zeitlinger left a comment

Choose a reason for hiding this comment

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

I would have expected more work - but the integration test works 😄

@@ -38,10 +38,11 @@ public static <T> ToDiskExporterBuilder<T> builder(Storage storage) {
return new ToDiskExporterBuilder<>(storage);
}

public CompletableResultCode export(Collection<EXPORT_DATA> data) {
public synchronized CompletableResultCode export(Collection<EXPORT_DATA> data) {
Copy link
Member

Choose a reason for hiding this comment

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

why sychronized?

Copy link
Member Author

Choose a reason for hiding this comment

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

The serializer is stateful now, plus it seems like a bad idea to allow multiple exports to be writing to disk concurrently anyway.

@trask trask added this to the v1.49.0 milestone Aug 20, 2025
@trask trask added this pull request to the merge queue Aug 20, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 20, 2025
@trask trask added this pull request to the merge queue Aug 20, 2025
Merged via the queue into open-telemetry:main with commit 2b8de4b Aug 20, 2025
31 checks passed
@tylerbenson tylerbenson deleted the tyler/disk-serializer branch August 20, 2025 21:53
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.

4 participants