Skip to content
Open
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
624 changes: 624 additions & 0 deletions aerospike_sdk/ael/_rust_fastpath.py

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions aerospike_sdk/ael/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
MapValuePart,
)
from aerospike_sdk.ael.filter_gen import FilterGenerator, IndexContext, ParseResult
from aerospike_sdk.ael._rust_fastpath import try_parse_ael_rust


class _AELParseErrorListener(ErrorListener):
Expand Down Expand Up @@ -163,6 +164,9 @@ def parse_ael(expression: str, *args: Any) -> FilterExpression:
if _parser is None:
_parser = AELParser()
placeholder_values = PlaceholderValues(*args) if args else None
rust_result = try_parse_ael_rust(expression, placeholder_values)
if rust_result is not None:
return rust_result
return _parser.parse(expression, placeholder_values)


Expand Down
68 changes: 68 additions & 0 deletions docs/benchmarks/ael-rust-fastpath-results.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# AEL Rust Fast Path Results

This benchmark note captures the current behavior and performance of the Rust-backed AEL fast path after native lowering for `let(...)`, `when(...)`, and variable references.

## Verification

- `cargo test --manifest-path rust/ael_rust_ext/Cargo.toml --target-dir /tmp/ael_rust_ext-target`: `5 passed`
- `pytest tests/unit -q`: `1581 passed`
- `pytest tests/integration -q`: `979 passed, 37 skipped, 2 xfailed`

## Parser Benchmark

![AEL parser throughput](ael-rust-parser-throughput.svg)

![AEL parser latency](ael-rust-parser-latency.svg)

### Repo expression corpus

- Raw corpus size: `868`
- Supported by Rust fast path: `750`
- Raw skips: `118`
- Skip classification: `28` placeholder-only cases with no values supplied, `90` expressions that Python itself rejects
- Real valid-expression fallbacks: `0`
- Mismatches vs Python: `0`
- Python parser throughput: `4,798.66 expr/s`
- Rust fast path throughput: `12,988.76 expr/s`
- Python parser time: `208.39 us/expr`
- Rust fast path time: `76.99 us/expr`
- Speedup: `2.71x`

### Literal `parse_ael(...)` callsites

- Corpus size: `596`
- Supported by Rust fast path: `596/596`
- Mismatches vs Python: `0`
- Python parser throughput: `4,496.22 expr/s`
- Rust fast path throughput: `9,842.60 expr/s`
- Python parser time: `222.41 us/expr`
- Rust fast path time: `101.60 us/expr`
- Speedup: `2.19x`

## Live Workload Benchmark

Environment:

- Aerospike server: Docker `aerospike/aerospike-server:8.1.0.2`
- Address: `127.0.0.1:3000`
- Workload: `RU,50`
- Command: `python -m benchmarks.benchmark -k 100 -z 4 -w RU,50 -d 3 --warmup 0 --cooldown 0`

Results:

- Total TPS: `8389`
- Read TPS: `4161`
- Write TPS: `4228`
- Latency: `p50=0.4ms p90=0.9ms p99=1.4ms p99.9=1.6ms max=1.8ms`
- Peak RSS: `48.8 MB`

Comparison run:

- PAC async: `9016 TPS`, `p99=1.4ms`, `RSS=42.3MB`
- PSDK async: `8486 TPS`, `p99=1.4ms`, `RSS=49.0MB`
- PSDK sim-sync: `3007 TPS`, `p99=0.7ms`, `RSS=49.2MB`

Interpretation:

- The parser work is materially faster.
- The live `RU,50` benchmark does not show a major end-to-end TPS change because it is primarily request/response bound rather than parser bound.
27 changes: 27 additions & 0 deletions docs/benchmarks/ael-rust-parser-latency.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions docs/benchmarks/ael-rust-parser-throughput.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions rust/ael_rust_ext/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "ael_rust_ext"
version = "0.1.0"
edition = "2021"

[lib]
name = "ael_rust_ext"
crate-type = ["cdylib"]

[dependencies]
pyo3 = { version = "0.21.2", features = ["extension-module"] }
Loading