When the message body is larger than 64KB, the message is stored on the disk by CachedOutputStream and read back later by FileInputStreamCache.
A thread dump during a load test shows that the execution is most of the time waiting in the "InputStream.read()" method calls.
The "truss" output shows that the file is read back 1 byte at a time, which makes the calls very slow.
A first workaround (setting property "CamelCachedOutputStreamThreshold" to 10000000 on the CamelContext's properties) helped in some case.
The cause is that the FileInputStreamCache does not use a BufferInputStream to read on the disk, although the
CachedOutputStream does properly use a BufferOutputStream.
A trivial patch is attached, which provides a fix.
This problem was first noticed when the trace was enabled on the CamelContext, but it occurs also in other scenarios.