[undertow-dev] Questions about Undertow's ByteBufferPool

Violeta Georgieva milesg78 at gmail.com
Fri Jun 16 10:35:55 EDT 2017


Hi Stuart,

Spring Framework 5 uses Undertow APIs directly, i.e. not going through the
Servlet API.
When reading the request the ByteBufferPool is obtained from the connection
and then the PooledByteBuffer is allocated and used [1].
Also the PooledByteBuffer is closed in ExchangeCompletionListener [2].

So currently the usage is limited only to the request reading.
In order to extend the usage of the ByteBufferPool we need to be able to
allocate buffers with a concrete size.
At the moment (what I saw in the sources) the ByteBufferPool is created
with a specific buffer size
and the pooled buffers are created with exactly this size.

For comparison see the io.netty.buffer.PooledByteBufAllocator in Netty
which provides a functionality to allocated buffers with a specific size
[3], [4], [5].

So is it possible to achieve the same with the Undertow's ByteBufferPool?
If such functionality is not existing do you think it is feasible to add
such API?

Thanks,
Violeta

[1]
https://github.com/spring-projects/spring-framework/blob/master/spring-web/src/main/java/org/springframework/http/server/reactive/UndertowServerHttpRequest.java#L144-L148
[2]
https://github.com/spring-projects/spring-framework/blob/master/spring-web/src/main/java/org/springframework/http/server/reactive/UndertowServerHttpRequest.java#L127-L133
[3]
https://github.com/netty/netty/blob/4.1/buffer/src/main/java/io/netty/buffer/AbstractByteBufAllocator.java#L107-L112
[4]
https://github.com/netty/netty/blob/4.1/buffer/src/main/java/io/netty/buffer/PooledByteBufAllocator.java#L301
[5]
https://github.com/netty/netty/blob/4.1/buffer/src/main/java/io/netty/buffer/PooledByteBufAllocator.java#L318


2017-06-14 3:21 GMT+03:00 Stuart Douglas <sdouglas at redhat.com>:

> It should be used anytime you require a large direct buffer (generally
> for IO operations). Depending on your app you may not need to use them
> directly at all, although Undertow will always use them internally.
>
> The buffers are fixed size which is determined dynamically (unless
> explicitly specified), generally they will be 16kb as this seems to
> give optimal IO performance.
>
> Stuart
>
> On Mon, Jun 12, 2017 at 11:06 AM, Violeta Georgieva <milesg78 at gmail.com>
> wrote:
> > Hi,
> >
> > I have few questions about Undertow's ByteBufferPool.
> > Are there any best practices how it should be used?
> > Also are the ByteBuffers always fixed in size?
> >
> > Thanks,
> > Violeta
> >
> > _______________________________________________
> > undertow-dev mailing list
> > undertow-dev at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/undertow-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/undertow-dev/attachments/20170616/e255f729/attachment.html 


More information about the undertow-dev mailing list