-
Notifications
You must be signed in to change notification settings - Fork 2k
Open
Labels
Description
Jetty version(s)
12.x
Enhancement Description
Currently, it appears that all data provided via Content.Source or Path resource is transferred to the client socked by copying data in userspace (via ByteBuffers).
In many cases, it may be possible to leverage sendfile(2) / FileChannel.transferTo to serve content directly from kernel buffers. This may greatly improve throughput and also reduce CPU usage when transferring lots of data.
We could do the following:
- Add an
asWritableByteChannel
method toContent.Sink
, which may or may not return an optimizedWritableByteChannel
, depending on filters, etc. - Give
Content.Source
the ability to write to aContent.Sink
directly (without forcibly usingContentCopier
). SuitableContent.Source
implementations may callContent.Sink#asWritableByteChannel
and useFileChannel#transferTo(long,long,WritableByteChannel)
with the corresponding data. - Optimize the
Content.Sink
implementation inServletChannel
to return a direct-socketWritableByteChannel
whenever possible. - Improve
IOResources.PathToSinkCopier
as well.