jvm.chisel.db.schedule

The hardware workflow scheduler: turns a logical operator graph (data, produced by the host) into a physical placement on a fixed pool of reusable operator blocks, and executes a pure-Clojure reference of the plan.

This is deliberately decoupled from the datapath (jvm.chisel.db.pipeline):

host chip graph ──▶ logical plan ──▶ place ──▶ schedule ──▶ composed module (data only) (which units) (order, cost)

  • place / schedule are pure functions over the plan and the resource inventory; schedule accepts a :cost-fn, the seam where a learned cost model (“AI inside the chip”) plugs in without touching the datapath.
  • run-plan is the golden reference: it runs a plan over concrete lane input by composing the existing *-ref models, so both tests and jvm.chisel.db.pipeline/pipeline-ref share one source of truth.

The scheduling logic itself is pure data; requiring the operator namespaces is only to reuse their reference models (single source of truth, no drift).

demands

(demands plan)

Per-kind unit counts a plan needs (one unit per node).

estimate-cost

(estimate-cost plan)

Default cycle estimate: one lanes pass per node. Overridable via schedule’s :cost-fn.

feasible?

(feasible? plan inventory)

True iff every node op is known and, for every kind, demand <= inventory.

op->kind

Resource kind consumed by each supported logical operator.

place

(place plan inventory)

Assign a concrete physical unit id to each node, in plan order, drawing from inventory. Returns {:ok? bool :placement :reason …}. Each placement entry is {:stage i :op op :kind kind :unit :-} where i is the node’s index in the (normalized) node vector.

plan->nodes

(plan->nodes plan)

Normalize a plan to a topological node vector. A plan with :nodes is used as-is; a linear :stages plan is lifted to a chain: node 0 reads source 0, node i reads node i-1.

plan->sources

(plan->sources plan)

Number of input relations a plan consumes (:sources int or vector, default 1).

run-plan

(run-plan plan input)

Execute plan over input by composing the operator reference models in topological order. Returns the behavior-preserving summary map {:values :mask int :buckets … :result x :env {…}} where :env maps every node id to its value (relation / table / scalar).

schedule

(schedule plan inventory)(schedule plan inventory {:keys [cost-fn]})

Place plan onto inventory and annotate with a :cost. opts may carry :cost-fn (fn plan -> number) to replace the default estimate — the injection point for a learned cost model. On infeasible plans the placement failure map is returned (no :cost).

supported-ops