Introducing a new way to review your PRs.

Read the announcement

eventual-inc / daft

High-performance data engine for AI and multimodal workloads. Process images, audio, video, and structured data at any scale

View on GitHub

19 documents · Updated Nov 11, 2026

docs / execution-engines

Execution engines

Daft executes an optimized query plan through one of two runners: a native runner for work in one process or a Ray runner for work across a cluster. Both runners turn the plan into partition work, stream completed results, and return execution data that links query progress to plan nodes.

Execution model

The execution model separates query shape from query work. The optimized plan describes the operators and their data flow. The chosen runner turns that plan into local pipelines or distributed tasks, then collects the resulting partitions for the caller.

flowchart LR
    A[Optimized query plan] --> B{Runner}
    B --> C[Native pipeline]
    B --> D[Distributed pipeline]
    C --> E[Local tasks and operators]
    D --> F[Scheduled worker tasks]
    E --> G[Result partitions]
    F --> G
    G --> H[Collected result and execution metadata]

Runner selection

The runner is a process-wide choice. Daft accepts native and ray runner modes, and can infer Ray mode when the process already runs in a Ray environment; once created, the selected runner is reused for later queries. The public setup boundary can create either runner, pass native thread or Ray connection settings, and validate Ray autoscale settings before query execution. src/…/runners.rs• L74-101 src/…/runners.rs• L246-307 src/…/python.rs• L14-119

The shared runner contract gives both paths the same user-facing choices. A query can stream materialized partitions as they complete or consume all partitions into a partition set. Each runner also supplies the data access actions needed to inspect source paths in its execution environment. daft/…/runner.py• L26-69 daft/…/runner_io.py• L10-34

References: src/…/runners.rs• L74-101 src/…/runners.rs• L246-307 src/…/python.rs• L14-119 daft/…/runner.py• L26-69 daft/…/runner_io.py• L10-34

Plan translation

Plan translation maps the optimized logical plan into an executable physical form. Source nodes keep the inputs that must be supplied at run time, while operator nodes keep the schema and the work needed to transform their input partitions. src/…/translate.rs• L21-33 src/…/translate.rs• L35-97

The local and distributed paths use different levels of work. The native path builds one local pipeline from a physical plan. The distributed path builds a tree of pipeline nodes that can produce tasks and can add repartition or gather stages when an operation needs data in a different layout. src/…/pipeline.rs• L397-433 src/…/translate.rs• L43-55 src/…/translate.rs• L369-422

References: src/…/translate.rs• L21-33 src/…/translate.rs• L35-97 src/…/pipeline.rs• L397-433 src/…/translate.rs• L43-55 src/…/translate.rs• L369-422

Local execution path

The native path runs the full physical plan in one process. It uses a local pipeline with source readers, streaming operators, and blocking operators, then exposes output as MicroPartition values. See Local execution for the focused path guide.

Pipeline evaluation

The native executor starts one pipeline for a plan and sends each input set through typed source channels. Pipeline messages carry either a result partition or a flush marker for one input. The flush marker lets the executor close that input's result stream without stopping other inputs that share the plan. src/…/run.rs• L95-155 src/…/run.rs• L328-405

The pipeline limits work by operator needs and the execution configuration. Scan work can run in parallel, while order-preserving reads use a flattener before results enter the rest of the pipeline. Operators that need a complete input, such as sort or aggregate, act as blocking stages rather than emitting each input batch directly. src/…/pipeline.rs• L148-222 src/…/scan_task.rs• L71-129

References: src/…/run.rs• L95-155 src/…/run.rs• L328-405 src/…/pipeline.rs• L148-222 src/…/scan_task.rs• L71-129

UDF worker execution

Python UDF work can run in a separate worker process so the main local execution path can exchange record batches without sharing the UDF's process state. The worker receives an expression projection and input batches, evaluates them, then returns output data with UDF metrics or a structured error. daft/…/udf_worker.py• L26-72 daft/…/udf_worker.py• L73-101

The worker keeps its compute thread count at one. This gives each UDF worker a clear execution boundary and avoids adding an uncontrolled layer of parallel work inside a scheduled task. daft/…/udf_worker.py• L38-43

References: daft/…/udf_worker.py• L26-72 daft/…/udf_worker.py• L73-101

Local result collection

The native runner exposes results as they arrive. The normal run call consumes the stream and stores the output partitions in the local partition cache. The table form dereferences the runner result so callers receive in-memory MicroPartition objects. daft/…/native_runner.py• L85-89 daft/…/native_runner.py• L194-214

When a caller stops consuming early, the result stream is closed and the executor cancels or completes the related work. A full consume reaches the end marker and returns execution metadata after the result receiver has been finished. daft/…/native_executor.py• L32-78 src/…/run.rs• L752-769

References: daft/…/native_runner.py• L85-89 daft/…/native_runner.py• L194-214 daft/…/native_executor.py• L32-78 src/…/run.rs• L752-769

Distributed execution path

The Ray path uses Ray actors as workers and a plan runner as the control point for task creation, scheduling, and result collection. Workers run the same kind of local physical plan as the native path, but each task receives only its assigned source inputs and prior partition references. See Distributed execution for the focused path guide.

Task production

The distributed pipeline produces task builders instead of running data in the driver. A builder records the local plan, source inputs, prior partition sets, resource needs, placement preference, and query context. At build time it receives a task ID and a plan fingerprint, which identifies tasks that can share one local pipeline. src/…/mod.rs• L119-135 src/…/task.rs• L319-358 src/…/task.rs• L482-533

Pipeline stages pass materialized outputs to later stages as partition references. The output also records the worker that produced it, so a later stage can use worker affinity when data placement makes that useful. A repartition or gather stage changes how those references are grouped before the next stage runs. src/…/mod.rs• L125-179 src/…/mod.rs• L196-247

References: src/…/mod.rs• L119-135 src/…/task.rs• L319-358 src/…/task.rs• L482-533 src/…/mod.rs• L125-179 src/…/mod.rs• L196-247

Actor-pool UDF execution

Actor-pool UDFs evaluate expression projections in long-lived Ray actors. The actor pool spreads actors across the cluster, applies the requested resource limits, and waits for a usable set of actors before work starts. daft/…/ray_actor_pool_udf.py• L28-43 daft/…/ray_actor_pool_udf.py• L79-165

The pool can prefer actors on the current Ray node when it assigns work. Ray can restart actors and retry actor tasks within the configured limits, while the pool reports an error when no node can satisfy one actor's resource request or when actors do not become ready in time. daft/…/ray_actor_pool_udf.py• L45-76 daft/…/ray_actor_pool_udf.py• L108-160

References: daft/…/ray_actor_pool_udf.py• L28-43 daft/…/ray_actor_pool_udf.py• L45-76 daft/…/ray_actor_pool_udf.py• L79-165

Task scheduling

The scheduler keeps pending tasks until workers have enough reported capacity. Its default policy spreads work to a worker with the most available capacity, honors hard or soft worker affinity, and keeps tasks ordered by query, plan node, and task priority. A linear scheduler is also available when the scheduler mode selects it. src/…/default.rs• L46-85 src/…/task.rs• L201-239 src/…/scheduler_actor.rs• L240-301

Every scheduling cycle refreshes worker state, asks for more workers when pending demand is high, dispatches tasks, and handles completed or failed tasks. A dead worker is removed and its task can return to the pending queue. An unavailable worker also permits a retry without marking that worker dead. src/…/scheduler_actor.rs• L101-230 src/…/dispatcher.rs• L71-149

Ray workers track active tasks and their CPU and GPU capacity. The worker manager can request more Ray resources when demand exceeds current capacity and can retire idle workers when downscaling is enabled. src/…/worker.rs• L66-129 src/…/worker_manager.rs• L197-333 src/…/worker_manager.rs• L335-507

References: src/…/default.rs• L46-85 src/…/task.rs• L201-239 src/…/scheduler_actor.rs• L101-230 src/…/dispatcher.rs• L71-149 src/…/worker.rs• L66-129 src/…/worker_manager.rs• L197-333 src/…/worker_manager.rs• L335-507

Distributed result collection

