BEFORE DOING THIS--- confirm that there is mutex contention. How?
I think that it's possible to redesign the cache to vastly reduce if not eliminate mutexes. The reason for this is that the worker threads do not actually write anything that the main thread writes, and vice versa. Each actually consumes something the other produces. The main thread produces work items, and the worker threads produce images. So mutexes might be completely unnecessary! Perhaps each worker could have its own work queue, then there is no contention for getting work, and the main thread partitions the work evenly. This assumes pretty constant work quantum sizes, which seems reasonable for blockbuster. It would be amazing to eliminate pthreads completely!
BEFORE DOING THIS--- confirm that there is mutex contention. How?
I think that it's possible to redesign the cache to vastly reduce if not eliminate mutexes. The reason for this is that the worker threads do not actually write anything that the main thread writes, and vice versa. Each actually consumes something the other produces. The main thread produces work items, and the worker threads produce images. So mutexes might be completely unnecessary! Perhaps each worker could have its own work queue, then there is no contention for getting work, and the main thread partitions the work evenly. This assumes pretty constant work quantum sizes, which seems reasonable for blockbuster. It would be amazing to eliminate pthreads completely!
Original comment by: wealthychef1