Skip to content

Commit d0c6760

Browse files
authored
feat(native): make native discovery the default compiler engine (#1003)
* feat(native): reproduce each supported Python's text semantics natively Native discovery deferred to Python whenever the running Python's Unicode data differed from the one table it carried (CPython 3.12), so 3.13 and 3.14 never ran natively. Generate a `str.isalnum()` table for the Unicode version of each supported CPython (15.0.0, 15.1.0, 16.0.0), select it by `unicodedata.unidata_version` per call, and reproduce `inspect.cleandoc` per Python minor version (3.13 strips spaces only). Unknown Python or Unicode versions still defer to Python. * feat(native): make native discovery the default compiler engine With SQLBUILD_COMPILER_ENGINE unset, compiles now discover project inputs natively. The differential harness is byte-identical on the per-PR corpus (on Python 3.12, 3.13 and 3.14), the dense corpus and a private real project, and cold, edit and no-change compiles are no slower. SQLBUILD_COMPILER_ENGINE=python keeps the Python discovery as the oracle, and CI keeps comparing both engines. Compiler and Rules stores stay namespaced by engine, so the first compile after upgrading is cold once; semantic fingerprints do not change. Tests that hardcoded the Python engine's cache paths now resolve the active engine's directories, and an E2E test proves the unset default runs native discovery with output identical to the Python engine. * fix(native): name engine-namespaced cache paths and test native discovery on Python 3.13 and 3.14 Docs now name the native engine's compile reuse and Rules cache directories, the unused Python-engine reuse path constant is removed, and a CI job runs the native text oracles and a bounded engine differential on Python 3.13 and 3.14. * ci: generate the base benchmark project with the base checkout's own environment * test(lineage): read the structural cache from the active engine's directory
1 parent 1d70758 commit d0c6760

64 files changed

Lines changed: 2121 additions & 200 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/verify.yml‎

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,50 @@ jobs:
296296
COMPILER_DIFFERENTIAL_ARGS="--stage-captures --require-discovery-coverage
297297
--require-render-coverage"
298298
299+
compiler_differential_python_versions:
300+
name: Native discovery on Python ${{ matrix.python }}
301+
needs: [changes, lockfile]
302+
if: needs.changes.outputs.compiler_differential == 'true'
303+
runs-on: ubuntu-24.04
304+
timeout-minutes: 20
305+
strategy:
306+
fail-fast: false
307+
matrix:
308+
python: ["3.13", "3.14"]
309+
env:
310+
UV_PYTHON: ${{ matrix.python }}
311+
steps:
312+
- uses: actions/checkout@v4
313+
- uses: astral-sh/setup-uv@v5
314+
with:
315+
version: "0.12.3"
316+
enable-cache: true
317+
cache-dependency-glob: |
318+
uv.lock
319+
Cargo.lock
320+
- uses: dtolnay/rust-toolchain@master
321+
with:
322+
toolchain: stable
323+
- name: Install Python
324+
run: uv python install ${{ matrix.python }}
325+
- name: Install dependencies
326+
run: uv sync --locked --all-groups --all-extras --python ${{ matrix.python }}
327+
- name: Require native discovery to support this Python
328+
run: >-
329+
uv run --no-sync python -c "import sys, unicodedata, sqlbuild._native as n;
330+
assert n.native_text_supported(sys.version_info[:2], unicodedata.unidata_version)"
331+
- name: Compare native text helpers with this Python
332+
run: >-
333+
uv run --no-sync pytest
334+
tests/integration/src/sqlbuild/compiler/test_native_python_compat_oracle.py
335+
-n auto --dist loadfile
336+
- name: Compare engines on fixtures, examples, the failure corpus and a few seeds
337+
env:
338+
PYTHONUNBUFFERED: "1"
339+
run: >-
340+
uv run --no-sync python -m scripts.run_compiler_differential
341+
--corpus fixtures examples failures seeds --seeds 4 --jobs 4
342+
299343
format_performance:
300344
name: Formatter performance guards
301345
needs: [changes, lockfile]
@@ -488,7 +532,7 @@ jobs:
488532
run: uv sync --locked --all-groups --all-extras
489533
- name: Install base dependencies
490534
working-directory: base
491-
run: uv sync --locked --all-extras
535+
run: uv sync --locked --all-groups --all-extras
492536
- name: Compare base and head cold, warm and one-model edit compiles
493537
env:
494538
KIND: ${{ matrix.kind }}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//! The generated `str.isalnum()` tables, one per Unicode version of a supported CPython.
2+
3+
/// `(unicodedata.unidata_version, ranges)` for every table native text helpers can select.
4+
pub(crate) const ALNUM_TABLES: [(&str, &[(u32, u32)]); 3] = [
5+
("15.0.0", include!("../alnum_ranges/unicode_15_0_0.in")),
6+
("15.1.0", include!("../alnum_ranges/unicode_15_1_0.in")),
7+
("16.0.0", include!("../alnum_ranges/unicode_16_0_0.in")),
8+
];
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
pub(crate) mod alnum_ranges;
1+
pub(crate) mod alnum_tables;
22
pub(crate) mod cleandoc;
33
pub(crate) mod sequence_matcher;

crates/sqlbuild-core/src/text/_helpers/alnum_ranges.rs renamed to crates/sqlbuild-core/src/text/alnum_ranges/unicode_15_0_0.in

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
//! Generated by `scripts/generate_python_char_table.py`; do not edit.
2-
3-
/// The Unicode version of the Python that generated the table.
4-
pub(crate) const PYTHON_ALNUM_UNICODE_VERSION: &str = "15.0.0";
5-
6-
/// Inclusive code point ranges where Python's `str.isalnum()` is true, in order.
7-
pub(crate) const PYTHON_ALNUM_RANGES: &[(u32, u32)] = &[
1+
// Generated by `scripts/generate_python_char_table.py`; do not edit.
2+
// Inclusive code point ranges where `str.isalnum()` is true in Unicode 15.0.0, in order.
3+
&[
84
(0x0030, 0x0039),
95
(0x0041, 0x005A),
106
(0x0061, 0x007A),
@@ -752,4 +748,4 @@ pub(crate) const PYTHON_ALNUM_RANGES: &[(u32, u32)] = &[
752748
(0x2F800, 0x2FA1D),
753749
(0x30000, 0x3134A),
754750
(0x31350, 0x323AF),
755-
];
751+
]

0 commit comments

Comments
 (0)