feat: replace C++ FFI with native Rust parser - #119
#119feat: replace C++ FFI with native Rust parser#119countradooku wants to merge 3 commits intoada-url:mainada-url/rust:mainfrom countradooku:feat/native-rust-portcountradooku/rust:feat/native-rust-portCopy head branch name to clipboard
Conversation
| # instrumented. LeakSanitizer is enabled by default under ASan on Linux; | ||
| # this catches regressions like https://github.com/ada-url/rust/issues/101 | ||
| # where the failed-parse path leaked the allocation from `ada_parse`. | ||
| - name: Test under AddressSanitizer + LeakSanitizer |
| if: matrix.env.CARGO_BUILD_TARGET == 'wasm32-wasip1' | ||
| run: | | ||
| rustup target add wasm32-wasip1 | ||
| curl -LO https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-33/wasi-sdk-33.0-x86_64-linux.deb |
There was a problem hiding this comment.
We should keep this and make sure it works with wasm etc...
Merging this PR will regress 1 benchmark
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ❌ | Simulation | ada_url |
3.7 µs | 4.9 µs | -24.91% |
| ⚡ | Simulation | ada_url |
4.8 ms | 2.3 ms | ×2.1 |
| ⚡ | Simulation | ada_url |
14.4 µs | 7.5 µs | +91.06% |
| ⚡ | Simulation | ada_url_parse |
165.6 ms | 98.5 ms | +68.13% |
| ⚡ | Simulation | ada_url |
830.7 µs | 515.3 µs | +61.22% |
| ⚡ | Simulation | ada_url |
3.4 ms | 2.6 ms | +33.02% |
| ⚡ | Simulation | ada_url |
24.8 µs | 22.2 µs | +11.75% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing countradooku:feat/native-rust-port (6269893) with main (af35063)
|
i think I need to tae a look at CodSpeed Performance Analysis |
|
Performance follow-up is pushed in Side-by-side release benchmarks against
Validation is green locally: all features, no-default-features, full WPT/IDNA/URLPattern corpora, Clippy, docs, Miri, package verification, and WASI compilation. I also fixed the pinned-toolchain Miri invocation. The new GitHub Actions/CodSpeed runs are currently marked |
| - run: cargo clippy --all-targets --all-features --locked -- -D warnings | ||
|
|
||
| miri: | ||
| name: Miri |
| - os: ubuntu-latest | ||
| env: | ||
| CARGO_BUILD_TARGET: wasm32-wasip1 | ||
| CARGO_TARGET_WASM32_WASI_RUNNER: /home/runner/.wasmtime/bin/wasmtime --dir=. |
| "LongYinan <github@lyn.one>", | ||
| "Boshen <boshenc@gmail.com>" | ||
| "Boshen <boshenc@gmail.com>", | ||
| "Diaconu Radu-Mihai <52667211+countradooku@users.noreply.github.com>" |
There was a problem hiding this comment.
is this the email you want to keep?
| repository = "https://github.com/ada-url/rust" | ||
| homepage = "https://ada-url.com" | ||
| license = "MIT OR Apache-2.0" | ||
| links = "ada-url" |
| url-pattern = ["dep:urlpattern", "std"] | ||
|
|
||
| [dependencies] | ||
| idna = "1.1.0" |
There was a problem hiding this comment.
we shouldn't have any dependency at all
| [dependencies] | ||
| idna = "1.1.0" | ||
| memchr = "2.8.0" | ||
| percent-encoding = "2.3.2" |
There was a problem hiding this comment.
please don't use a dependency for this
There was a problem hiding this comment.
ada doesn't have any dependencies. we should keep the same.
|
|
||
| [dev-dependencies] | ||
| criterion = { package = "codspeed-criterion-compat", version = "4", default-features = false, features = ["cargo_bench_support"] } | ||
| url = "2" # Used by benchmarks |
|
The final CodSpeed regression is addressed in
That is ~62% lower than the previous native result and ~67% lower than upstream. The mixed The new CI and CodSpeed runs are awaiting maintainer approval again because this is a fork PR. |
Summary
ada-urlpublic API,no_stdsupport, serde behavior, and the formerbundled/libcppfeature names as compatibility no-opsada-url/adafixtures at30f3f3020c5a979b62f90dc9c37fd45de3cc84d7Impact
This removes
build.rs, the C/C++ FFI layer, and the vendored Ada sources. Most of the apparent diff size is the deletion of roughly 27,000 lines fromada.cppandada.h; the native implementation is roughly 5,000 lines of Rust.The packaged crate verifies successfully at 132.7 KiB compressed. Existing benchmark targets remain available, and smoke runs cover both the focused parser corpus and all 891 WPT URL entries.
Conformance
The test suite now directly covers:
The current fixtures are recorded in
tests/wpt/UPSTREAM.Validation
rustup run 1.96.1 cargo test --all-features --lockedrustup run 1.96.1 cargo test --no-default-features --lockedcargo clippy --all-targets --all-features --locked -- -D warningsRUSTDOCFLAGS='-D warnings' cargo doc --all-features --no-deps --lockedcargo fmt --all -- --checkcargo package --allow-dirty --lockedcargo bench --bench parse -- --quickcargo bench --bench wpt -- --quick