Skip to content

docs: design doc for planner-layering stage components, algorithms and code interfaces - #688

Open
zzylol wants to merge 4 commits into
mainfrom
docs/planner-layering-code-map
Open

zzylol wants to merge 4 commits into
mainfrom
docs/planner-layering-code-map

Conversation

@zzylol

@zzylol zzylol commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Why

planner-layering.md defines the planning stages, passes and algorithms. Nothing explains how they are actually built: which components implement each stage, how the implemented algorithm runs, and where it differs from the design. Developers need that before they can extend a stage or compare it with the design.

What

This PR adds a design doc, docs/design_docs/planner-layering-components.md, and links it from docs/design_docs/README.md. It describes main @ 80fc72e1 in planner-layering.md's stage order. No code changes.

How

The doc opens with a pipeline diagram of the types passed between stages and pseudocode for the top-level run. Each stage then gets three parts:

  1. Core components: what each component is and does.
  2. Core algorithm: pseudocode for what is implemented, mapped to the design's algorithms, followed by the differences from the design.
  3. Code interface: short verbatim signatures, inputs → outputs.

The stages covered:

  • Stage 0, query-language frontends.
  • Stage 1, logical ASAP-aware optimization:
    • Pass 1, including whole-expression top-k candidates.
    • Composition with sizing per target, and symbolic guarantee composition.
    • Pass 2's identical-expression rule (Next Closure over sharing groups), within a lazy enumeration.
  • Stage 2, physical ASAP-aware optimization: operator implementation and materialization assignment.
  • Stage 3, plan selection:
    • The output-level accuracy check: counter weights confirmed, statistics bound, deployment evidence.
    • Per-second pricing with retained-state memory, and the ranking.
  • Stage 4, execution: the hand-off.

It ends with a few lines on tooling and legacy code, and design-level notes on what is not implemented yet.

Before this PR

Mapping a design stage to code meant reading the module docs of asap-aware-mapping and asap-types. There was no single description of how the implemented algorithms compare with the design, such as Pass 2's two unimplemented rules or Stage 2's single materialization option.

After this PR

One design doc answers, stage by stage:

  • what the components are;
  • how the algorithm runs today;
  • where it falls short of the design;
  • which functions and types to call.

Example (Stage 1 Pass 2, as the doc presents it):

identical_expression_variants(roots, groups):
    for each closed subset S of the sharing groups, in binary-counter order:
        emit roots with every group in S made one node serving all its consumers

Verification

  • Every repository path, type and function name in the doc was grepped on origin/main @ 80fc72e1 and exists. The exceptions are the design-doc terms LogicalDAG, CandidateLogicalDAGs and MATCH.
  • Every non-comment line of the Rust excerpts matches the source exactly.
  • Links resolve to existing files and planner-layering.md headings.
  • Screenshots and measurements: not applicable (documentation only).

🤖 Generated with Claude Code

@zzylol zzylol added the documentation Improvements or additions to documentation label Oct 14, 2026
@zzylol zzylol changed the title docs: map planner-layering stages and passes to code components and interfaces docs: design doc for planner-layering stage components, algorithms and code interfaces Oct 14, 2026
| Pass 1 (`crates/asap-aware-mapping/src/per_computation_candidates.rs`, `generate_per_computation_candidates`) | Finds every computation target and its unranked, unsized candidates, with pruned candidates and reasons. |
| Composition (same file, `compose_logical_candidate`) | Builds one whole-workload candidate DAG from one choice per target, sizes its summaries and gives every node a guarantee. |
| Summary realization (`crates/asap-aware-mapping/src/realization.rs`) | The summary families per intent (`summary_candidates`), the `(ε, δ)` budget of a target, and default sizing. |
| Accuracy model (`crates/asap-aware-mapping/src/accuracy/`) | `DefaultAccuracyModel`: local error bounds of sized families, propagation rules (`composition.rs`), and per-family sizing (`estimators/`). |

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on planner-layering.md doc, should the accuracy model in Stage 1?

Move it to docs/design_docs/planner-layering-components.md and describe each
stage by its core components, its algorithm as implemented, and its code
interface; note where the implementation differs from the planning-stages
design. Link it from the design docs README instead of the developer docs.
Describe Pass 2's identical-expression rule, whole-expression top-k
candidates, symbolic guarantee composition bound in plan selection, counter
weight confirmation, per-second pricing with retained-state memory, and the
lazy Stage 1 enumeration; update the code interfaces and the notes on what is
not implemented yet.
@zzylol
zzylol force-pushed the docs/planner-layering-code-map branch 2 times, most recently from 2b51902 to 054c30c Compare October 14, 2026 23:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant