This is an automated email from the ASF dual-hosted git repository.
tabish pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-protonj2.git
The following commit(s) were added to refs/heads/main by this push:
new 22ac0613 PROTON-2591 Provide a non-default allocation size for message
buffers
22ac0613 is described below
commit 22ac0613f24c3818b8ccc86c8cb7be4eb79e4302
Author: Timothy Bish <[email protected]>
AuthorDate: Tue Aug 9 18:51:41 2022 -0400
PROTON-2591 Provide a non-default allocation size for message buffers
Provide a larger than default size for initial buffer allocation for
encoding messages (256 bytes) which avoids a rapid buffer reallocation
and copy for most small outgoing messages.
---
.../org/apache/qpid/protonj2/client/impl/ClientMessageSupport.java | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git
a/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/impl/ClientMessageSupport.java
b/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/impl/ClientMessageSupport.java
index cf4ad91f..f8dd8f45 100644
---
a/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/impl/ClientMessageSupport.java
+++
b/protonj2-client/src/main/java/org/apache/qpid/protonj2/client/impl/ClientMessageSupport.java
@@ -54,6 +54,8 @@ public abstract class ClientMessageSupport {
private static final Encoder DEFAULT_ENCODER =
CodecFactory.getDefaultEncoder();
private static final Decoder DEFAULT_DECODER =
CodecFactory.getDefaultDecoder();
+ private static final int DEFAULT_BUFFER_ALLOCATION = 256;
+
private static final ThreadLocal<EncoderState> THREAD_LOCAL_ENCODER_STATE =
ThreadLocal.withInitial(() -> DEFAULT_ENCODER.newEncoderState());
private static final ThreadLocal<DecoderState> THREAD_LOCAL_DECODER_STATE =
@@ -105,7 +107,7 @@ public abstract class ClientMessageSupport {
}
public static ProtonBuffer encodeMessage(Encoder encoder, EncoderState
encoderState, ProtonBufferAllocator allocator, AdvancedMessage<?> message,
Map<String, Object> deliveryAnnotations) throws ClientException {
- ProtonBuffer buffer = allocator.allocate();
+ ProtonBuffer buffer = allocator.allocate(DEFAULT_BUFFER_ALLOCATION);
Header header = message.header();
MessageAnnotations messageAnnotations = message.annotations();
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]