Buffer caching for heavy multithreaded load
neopaf opened this issue · 6 comments
Michel, I see that current implementation of
/**
* Keeps thread-local re-usable buffers. Each buffer is identified by a key.
* This class is a singleton, whereas the reference to the instance is held
* in a {@link SoftReference} so buffers can be freed when they are not needed
* anymore.
* @see com.fasterxml.jackson.core.util.BufferRecycler
* @author Michel Kraemer
*/
public class StaticBuffers {
was designed with good intent, but we have only 1 buffer by each key.
For a massive parallel workload this does not work well.
Did you consider adding a bit better buffer caching?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in two weeks if no further activity occurs. Thank you for your contributions.
@neopaf Sorry for my late answer. Can you elaborate on that? Maybe you can provide a unit test or a small sample program that demonstrates your requirements. Cheers.
My colleague @iruno discovered that I was wrong when raised this.
Stas, please elaborate, so Michel could close it in peace?
Greetings!
We can see StaticBuffers are thread-local
. So we have 1 buffer by each key per thread
. As far as I understand it is enough for bson4jackson implementation.
@neopaf In our ap4jackson
project we have one major difference: we need to have at least two re-usable buffers by each key.
That is why we have implemented different ByteBufferPool.
I think we can close this issue.
Thanks for the feedback!