The distributed plan runner submits task builders to the scheduler and forwards each completed task output into a result stream. The caller therefore sees completed partitions without waiting for every task in the plan. When the stream ends, the plan runner cleans up shuffle directories and closes its plan task set. src/…/runner.rs• L123-146 src/…/runner.rs• L159-219

Ray transports result data as object references when possible. Shuffle stages can instead return Flight partition references, which identify data served by a worker. The worker returns partition metadata and encoded execution stats with the result so the driver can keep data and its description together. daft/…/flotilla.py• L212-289 daft/…/flotilla.py• L324-366 src/…/task.rs• L84-132

References: src/…/runner.rs• L123-146 src/…/runner.rs• L159-219 daft/…/flotilla.py• L212-289 daft/…/flotilla.py• L324-366 src/…/task.rs• L84-132

Partitioning and data placement

Partitions are the unit of data transfer and result delivery. A partition set keeps partition IDs, row counts, byte sizes, and backend-specific data handles. The native runner stores in-memory partitions. The Ray runner stores Ray object references or Flight references and resolves them only when a caller asks for table data. daft/…/partitioning.py• L74-112 daft/…/partitioning.py• L180-213 daft/…/partitioning.py• L215-283

Distributed operators use a clustering description to state how rows are laid out across partitions. Operators can preserve that layout, rewrite it through a projection, or set a new layout. Hash repartitioning groups matching keys together; gather stages bring data to one place. The translator skips a repartition only when the existing layout already covers the required keys. src/…/mod.rs• L251-303 src/…/translate.rs• L96-117

The partition cache gives later queries a handle to prior results without copying the data into the driver. Cached entries are weakly held, so the data remains available only while a live partition set owns it. daft/…/partitioning.py• L371-433 daft/…/runner.py• L23-36

References: daft/…/partitioning.py• L74-112 daft/…/partitioning.py• L180-213 daft/…/partitioning.py• L215-283 src/…/mod.rs• L251-303 src/…/translate.rs• L96-117 daft/…/partitioning.py• L371-433 daft/…/runner.py• L23-36

Execution metadata

Execution metadata identifies the query and describes work at plan nodes. It carries the plan view, node-level statistics, and files that were skipped because corruption was allowed. The same metadata shape is used for native results and for stats sent back from distributed workers. src/…/results.rs• L16-23 src/…/results.rs• L25-79

Each node snapshot can report duration, input and output rows, input and output bytes, and task counts. Distributed node stats use the local node's origin ID to add worker measurements to the correct distributed node, which avoids counting fused local operators as separate distributed stages. src/…/results.rs• L82-150 src/…/stats.rs• L102-105 src/…/stats.rs• L212-250

Task lifecycle events expose submitted, scheduled, completed, failed, and canceled work. Task metadata can include source paths, scan counts, storage size, and estimated memory size. These events support progress views and help relate a worker failure to the query task that was affected. src/…/task.rs• L166-192 src/…/task_lifecycle.rs• L48-119

References: src/…/results.rs• L16-23 src/…/results.rs• L25-79 src/…/results.rs• L82-150 src/…/stats.rs• L102-105 src/…/stats.rs• L212-250 src/…/task.rs• L166-192 src/…/task_lifecycle.rs• L48-119

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep the runner contract aligned across Runner.run_iter, Runner.run_iter_tables, partition cache entries, and both runner implementations. A change in the result handle type can break table conversion or cache reuse without changing the query plan.
  • Keep Input variants aligned with the source sender created from a local physical plan. Distributed task inputs must also match the input conversion used by Ray workers.
  • Keep task context fields aligned with task events and execution stats. In particular, task_id, plan_fingerprint, node_ids, and origin_node_id link scheduler state to dashboard metrics.
  • When changing repartition or gather output, check partition count and order contracts. Some downstream stages depend on fixed output slots rather than only on row content.
  • When changing result streaming or early close behavior, check that cancellation, flush signals, plan cleanup, and final metadata still happen for both runners.
  • When changing resource requests or worker retirement, check the interaction between scheduler demand, Ray autoscaler requests, worker refresh, and retry behavior.
  • When changing runner setup options, keep validation, environment-based defaults, and the Python-to-runner constructor boundary aligned. Invalid Ray autoscale values must fail during setup rather than at query time.
  • When changing UDF worker messages or result transport, keep the ready, success, error, and end-of-input signals aligned with the parent process.
  • When changing actor-pool UDF resources or readiness behavior, keep resource validation, partial-pool handling, actor retry limits, and the readiness timeout aligned.

