manifold icon indicating copy to clipboard operation
manifold copied to clipboard

refactor csg_tree to avoid blocking

Open pca006132 opened this issue 1 year ago • 3 comments

The current csg_tree implementation will hold the lock until the underlying object is completely evaluated. If the lock is already taken, the thread will not be able to proceed and we will lose 1 worker thread in our thread pool. This behavior will occur when two parallel boolean operations both depend on a single object that takes a long time to evaluate.

Ideally we should refactor csg_tree to avoid using such blocking construct internally. We can change to an async style (internal) API, put the task into a top level watchkeeper when the task is waiting for the result of some other operation and it can do nothing. The top level watchkeeper should put the task back to task_arena when the task is ready (received an event). The top level watchkeeper implementation can depend on TBB, because there is no blocking issue when we are running in a single thread.

pca006132 avatar Aug 11 '23 18:08 pca006132