optimize-comet-expression

Optimizes existing native scalar expressions in the datafusion-comet spark-expr crate with benchmarked, regression-gated changes.

1.3k|364|Updated Jan 15, 2024
One-click install
npx skills add https://github.com/apache/datafusion-comet --skill optimize-comet-expression
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: optimize-comet-expression
Source: https://github.com/apache/datafusion-comet/tree/main/.ai/skills/optimize-comet-expression
Command: npx skills add https://github.com/apache/datafusion-comet --skill optimize-comet-expression

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Optimizing a Rust scalar expression in Apache DataFusion Comet without a disciplined process leads to fake wins: baselines measured against already-modified code, hidden regressions on dense-null or long-value shapes, and output that silently diverges from main. This Skill enforces a rigorous benchmark-first, no-regression workflow for performance work in native/spark-expr/.

Core Features & Use Cases

  • Baseline-first benchmarking: Captures a criterion baseline from unmodified source before any edit, covering no-null, sparse-null, dense-null, short/long, valid/invalid, and ASCII/non-ASCII shapes.
  • Bit-identical correctness gate: Requires unit tests to pass unchanged and output (values, null buffer, errors) to match main exactly before any submission.
  • No-regression gate with noise filtering: Blocks PRs with reproducible regressions on any shape while teaching how to distinguish cross-run criterion noise from real effects via second samples.
  • Use Case: You want to speed up a string kernel in native/spark-expr/. The Skill walks you through reading the optimizing_expressions.md guide, saving a main baseline, applying a technique from the catalog, re-measuring against the baseline, and recording a dated performance audit before opening a perf PR.

Quick Start

Optimize the native substring expression in the datafusion-comet spark-expr crate following the benchmark-first workflow.

Frequently Asked Questions about optimize-comet-expression

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I optimize a native expression in Apache DataFusion Comet?▼

Read docs/source/contributor-guide/optimizing_expressions.md first, then capture a criterion baseline from unmodified source, apply a technique from the catalog, verify bit-identical output, and re-measure against the baseline. Submit only if no shape reproducibly regresses.

How do I benchmark Rust expressions in the spark-expr crate?▼

Add or extend a criterion benchmark in native/spark-expr/benches/, register it in Cargo.toml, and run cargo bench --bench <name> -- --save-baseline main before editing. Cover no-null, sparse-null, dense-null, short/long, valid/invalid, and ASCII/non-ASCII shapes.

Why does my criterion benchmark show zero speedup after optimizing?▼

The baseline was likely built from source that already contained your optimization, since cargo bench compiles from disk. Stash your edit with git stash push -- <source file>, capture the baseline on unmodified code, then restore the change.

When should I not submit a Comet expression optimization PR?▼

Do not submit if any shape is meaningfully and reproducibly slower, if no shape shows a meaningful speedup, or if output differs from main in values, null placement, or error behavior. A big win on one shape never justifies a regression on another.

Is a small flagged regression in criterion always a real problem?▼

No. Criterion compares two separate process runs, so a small flag on a code path you did not touch is often cross-run noise from thermal or background load. Take a second independent sample; real regressions reproduce, noise does not.