Synodic-Software / Soul-Engine

Physically based renderer and simulation engine for real-time applications.
GNU General Public License v3.0
42 stars 24 forks source link

Fiber Scheduler: Two Awaken Calls (Unnecessary) #25

Closed Behemyth closed 6 years ago

Behemyth commented 7 years ago

When adding a task to the scheduler variables are added via the custom properties. Because the scheduler runs across multiple threads, the fibers are not guaranteed to modify their properties before being submitted. Therefore, when the are run, they change the properties, then yield, causing the values to update at the potential expense of two more context switches.

Check out the Boost/Fiber repository by olk

Behemyth commented 6 years ago

With the work stealing implementation any fiber that is pushed onto the readyQueue can immediately be stolen. This is worked around by changing yielding the fiber as soon as it starts, guaranteeing the fiber properties are updated. This causes an extra awaken and pick_next call (relatively expensive)