Skip to content

Buffer ByteArrayOutputStream in serialization#2724

Merged
ChristianGruen merged 1 commit into
BaseXdb:mainfrom
GuntherRademacher:buffer-bytearrayoutputstream
Jul 15, 2026
Merged

Buffer ByteArrayOutputStream in serialization#2724
ChristianGruen merged 1 commit into
BaseXdb:mainfrom
GuntherRademacher:buffer-bytearrayoutputstream

Conversation

@GuntherRademacher

Copy link
Copy Markdown
Member

PrintOutput.get() left a java.io.ByteArrayOutputStream unbuffered, so every serialized codepoint went through a synchronized single-byte write + ensureCapacity. In a benchmark this caused about 28% of the total runtime.

It is now wrapped in BufferOutput like any other stream. OutputSerializer.close() flushes, and internally the serializer is fed ArrayOutput, not a JDK ByteArrayOutputStream - only external BAOS sinks are affected.

@GuntherRademacher GuntherRademacher changed the title Buffer ByteArrayOutputStream serialization Buffer ByteArrayOutputStream in serialization Jul 15, 2026
@ChristianGruen
ChristianGruen merged commit 511b1e0 into BaseXdb:main Jul 15, 2026
1 check passed
@ChristianGruen
ChristianGruen deleted the buffer-bytearrayoutputstream branch July 15, 2026 16:41
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.

2 participants