On 2020-12-17 00:12:06 [+0200], Lasse Collin wrote:
> When decoding one can get smoother output by copying decompressed data
> out in smaller chunks. Your code does this but it's still a single
> mutex for all threads. With many threads that is easily thousands or
> even tens of thousands of locks/unlocks per second from all threads
> combined. I don't know how much it matters and if it is worth it to
> make it more complex. For example, one could have a thread-specific flag
> indicating if the main thread is interested in the data from that
> thread. Then only that thread would lock/signal/unlock the main mutex
> when a chunk of data is ready.

I moved parts of the memcpy() out the locked section. Only the thread,
that is currently decompressing is waking the main thread. However the
current output position is updated under the main-thread's mutex. So
that might be not optimal.

Let me know if you have other concerns or of this part should be
reworked somehow.

Sebastian

Reply via email to