@@ -227,5 +227,41 @@ opts = Dagger.Sch.ThunkOptions(;single=1)
227
227
delayed (+ )(1 , 2 ; options= opts)
228
228
```
229
229
230
+ ### Core vs. Worker Schedulers
231
+
232
+ Dagger's scheduler is really two kinds of entities: the "core" scheduler, and
233
+ "worker" schedulers:
234
+
235
+ The core scheduler runs on worker 1, thread 1, and is the entrypoint to tasks
236
+ which have been submitted. The core scheduler manages all task dependencies,
237
+ notifies calls to ` wait ` and ` fetch ` of task completion, and generally performs
238
+ initial task placement. The core scheduler has cached information about each
239
+ worker and their processors, and uses that information (together with metrics
240
+ about previous tasks and other aspects of the Dagger runtime) to generate a
241
+ near-optimal just-in-time task schedule.
242
+
243
+ The worker schedulers each run as a set of tasks across all workers and all
244
+ processors, and handles data movement and task execution. Once the core
245
+ scheduler has scheduled and launched a task, it arrives at the worker scheduler
246
+ for handling. The worker scheduler will pass the task to a queue for the
247
+ assigned processor, where it will wait until the processor has a sufficient
248
+ amount of "occupancy" for the task. Once the processor is ready for the task,
249
+ it will first fetch all arguments to the task from other workers, and then it
250
+ will execute the task, package the result into a ` Chunk ` , and pass that back to
251
+ the core scheduler.
252
+
253
+ ### Workload Balancing
254
+
255
+ In general, Dagger's core scheduler tries to balance workloads as much as
256
+ possible across all the available processors, but it can fail to do so
257
+ effectively when either the cached per-processor information is outdated, or
258
+ when the estimates about the task's behavior are inaccurate. To minimize the
259
+ impact of this potential workload imbalance, the worker schedulers' processors
260
+ will attempt to steal tasks from each other when they are under-occupied. Tasks
261
+ will only be stolen if their [ scope] ( `Scopes` ) matches the processor attempting
262
+ the steal, so tasks with wider scopes have better balancing potential.
263
+
264
+ ### Scheduler/Thunk Options
265
+
230
266
[ ` Dagger.Sch.SchedulerOptions ` ] ( @ref )
231
267
[ ` Dagger.Sch.ThunkOptions ` ] ( @ref )
0 commit comments