Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion benchmarks/bench_serving.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
Run: uv run python -m benchmarks.bench_serving [--json out.json]
IMPORTANT: rebuild the wheel first (uv run --reinstall-package sql-transform
python -c pass) — a stale wheel inflates ONLY the engine rows and once
produced a phantom 7x regression (caught by bisection, 2026-07-26).
produced a phantom 7x regression (caught by bisection, 2026-07-26). Debug
builds (the native test guard's `maturin develop` shadowing the release
wheel) are refused automatically before any timing.
"""

from __future__ import annotations
Expand Down Expand Up @@ -140,6 +142,24 @@ def engine_run(engines):
print(json.dumps(results))


def refuse_debug_build():
"""Abort unless the imported native extension is a release build.

tests/_native_guard.py rebuilds the cwd-local .pyd via plain `maturin
develop` (debug) whenever src/*.rs is newer; that shadows the venv's
release wheel and silently inflates engine rows ~5x (measured 2026-07-26).
"""
from sql_transform import _interpreter

profile = getattr(_interpreter, "BUILD_PROFILE", None)
if profile != "release":
sys.exit(
f"bench_serving: refusing to time a non-release native build "
f"(BUILD_PROFILE={profile!r}, loaded from {_interpreter.__file__}).\n"
f"Rebuild with: uv run maturin develop --release"
)


def orchestrate():
print("parity gate:", flush=True)
for mod in map(sc.load, scenario_names()):
Expand Down Expand Up @@ -192,6 +212,7 @@ def orchestrate():


if __name__ == "__main__":
refuse_debug_build()
if "--engine-run" in sys.argv:
engine_run(os.environ["BENCH_ENGINES"].split(","))
else:
Expand Down
10 changes: 10 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,15 @@ mod value;
fn _interpreter(m: &Bound<'_, PyModule>) -> PyResult<()> {
m.add_class::<datafusion::InferFn>()?;
m.add_class::<duckdb::DuckDBInferFn>()?;
// Lets benchmarks refuse an unoptimized build (a `maturin develop` debug
// .pyd shadowing the release wheel once inflated engine rows ~5x).
m.add(
"BUILD_PROFILE",
if cfg!(debug_assertions) {
"debug"
} else {
"release"
},
)?;
Ok(())
}
3 changes: 2 additions & 1 deletion tests/_native_guard.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ def ensure_native_built() -> None:
return
print(
"native guard: src/*.rs newer than _interpreter -- rebuilding "
"(maturin develop)...",
"(maturin develop, DEBUG profile; benchmarks will refuse this build "
"-- rerun with --release before timing)...",
file=sys.stderr,
)
# noqa justification: maturin is the venv's own executable and _REPO derives
Expand Down