Skip to content

Commit c56523b

Browse files
Improve documentation of yield guidelines
Co-authored-by: Mehmet Ozan Kabak <[email protected]>
1 parent 286f62e commit c56523b

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

datafusion/physical-plan/src/execution_plan.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -261,14 +261,16 @@ pub trait ExecutionPlan: Debug + DisplayAs + Send + Sync {
261261
/// Thus, [`spawn`] is disallowed, and instead use [`SpawnedTask`].
262262
///
263263
/// To enable timely cancellation, the [`Stream`] that is returned must not
264-
/// block the CPU and must yield back to the tokio runtime regularly.
265-
/// [`ExecutionPlan`] implementations should follow [the guideline of not
266-
/// spending a long time without reaching an `await`/yield point][async-guideline].
267-
/// This can be achieved by manually returning [`Poll::Pending`] in regular
268-
/// intervals, or the use of [`tokio::task::yield_now()`] (as appropriate).
269-
/// Determination for "regularly" may be made using a timer (being careful
270-
/// with the overhead-heavy syscall needed to take the time) or by
271-
/// counting rows or batches.
264+
/// block the CPU indefinitely and must yield back to the tokio runtime regularly.
265+
/// In a typical [`ExecutionPlan`], this automatically happens unless there are
266+
/// special circumstances; e.g. when the computational complexity of processing a
267+
/// batch is superlinear. See this [general guideline][async-guideline] for more context
268+
/// on this point, which explains why one should avoid spending a long time without
269+
/// reaching an `await`/yield point in asynchronous runtimes.
270+
/// This can be achieved by manually returning [`Poll::Pending`] and setting up wakers appropriately, or the use of [`tokio::task::yield_now()`] when appropriate.
271+
/// In special cases that warrant manual yielding, determination for "regularly" may be
272+
/// made using a timer (being careful with the overhead-heavy system call needed to
273+
/// take the time), or by counting rows or batches.
272274
///
273275
/// The cancellation benchmark tracks some cases of how quickly queries can
274276
/// be cancelled.

0 commit comments

Comments
 (0)