Page MenuHome

Compositor: Scheduling
AbandonedPublic

Authored by Jeroen Bakker (jbakker) on Apr 6 2021, 4:53 PM.

Details

Summary

This started out with tweaking the WorkScheduler of the compositor and tying out different scheduling strategies.

Scheduling modes:

  • Input to output: mode where input nodes are calculated and after finished their child nodes.
  • Output to input: same behavior as master where tiles are prioritized to show something to the user.

These modes can be switched in COM_defines.h COM_SCHEDULING_MODE.

Scheduling Back-ends:

  • BLI_task
  • pthread queue

The back-end can be switched in COM_WorkScheduler.cc COM_threading_model.

Test File:


Timing patch for master:
Timing patch for temp-compositor-scheduling:

AMD Ryzen 1700, Linux

branchscheduling modescheduling backendtime ExecutionSystem.execute
masterOutput to inputpthread_queue3.15s
temp-compositor-schedulingOutput to inputpthread_queue3.09s
temp-compositor-schedulingInput to outputpthread_queue3.49s
temp-compositor-schedulingOutput to inputBLI_task3.35s
temp-compositor-schedulingInput to outputBLI_task3.09s

Diff Detail

Repository
rB Blender
Branch
temp-compositor-scheduling
Build Status
Buildable 13904
Build 13904: arc lint + arc unit

Event Timeline

Jeroen Bakker (jbakker) requested review of this revision.Apr 6 2021, 4:53 PM
Jeroen Bakker (jbakker) created this revision.
Jeroen Bakker (jbakker) edited the summary of this revision. (Show Details)Apr 6 2021, 5:06 PM
Jeroen Bakker (jbakker) retitled this revision from [WIP] Compositor: Scheduling to Compositor: Scheduling.Apr 6 2021, 5:12 PM
Jeroen Bakker (jbakker) edited the summary of this revision. (Show Details)
source/blender/compositor/intern/COM_ExecutionSystem.cc
292

100ms is too long. We should not sleepnet yield other threads

Jeroen Bakker (jbakker) edited the summary of this revision. (Show Details)Apr 7 2021, 10:54 AM
Jeroen Bakker (jbakker) edited the summary of this revision. (Show Details)
Jeroen Bakker (jbakker) edited the summary of this revision. (Show Details)
Jeroen Bakker (jbakker) edited the summary of this revision. (Show Details)
Jeroen Bakker (jbakker) edited the summary of this revision. (Show Details)

Replace sleep with yield.

source/blender/compositor/intern/COM_ExecutionSystem.cc
293

Replace with BLI_condition_*.

  • Merge branch 'master' into temp-compositor-scheduling
  • Compostior: Test for break to stop compositing.
  • Tweaked InputToOutput scheduling.

Looks good to me. I've tested both modes and haven't found any issue. Thanks to this patch it should be easy to know when all readers of an execution group have finished and free its buffer.

This revision is now accepted and ready to land.Apr 13 2021, 9:19 PM
Sergey Sharybin (sergey) requested changes to this revision.Apr 14 2021, 11:01 AM
Sergey Sharybin (sergey) added inline comments.
source/blender/blenlib/BLI_threads.h
198 ↗(On Diff #36118)

What does this function do?

As in, write a comment about this function so that BLI's API stays nice and documented.

source/blender/compositor/intern/COM_ExecutionSystem.cc
302–312

I am not really convinced the busy wait is the best approach here: you are occupying a CPU thread to constantly perform checks whether there is still work being done. On a non-trivial node setup it will be a lot of extra work done for no apparent reason.

Depending on which threading model is used in compositor, there are better approaches:

  • If you have worker threads which will exit once there is no work to be done you can join the thread, or the pool, or the task scheduler.
  • If the worker threads are always active you'd better use conditional variable, so that worker threads wake up the waiting thread once they've finished work.
  • I also see usage of ThreadQueue, so maybe BLI_thread_queue_wait_finish implements what you need already.

If the busy wait is the best solution here it must be explained why is it so.

This revision now requires changes to proceed.Apr 14 2021, 11:01 AM

Patch should be reviewed after the buffered compositor is implemented.