<div dir="ltr">Hi <span style="font-size:12.800000190734863px">Stuart</span>,<div><br></div><div><div>Spring Framework 5 uses Undertow APIs directly, i.e. not going through the Servlet API.</div><div>When reading the request the ByteBufferPool is obtained from the connection</div><div>and then the PooledByteBuffer is allocated and used [1].</div><div>Also the PooledByteBuffer is closed in ExchangeCompletionListener [2].</div><div><br></div><div>So currently the usage is limited only to the request reading.</div><div>In order to extend the usage of the ByteBufferPool we need to be able to allocate buffers with a concrete size.</div><div>At the moment (what I saw in the sources) the ByteBufferPool is created with a specific buffer size</div><div>and the pooled buffers are created with exactly this size.</div><div><br></div><div>For comparison see the io.netty.buffer.PooledByteBufAllocator in Netty</div><div>which provides a functionality to allocated buffers with a specific size [3], [4], [5].</div><div><br></div><div>So is it possible to achieve the same with the Undertow&#39;s ByteBufferPool?</div><div>If such functionality is not existing do you think it is feasible to add such API?</div><div><br></div><div>Thanks,</div><div>Violeta</div></div><div><br></div><div><div>[1] <a href="https://github.com/spring-projects/spring-framework/blob/master/spring-web/src/main/java/org/springframework/http/server/reactive/UndertowServerHttpRequest.java#L144-L148">https://github.com/spring-projects/spring-framework/blob/master/spring-web/src/main/java/org/springframework/http/server/reactive/UndertowServerHttpRequest.java#L144-L148</a></div><div>[2] <a href="https://github.com/spring-projects/spring-framework/blob/master/spring-web/src/main/java/org/springframework/http/server/reactive/UndertowServerHttpRequest.java#L127-L133">https://github.com/spring-projects/spring-framework/blob/master/spring-web/src/main/java/org/springframework/http/server/reactive/UndertowServerHttpRequest.java#L127-L133</a></div><div>[3] <a href="https://github.com/netty/netty/blob/4.1/buffer/src/main/java/io/netty/buffer/AbstractByteBufAllocator.java#L107-L112">https://github.com/netty/netty/blob/4.1/buffer/src/main/java/io/netty/buffer/AbstractByteBufAllocator.java#L107-L112</a></div></div><div>[4] <a href="https://github.com/netty/netty/blob/4.1/buffer/src/main/java/io/netty/buffer/PooledByteBufAllocator.java#L301">https://github.com/netty/netty/blob/4.1/buffer/src/main/java/io/netty/buffer/PooledByteBufAllocator.java#L301</a></div><div>[5] <a href="https://github.com/netty/netty/blob/4.1/buffer/src/main/java/io/netty/buffer/PooledByteBufAllocator.java#L318">https://github.com/netty/netty/blob/4.1/buffer/src/main/java/io/netty/buffer/PooledByteBufAllocator.java#L318</a></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-06-14 3:21 GMT+03:00 Stuart Douglas <span dir="ltr">&lt;<a href="mailto:sdouglas@redhat.com" target="_blank">sdouglas@redhat.com</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">It should be used anytime you require a large direct buffer (generally<br>
for IO operations). Depending on your app you may not need to use them<br>
directly at all, although Undertow will always use them internally.<br>
<br>
The buffers are fixed size which is determined dynamically (unless<br>
explicitly specified), generally they will be 16kb as this seems to<br>
give optimal IO performance.<br>
<br>
Stuart<br>
<div><div class="h5"><br>
On Mon, Jun 12, 2017 at 11:06 AM, Violeta Georgieva &lt;<a href="mailto:milesg78@gmail.com">milesg78@gmail.com</a>&gt; wrote:<br>
&gt; Hi,<br>
&gt;<br>
&gt; I have few questions about Undertow&#39;s ByteBufferPool.<br>
&gt; Are there any best practices how it should be used?<br>
&gt; Also are the ByteBuffers always fixed in size?<br>
&gt;<br>
&gt; Thanks,<br>
&gt; Violeta<br>
&gt;<br>
</div></div>&gt; ______________________________<wbr>_________________<br>
&gt; undertow-dev mailing list<br>
&gt; <a href="mailto:undertow-dev@lists.jboss.org">undertow-dev@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/undertow-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/<wbr>mailman/listinfo/undertow-dev</a><br>
</blockquote></div><br></div>