Skip to content

Add native SVG polyline path serializer and bump ABI to 36#94

Merged
Alek99 merged 3 commits into
mainfrom
codex/evaluate-svg-rasterization-speed-in-rust
Jul 19, 2026
Merged

Add native SVG polyline path serializer and bump ABI to 36#94
Alek99 merged 3 commits into
mainfrom
codex/evaluate-svg-rasterization-speed-in-rust

Conversation

@FarhanAliRaza

Copy link
Copy Markdown
Contributor

Motivation

  • Add a native, zero-copy SVG polyline path serializer to produce compact path strings in Rust instead of building one Python string per point for performance and consistency.
  • Expose the serializer across the C ABI so Python can call into the Rust core and avoid per-point Python allocations.
  • Bump the ABI version to reflect the new exported function so loaders can detect mismatched libraries.

Description

  • Bump ABI version from 35 to 36 in both src/lib.rs and python/xy/_native.py to account for the new FFI entry.
  • Implement svg::poly_path in a new src/svg.rs module that formats screen-space coordinates into an SVG path string with the same fixed-point formatting as the public SVG exporter.
  • Add a C ABI entry xy_svg_poly_path in src/lib.rs that returns the required byte count and supports size-query retries, and wire its signature into the Python ctypes wrapper in python/xy/_native.py.
  • Add a Python convenience wrapper svg_poly_path that calls the FFI with a resizable buffer, and switch _poly_path in python/xy/_svg.py to use _native.svg_poly_path.
  • Add unit tests: a Rust test in src/svg.rs and a Python test test_native_svg_poly_path_format_and_validation in tests/test_kernels.py to validate formatting and error handling.

Testing

  • Ran the Rust unit tests with cargo test, and the new svg::poly_path test passed.
  • Ran Python unit tests with pytest, including the new tests/test_kernels.py::test_native_svg_poly_path_format_and_validation, and all tests passed.
  • Verified the Python FFI path-resize/retry behavior by exercising the svg_poly_path wrapper in the added test.

Codex Task

@codspeed-hq

codspeed-hq Bot commented Jul 19, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by ×2.7

⚡ 1 improved benchmark
✅ 93 untouched benchmarks
⏩ 1 skipped benchmark1

Performance Changes

Benchmark BASE HEAD Efficiency
test_svg_export_line 18.1 ms 6.6 ms ×2.7

Tip

Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.


Comparing codex/evaluate-svg-rasterization-speed-in-rust (f14122b) with main (e2d0460)

Open in CodSpeed

Footnotes

  1. 1 benchmark was skipped, so the baseline result was used instead. If it was deleted from the codebase, click here and archive it to remove it from the performance reports.

@Alek99
Alek99 merged commit 4a2541f into main Jul 19, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants