Merged
Conversation
… to optimize auto
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. ℹ️ You can also turn on project coverage checks and project coverage reporting on Pull Request comment Thanks for integrating Codecov - We've got you covered ☂️ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rust + PyO3 Bindings for High-Performance AGON Encoding
Summary
This PR introduces a complete Rust core implementation for AGON with PyO3 bindings, delivering significant performance improvements while maintaining 100% API compatibility with the Python-only implementation.
Key Achievements
Motivation
The original Python-only implementation worked well for small datasets but faced performance bottlenecks on larger payloads:
Solution: Rewrite the core encoding/decoding engine in Rust, expose it to Python via PyO3, and leverage Rust's performance advantages (compiled code, zero-cost abstractions, parallel processing with rayon).
Changes
New Rust Core (
crates/agon-core/)src/formats/rows.rs: AGONRows format implementation (1,339 lines)src/formats/columns.rs: AGONColumns format implementation (1,309 lines)src/formats/struct_fmt.rs: AGONStruct format implementation (1,501 lines)src/lib.rs: PyO3 bindings and Python interface (513 lines)src/error.rs: Custom error types with PyO3 integration (102 lines)src/types.rs: Shared type definitions (130 lines)src/utils.rs: Utility functions (74 lines)Python Layer Refactoring
src/topython/for claritypython/agon/core.pyto use Rust bindings (reduced from ~1,000 lines to 166 lines)src/agon/formats/text.py(837 lines) → ✅crates/agon-core/src/formats/rows.rssrc/agon/formats/columns.py(895 lines) → ✅crates/agon-core/src/formats/columns.rssrc/agon/formats/struct.py(1,070 lines) → ✅crates/agon-core/src/formats/struct_fmt.rsDocumentation Updates
Build & Tooling
CI/CD Enhancements:
.github/workflows/ci.yml: Added Rust toolchain installation and Rust coverage reporting to the CI workflow, ensuring Rust code is built, tested, and covered alongside Python code [1] [2] [3].github/workflows/publish.yml: Refactored to build wheels for Linux (x86_64, aarch64), macOS (x86_64, aarch64), and Windows (x64) usingmaturin, with separate jobs for each platform. Added source distribution build and aggregates all artifacts before uploading to PyPICargo.toml: Introduced Rust workspace with common dependencies and release profile optimizations for performanceDevelopment Tooling:
Makefile: Updated to include Rust build, test, and benchmark targets, improved help output to clarify hybrid workflow. Both Python and Rust linting/formatting now run in parallel [1] [2].pre-commit-config.yaml: Enhanced with Rust formatting (cargo fmt) and linting (cargo clippy) hooks, upgraded Python tooling (Ruff, codespell), improved Python type checking coveragepyproject.toml: Configuredmaturinfor building PyO3 extensioncodecov.yml: Added coverage configuration for both Python and RustFor Contributors
cargo,rustcviarustup)make buildto compile Rust code (automatically done bymaturin develop)cargo clippy,cargo fmt)Testing
All existing tests pass with Rust implementation:
tests/test_core.py: Core AGON.encode/decode functionalitytests/test_rows.py: AGONRows format (renamed from test_text.py)tests/test_columns.py: AGONColumns formattests/test_struct.py: AGONStruct formattests/test_benchmarks.py: Performance benchmarks with encode/decode timesRunning Tests
Documentation Changes
encoding: Encoding | None = Noneparameter, movedhint()method to AGONEncoding classFuture Work
Potential optimizations and enhancements: