@@ -30,7 +30,7 @@ PYTHON_TYPED := scripts tests/unit/scripts python/src $(PYTHON_API_TESTS)
3030PYTHON_TESTS := tests/unit/scripts $(PYTHON_API_TESTS )
3131endif
3232
33- .PHONY : distribution-notices format rust-lint python-check fensu syntax-coverage depth-probe depth-probe-debug gate-build evidence-guard polyglot-guard engine-free generate-cases generated-cases generate-syntax-cases syntax-cases corpus-rerecord generate-referee-cases referee-cases referee-pending translation-results check-ci check-merge test test-rust test-python python-module python-api python-wheel verify-recorded polyglot-duckshop census-duckshop fuzz-smoke gate gate-parallel census duckshop-compiled duckshop-measure
33+ .PHONY : distribution-notices format rust-lint python-check fensu syntax-coverage depth-probe depth-probe-debug gate-build evidence-guard polyglot-guard engine-free generate-cases generated-cases generate-syntax-cases syntax-cases corpus-rerecord generate-referee-cases referee-cases referee-pending translation-results sql-sizes sql-size-baseline sql-benchmark check-ci check-merge test test-rust test-python python-module python-api python-wheel verify-recorded polyglot-duckshop census-duckshop fuzz-smoke gate gate-parallel census duckshop-compiled duckshop-measure
3434
3535format :
3636 cargo fmt --all
@@ -203,11 +203,44 @@ TRANSLATION_REPORT ?= target/translation-results.json
203203RESULTS_BASE ?= $(EVIDENCE_BASE )
204204RESULTS_BASE_FILE := target/translation-results-base.json
205205
206+ # Verify also writes the bytes of DuckDB SQL each converted case emits to SQL_SIZES, which must equal
207+ # coverage/sql-size/baseline.json and must not grow against the baseline at RESULTS_BASE beyond what
208+ # coverage/sql-size/allowances.toml rules.
209+ SQL_SIZES ?= target/sql-sizes.json
210+ SQL_SIZE_BASELINE := coverage/sql-size/baseline.json
211+ SQL_SIZE_BASE_FILE := target/sql-size-base.json
212+ SQL_SIZE_ALLOWANCES := coverage/sql-size/allowances.toml
213+
206214verify-recorded :
207215 mkdir -p $(dir $(COVERAGE_REPORT ) )
208216 cargo run --release --locked -p sqlquack -- verify $(VERIFY_FLAGS ) $(COVERAGE_FLAGS ) --python $(VERIFY_PYTHON ) \
209- --translation-statements $(TRANSLATION_STATEMENTS )
217+ --translation-statements $(TRANSLATION_STATEMENTS ) --sql-sizes $( SQL_SIZES )
210218 $(MAKE ) translation-results
219+ $(MAKE ) sql-sizes
220+
221+ # The generated-SQL size ratchet over the sizes verify wrote; see verify-recorded.
222+ sql-sizes :
223+ @if git show $(RESULTS_BASE ) :$(SQL_SIZE_BASELINE ) > $(SQL_SIZE_BASE_FILE ) 2> /dev/null; \
224+ then against=" --against $( SQL_SIZE_BASE_FILE) " ; \
225+ else echo " sql-sizes: $( RESULTS_BASE) has no baseline; checking the committed one only" ; against=; fi ; \
226+ uv run python -m scripts.check_sql_sizes $(SQL_SIZES ) --baseline $(SQL_SIZE_BASELINE ) \
227+ --allowances $(SQL_SIZE_ALLOWANCES ) $$ against
228+
229+ # Rewrites coverage/sql-size/baseline.json from the sizes the last verify-recorded wrote.
230+ sql-size-baseline :
231+ uv run python -m scripts.check_sql_sizes $(SQL_SIZES ) --baseline $(SQL_SIZE_BASELINE ) --update
232+
233+ # Times the converted VARIANT and decimal division examples over a million rows against hand-written
234+ # DuckDB SQL, and fails when one's time over its reference exceeds twice the ratio
235+ # coverage/sql-size/benchmarks.json records. SQL_BENCHMARK_ARGS=--update records the ratios.
236+ SQL_BENCHMARK_ARGS ?=
237+ sql-benchmark :
238+ cargo build --locked --release -p sqlquack
239+ target=" $$ {CARGO_TARGET_DIR:-target}" ; \
240+ library=" $$ (ls " $$ target" /duckdb-download/*/*/libduckdb.so 2>/dev/null | head -1)" ; \
241+ test -n " $$ library" || { echo " sql-benchmark: no libduckdb.so under $$ target/duckdb-download" >&2 ; exit 1; }; \
242+ LD_LIBRARY_PATH=" $$ (dirname " $$ library" )" uv run python -m scripts.benchmark_sql --sqlquack " $$ target/release/sqlquack" \
243+ --budget coverage/sql-size/benchmarks.json $(SQL_BENCHMARK_ARGS )
211244
212245# The result-matching measure over the statements verify wrote; see verify-recorded.
213246translation-results :
@@ -296,10 +329,11 @@ fuzz-smoke:
296329# timed conversion on DuckShop, and the fuzz smoke. The pre-push verify hook runs this.
297330# After the static gate, the independent targets run in parallel, each target's output kept
298331# together; any failure fails the gate. The verify hook builds what they need beforehand. The fuzz
299- # smoke runs alone afterwards, so its time-boxed run gets the machine to itself.
332+ # smoke and then the SQL timing benchmark run alone afterwards, so each gets the machine to itself.
300333gate : check-ci $(if $(filter command line,$(origin DUCKSHOP_COMPILED ) ) ,,duckshop-compiled)
301334 $(MAKE ) -j --output-sync=target gate-parallel
302335 $(MAKE ) fuzz-smoke
336+ $(MAKE ) sql-benchmark
303337
304338gate-parallel : test-rust test-python verify-recorded polyglot-duckshop census-duckshop
305339
0 commit comments