Important failure modes

TriggerConsequenceGuard
A task requests more memory than the local memory limitThe task returns a compute error instead of waiting for memoryKeep task memory requests within the configured limit; the memory manager rejects requests above its total capacity. src/…/resource_manager.rs• L79-113
No worker has enough CPU or GPU capacityThe task stays pending and can trigger an autoscale requestCheck worker capacity and resource requests; the scheduler does not dispatch a task that cannot fit. src/…/mod.rs• L217-245 src/…/default.rs• L88-109
A Ray worker dies during a taskThe worker is removed and the task is returned for scheduling againTreat task output as incomplete until the retry path reports success. src/…/dispatcher.rs• L101-137
A native query uses repartition or IntoPartitionsThe native translator warns and treats the operation as a no-op; the requested distributed layout is not providedUse the Ray runner when the query needs distributed repartitioning. src/…/translate.rs• L583-594
A caller abandons a result streamThe executor cancels or closes work and the caller may not receive normal end metadataDrain the stream when metadata is required; early-close paths are handled as cancellation or finish cleanup. daft/…/native_executor.py• L57-78 daft/…/ray_runner.py• L688-710
A corrupt file is read with corrupt-file skipping enabledThe query can finish with missing or partial file dataInspect skipped_corrupt_files and its partial flag before treating the result as complete. src/…/results.rs• L21-23 daft/…/metadata.py• L105-113
Runner setup uses an invalid Ray autoscale strategy or a zero bisect timeoutRunner creation fails before a query startsUse gradual or bisect and a positive bisect timeout. src/…/python.rs• L49-70
No Ray node can satisfy one actor-pool UDF's resource requestNo actor can start and the UDF fails before evaluationRequest resources that fit on one live node. daft/…/ray_actor_pool_udf.py• L108-118
Actor-pool UDF actors do not become ready before the configured timeoutThe UDF fails without a usable actor poolSet a readiness timeout that matches cluster startup time. daft/…/ray_actor_pool_udf.py• L149-160
The UDF worker cannot send its result or error to the parentThe parent may receive no normal UDF resultKeep the worker transport and lifecycle signals compatible with the parent process. daft/…/udf_worker.py• L47-72 daft/…/udf_worker.py• L85-101

Key files

FileWhy to read it
daft/…/runner.pyDefines the common runner contract for streaming, full collection, and partition cache use.
src/…/runners.rsShows runner selection, runner lifetime, and the native/Ray boundary.
src/…/python.rsExposes runner setup and selection to Python and validates Ray setup options.
daft/…/native_runner.pyShows the native query lifecycle from optimization to local result collection.
daft/…/ray_runner.pyShows the distributed query lifecycle from plan creation to streamed Ray results.
src/…/translate.rsMaps optimized logical operators to local physical plan nodes and runtime inputs.
src/…/run.rsCoordinates local pipeline execution, input IDs, result delivery, cancellation, and final stats.
daft/…/udf_worker.pyShows the process boundary used to evaluate local Python UDF batches and return UDF metrics or errors.
src/…/translate.rsMaps the logical plan to distributed pipeline stages and data-layout changes.
src/…/runner.rsConnects distributed task production, scheduling, materialization, and cleanup.
src/…/scheduler_actor.rsDefines the scheduling loop, worker refresh, autoscaling, dispatch, retry, and shutdown flow.
src/…/task.rsDefines task identity, resource needs, placement strategy, inputs, and task status.
src/…/worker_manager.rsConnects scheduler worker state to Ray worker startup, autoscaling, retry visibility, and downscale.
daft/…/ray_actor_pool_udf.pyShows how distributed actor-pool UDFs allocate resources, wait for actors, and evaluate partitions.
daft/…/partitioning.pyDefines partition metadata, partition sets, result handles, and cache behavior.
src/…/results.rsDefines the execution stats carried from runners to callers and dashboards.