saints row scheduler randall turner, volition, inc. [email protected] discussion...
TRANSCRIPT
![Page 1: Saints Row Scheduler Randall Turner, Volition, Inc. Randall.turner@volition-inc.com Discussion Areas: Saints Row project Saint’s Row scheduler](https://reader034.vdocuments.mx/reader034/viewer/2022051401/56649e915503460f94b96c57/html5/thumbnails/1.jpg)
![Page 2: Saints Row Scheduler Randall Turner, Volition, Inc. Randall.turner@volition-inc.com Discussion Areas: Saints Row project Saint’s Row scheduler](https://reader034.vdocuments.mx/reader034/viewer/2022051401/56649e915503460f94b96c57/html5/thumbnails/2.jpg)
Saints Row Scheduler
Randall Turner, Volition, Inc. [email protected] Discussion Areas:
Saints Row project Saint’s Row scheduler
![Page 3: Saints Row Scheduler Randall Turner, Volition, Inc. Randall.turner@volition-inc.com Discussion Areas: Saints Row project Saint’s Row scheduler](https://reader034.vdocuments.mx/reader034/viewer/2022051401/56649e915503460f94b96c57/html5/thumbnails/3.jpg)
Saint’s Row
![Page 4: Saints Row Scheduler Randall Turner, Volition, Inc. Randall.turner@volition-inc.com Discussion Areas: Saints Row project Saint’s Row scheduler](https://reader034.vdocuments.mx/reader034/viewer/2022051401/56649e915503460f94b96c57/html5/thumbnails/4.jpg)
Single Thread, CPU Bound
![Page 5: Saints Row Scheduler Randall Turner, Volition, Inc. Randall.turner@volition-inc.com Discussion Areas: Saints Row project Saint’s Row scheduler](https://reader034.vdocuments.mx/reader034/viewer/2022051401/56649e915503460f94b96c57/html5/thumbnails/5.jpg)
Alpha Kits
Two Hardware Threads Dual Core
Hardware thread Software thread Many software threads on one hardware
thread Software threads != concurrency. Hardware
threads do.
![Page 6: Saints Row Scheduler Randall Turner, Volition, Inc. Randall.turner@volition-inc.com Discussion Areas: Saints Row project Saint’s Row scheduler](https://reader034.vdocuments.mx/reader034/viewer/2022051401/56649e915503460f94b96c57/html5/thumbnails/6.jpg)
First Step: Alpha kit solution Sim/Render Split (Still CPU bound,
not as bad.) Two HW Threads
![Page 7: Saints Row Scheduler Randall Turner, Volition, Inc. Randall.turner@volition-inc.com Discussion Areas: Saints Row project Saint’s Row scheduler](https://reader034.vdocuments.mx/reader034/viewer/2022051401/56649e915503460f94b96c57/html5/thumbnails/7.jpg)
Beta Kits
Betas = Six hardware threads, Woo Hoo! But each hardware thread was slower than Alphas. Homogeneous processing, unified memory
![Page 8: Saints Row Scheduler Randall Turner, Volition, Inc. Randall.turner@volition-inc.com Discussion Areas: Saints Row project Saint’s Row scheduler](https://reader034.vdocuments.mx/reader034/viewer/2022051401/56649e915503460f94b96c57/html5/thumbnails/8.jpg)
First Beta Soluton
![Page 9: Saints Row Scheduler Randall Turner, Volition, Inc. Randall.turner@volition-inc.com Discussion Areas: Saints Row project Saint’s Row scheduler](https://reader034.vdocuments.mx/reader034/viewer/2022051401/56649e915503460f94b96c57/html5/thumbnails/9.jpg)
Problem
Still only using mostly two HW threads (Sim, Render)
Badly CPU bound No more major “natural” separation
points
![Page 10: Saints Row Scheduler Randall Turner, Volition, Inc. Randall.turner@volition-inc.com Discussion Areas: Saints Row project Saint’s Row scheduler](https://reader034.vdocuments.mx/reader034/viewer/2022051401/56649e915503460f94b96c57/html5/thumbnails/10.jpg)
Interim Solution
Manually move processing to other HW threads.
Example – Shadow Calculations Create a SW thread to process half of
the object list Process half the list when triggered.
![Page 11: Saints Row Scheduler Randall Turner, Volition, Inc. Randall.turner@volition-inc.com Discussion Areas: Saints Row project Saint’s Row scheduler](https://reader034.vdocuments.mx/reader034/viewer/2022051401/56649e915503460f94b96c57/html5/thumbnails/11.jpg)
Fixed Concurrent Processing
Uses an entire SW thread for one type of processing.
Wastes system resources Hard coded to execute that processing type only. Inflexible, Scales up badly.
![Page 13: Saints Row Scheduler Randall Turner, Volition, Inc. Randall.turner@volition-inc.com Discussion Areas: Saints Row project Saint’s Row scheduler](https://reader034.vdocuments.mx/reader034/viewer/2022051401/56649e915503460f94b96c57/html5/thumbnails/13.jpg)
Goal Make all movable so will use
available space
![Page 14: Saints Row Scheduler Randall Turner, Volition, Inc. Randall.turner@volition-inc.com Discussion Areas: Saints Row project Saint’s Row scheduler](https://reader034.vdocuments.mx/reader034/viewer/2022051401/56649e915503460f94b96c57/html5/thumbnails/14.jpg)
Scheduler (Job Manager)
Jobs Worker threads Job Queues Triggers
![Page 15: Saints Row Scheduler Randall Turner, Volition, Inc. Randall.turner@volition-inc.com Discussion Areas: Saints Row project Saint’s Row scheduler](https://reader034.vdocuments.mx/reader034/viewer/2022051401/56649e915503460f94b96c57/html5/thumbnails/15.jpg)
Jobs
Independently schedulable entity No dependencies on other jobs. Atomic with respect to other jobs Essentially a function/data pair
![Page 16: Saints Row Scheduler Randall Turner, Volition, Inc. Randall.turner@volition-inc.com Discussion Areas: Saints Row project Saint’s Row scheduler](https://reader034.vdocuments.mx/reader034/viewer/2022051401/56649e915503460f94b96c57/html5/thumbnails/16.jpg)
Creating Jobs
Extract parallelism from loops. (Splatting)
Segregate memory usage Thread safe interactions with systems
critical sections double-buffering
![Page 17: Saints Row Scheduler Randall Turner, Volition, Inc. Randall.turner@volition-inc.com Discussion Areas: Saints Row project Saint’s Row scheduler](https://reader034.vdocuments.mx/reader034/viewer/2022051401/56649e915503460f94b96c57/html5/thumbnails/17.jpg)
Examples
Compute shadow silhouettes Character animation Object visibility culling Building command buffers Bad candidate - AI processing
Not easily turned into jobs due to interaction with large, difficult to thread safe data set.
![Page 18: Saints Row Scheduler Randall Turner, Volition, Inc. Randall.turner@volition-inc.com Discussion Areas: Saints Row project Saint’s Row scheduler](https://reader034.vdocuments.mx/reader034/viewer/2022051401/56649e915503460f94b96c57/html5/thumbnails/18.jpg)
Basic Scheduler Flow
![Page 19: Saints Row Scheduler Randall Turner, Volition, Inc. Randall.turner@volition-inc.com Discussion Areas: Saints Row project Saint’s Row scheduler](https://reader034.vdocuments.mx/reader034/viewer/2022051401/56649e915503460f94b96c57/html5/thumbnails/19.jpg)
Worker Threads
One per HW thread Draws jobs from job queues Associated with job “type”
Sim jobs, Render jobs, or “any” job. “Soft” or “Hard” linkage Dynamically configurable
Wakes up when jobs go into job queue Can be deactivated
![Page 20: Saints Row Scheduler Randall Turner, Volition, Inc. Randall.turner@volition-inc.com Discussion Areas: Saints Row project Saint’s Row scheduler](https://reader034.vdocuments.mx/reader034/viewer/2022051401/56649e915503460f94b96c57/html5/thumbnails/20.jpg)
Job Queues
One per job type Sim or Render
Implicit prioritization High frequency, contention sensitive
Used critical sections on version 1.0
![Page 21: Saints Row Scheduler Randall Turner, Volition, Inc. Randall.turner@volition-inc.com Discussion Areas: Saints Row project Saint’s Row scheduler](https://reader034.vdocuments.mx/reader034/viewer/2022051401/56649e915503460f94b96c57/html5/thumbnails/21.jpg)
Triggers Fire on completion of jobs Scheduling Triggers – schedule more
jobs Event Triggers - activate suspended
threads Can tie together to create state
machines.
![Page 22: Saints Row Scheduler Randall Turner, Volition, Inc. Randall.turner@volition-inc.com Discussion Areas: Saints Row project Saint’s Row scheduler](https://reader034.vdocuments.mx/reader034/viewer/2022051401/56649e915503460f94b96c57/html5/thumbnails/22.jpg)
First Pass
![Page 23: Saints Row Scheduler Randall Turner, Volition, Inc. Randall.turner@volition-inc.com Discussion Areas: Saints Row project Saint’s Row scheduler](https://reader034.vdocuments.mx/reader034/viewer/2022051401/56649e915503460f94b96c57/html5/thumbnails/23.jpg)
Final Pass 90% CPU Utilization
![Page 24: Saints Row Scheduler Randall Turner, Volition, Inc. Randall.turner@volition-inc.com Discussion Areas: Saints Row project Saint’s Row scheduler](https://reader034.vdocuments.mx/reader034/viewer/2022051401/56649e915503460f94b96c57/html5/thumbnails/24.jpg)
Flow-Around Callback to scheduler on interrupt
Allow “small” jobs to complete, then resume Jobs contain duration info
![Page 25: Saints Row Scheduler Randall Turner, Volition, Inc. Randall.turner@volition-inc.com Discussion Areas: Saints Row project Saint’s Row scheduler](https://reader034.vdocuments.mx/reader034/viewer/2022051401/56649e915503460f94b96c57/html5/thumbnails/25.jpg)
Havok
Timestep called from Scheduler job More flexible
Problem: Has own internal scheduler Timestep Goes “Serial” Jobs don’t flow
Solution: break out and splat serial processing ourselves.
![Page 26: Saints Row Scheduler Randall Turner, Volition, Inc. Randall.turner@volition-inc.com Discussion Areas: Saints Row project Saint’s Row scheduler](https://reader034.vdocuments.mx/reader034/viewer/2022051401/56649e915503460f94b96c57/html5/thumbnails/26.jpg)
Havok - serial extraction
![Page 27: Saints Row Scheduler Randall Turner, Volition, Inc. Randall.turner@volition-inc.com Discussion Areas: Saints Row project Saint’s Row scheduler](https://reader034.vdocuments.mx/reader034/viewer/2022051401/56649e915503460f94b96c57/html5/thumbnails/27.jpg)
Performance Critical Sections
Scheduler v1.0 all critical sections Blockage risk – CS owner preemption
Can stall ALL threads
Lock-Free Faster – x2 no contention, x10-20 high-
contention situations NO blockage risk (Woo Hoo!)
GP Gems 6, Fober
![Page 28: Saints Row Scheduler Randall Turner, Volition, Inc. Randall.turner@volition-inc.com Discussion Areas: Saints Row project Saint’s Row scheduler](https://reader034.vdocuments.mx/reader034/viewer/2022051401/56649e915503460f94b96c57/html5/thumbnails/28.jpg)
Job Size
Scheduler overhead determines job size. Small as possible. Assume 5% overhead Saints Row “ideal” size about 250
microseconds 7 microseconds per job, 5% = 150 microsec, 250 drops to ~ 3% overhed
![Page 30: Saints Row Scheduler Randall Turner, Volition, Inc. Randall.turner@volition-inc.com Discussion Areas: Saints Row project Saint’s Row scheduler](https://reader034.vdocuments.mx/reader034/viewer/2022051401/56649e915503460f94b96c57/html5/thumbnails/30.jpg)
Extras Pix with PVS on, night, high load
Release, w/o PIX samples, ~ 35ms
![Page 31: Saints Row Scheduler Randall Turner, Volition, Inc. Randall.turner@volition-inc.com Discussion Areas: Saints Row project Saint’s Row scheduler](https://reader034.vdocuments.mx/reader034/viewer/2022051401/56649e915503460f94b96c57/html5/thumbnails/31.jpg)
Lock Free URL’s
Fober implementation: http://www.grame.fr/pub/LockFree.pdf
http://www.grame.fr/pub/TR-050523.pdf
Toby Jones: GP Gems 6 Good coding style