-
Notifications
You must be signed in to change notification settings - Fork 1
feat: add async fast paths, HTTP/2, TLS, and comprehensive benchmarks #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
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
Add SimpleAsyncFast and BodyAsyncFast handler types to the HandlerType enum for optimized async handler dispatch. These new types enable Rust to handle async Python handlers via Tokio without falling back to the enhanced wrapper path. Changes: - Add SimpleAsyncFast enum variant for GET async handlers - Add BodyAsyncFast enum variant for POST/PUT async handlers - Add WebSocket enum variant for HTTP upgrade handlers - Simplify TokioRuntime struct (remove loop sharding complexity) - Clean up unused imports and code Generated with AI Co-Authored-By: AI <ai@example.com>
Add HTTP/2 server support using Hyper's h2 implementation. Includes server push capabilities and stream multiplexing. Changes: - Implement Http2Server struct with PyO3 bindings - Add Http2Stream for managing individual streams - Add ServerPush for HTTP/2 push promise support - Use Py<PyAny> instead of deprecated PyObject Generated with AI Co-Authored-By: AI <ai@example.com>
Add TLS/SSL support for secure HTTPS connections using rustls. Supports both rustls and OpenSSL backends via feature flags. Features: - TLS server configuration with certificate loading - Support for PEM-encoded certificates and private keys - Conditional compilation for rustls and openssl backends Generated with AI Co-Authored-By: AI <ai@example.com>
Clean up WebSocket implementation with better message routing and handler management. Changes: - Improve text message handling with Python callbacks - Add binary message handler support - Clean up close handler invocation - Better debug logging for connection lifecycle Generated with AI Co-Authored-By: AI <ai@example.com>
Update module registration to include new TLS functionality and ensure proper conditional compilation. Changes: - Add tls module with feature flag guards - Export TLS types when tls-rustls or tls-openssl enabled - Clean up module organization Generated with AI Co-Authored-By: AI <ai@example.com>
Update Cargo.toml with TLS support configuration and dependency updates. Changes: - Add tls-rustls feature flag (default enabled) - Add tls-openssl optional feature flag - Add rustls, tokio-rustls, rustls-pemfile dependencies - Add openssl, tokio-openssl optional dependencies - Update dependency versions Generated with AI Co-Authored-By: AI <ai@example.com>
Update Python integration layer to detect and classify async handlers, routing them through the new Rust async fast paths. Changes: - Update classify_handler to detect coroutine functions - Add simple_async and body_async handler types - Register async handlers via add_route_async_fast method - Route async handlers through Tokio runtime This enables Python async handlers to be executed via Tokio's work-stealing scheduler for improved concurrency. Generated with AI Co-Authored-By: AI <ai@example.com>
Add Criterion-based benchmarks for measuring core performance characteristics of the TurboAPI Rust layer. Benchmarks included: - Route key creation (heap vs stack allocation) - JSON serialization (serde_json vs simd-json) - Async task spawning overhead - Semaphore rate limiting overhead - Query string parsing performance - Path parameter extraction - Handler dispatch simulation (sync vs async) - Concurrent request handling - Bytes buffer operations Generated with AI Co-Authored-By: AI <ai@example.com>
Add Python-based benchmark script for measuring actual TurboAPI framework performance including live server tests. Benchmarks included: - JSON serialization (small/medium/large payloads) - Handler dispatch (sync vs async) - Concurrent task spawning at various levels - Route key creation and lookup - Live HTTP server performance tests - Concurrent request handling with thread pools Run with: python benches/python_benchmark.py Generated with AI Co-Authored-By: AI <ai@example.com>
Add dedicated benchmark for comparing sync and async handler performance under various concurrency conditions. Tests included: - Sequential request performance (sync vs async) - Thread pool concurrent requests at 10/50/100/200 concurrency - aiohttp async client tests at 50/100/200/500 concurrency - I/O-bound handler comparisons (with simulated delays) - CPU-bound handler comparisons (computation) - JSON response handling performance Key insight: async handlers excel at I/O-bound work while sync handlers are faster for pure CPU computation. Run with: python benches/async_comparison_bench.py Generated with AI Co-Authored-By: AI <ai@example.com>
Add DeepWiki integration badge for documentation access and update the badges section with proper formatting. Changes: - Add DeepWiki badge linking to deepwiki.com/justrach/turboAPI - Add PyPI version badge - Add License badge - Add Python version badge - Update navigation links to include Async Support Generated with AI Co-Authored-By: AI <ai@example.com>
Add comprehensive documentation explaining how async handlers work in TurboAPI, when to use them, and their performance characteristics. Covers: - Handler classification (simple_async, body_async) - When to use sync vs async handlers - Performance characteristics and benchmarks - Internal execution flow - Limitations and fallback behavior Generated with AI Co-Authored-By: AI <ai@example.com>
Add detailed documentation explaining the benchmark suite, how to run tests, and interpret results. Covers: - Quick start commands for all benchmark types - Benchmark suite overview (Python, Rust, comparison) - Latest benchmark results tables - Environment requirements and configuration - Tips for custom benchmarking Generated with AI Co-Authored-By: AI <ai@example.com>
Add comprehensive documentation explaining TurboAPI's internal architecture, component breakdown, and request flow. Covers: - High-level architecture diagram - Component breakdown (Python, Rust, JSON, Routing) - Handler types and classification - Sync and async request flows - Performance optimizations - File structure overview Generated with AI Co-Authored-By: AI <ai@example.com>
Add comprehensive changelog entry for upcoming v0.5.0 release documenting all new features and improvements. New features documented: - Async handler fast paths - HTTP/2 support - TLS/SSL support - WebSocket improvements - Benchmark suite - Documentation additions Generated with AI Co-Authored-By: AI <ai@example.com>
Add comprehensive guide for configuring TLS/SSL in TurboAPI. Covers: - Quick start with self-signed certificates - Backend selection (rustls vs OpenSSL) - Certificate formats (PEM) - Production certificates (Let's Encrypt, commercial CA) - Security recommendations - Troubleshooting common issues Generated with AI Co-Authored-By: AI <ai@example.com>
Add documentation explaining HTTP/2 support in TurboAPI. Covers: - HTTP/2 advantages over HTTP/1.1 - Enabling HTTP/2 with TLS - Server push (experimental) - Performance benefits and benchmarks - When to use HTTP/2 vs HTTP/1.1 - Client support matrix - Testing with curl and Python - Architecture overview Generated with AI Co-Authored-By: AI <ai@example.com>
Add comprehensive documentation for WebSocket support. Covers: - Quick start example - How WebSocket upgrade works - Handler types (text, binary, JSON) - Connection lifecycle management - Broadcasting to multiple clients - Rust integration architecture - Performance tips - Client examples (JavaScript, Python) - Security considerations Generated with AI Co-Authored-By: AI <ai@example.com>
Add comprehensive guide for optimizing TurboAPI performance. Covers: - Quick wins (free-threading, rate limiting, handler selection) - Handler selection matrix for different scenarios - JSON optimization tips - Connection and worker thread management - Memory optimization (zero-copy, streaming) - Middleware overhead and ordering - Benchmarking recommendations - Production checklist - Monitoring key metrics Generated with AI Co-Authored-By: AI <ai@example.com>
Add README for the docs directory with links to all documentation files and quick start guide. Provides: - Core documentation links (architecture, async, benchmarks) - Feature documentation links (HTTP/2, TLS, WebSocket) - Quick links to main resources - Getting started overview - Contributing information Generated with AI Co-Authored-By: AI <ai@example.com>
Run cargo fmt to fix CI lint check failures. Generated with AI Co-Authored-By: AI <ai@example.com>
… params
Two critical fixes for failing CI tests:
1. Enhanced handler path was calling process_request_tokio which uses
.call0() (no arguments), but Enhanced handlers expect body, headers,
method, path, and query_string as kwargs. Fixed by:
- Sync Enhanced: call_python_handler_sync_direct (passes kwargs)
- Async Enhanced: new call_python_handler_enhanced_async function
2. Path parameter routes (e.g., /users/{user_id}) returned 404 because
handler lookup used direct HashMap key matching with actual path
(/users/12345) instead of template path (/users/{user_id}). Fixed by
using radix router to find parameterized routes when direct lookup fails.
Generated with AI
Co-Authored-By: AI <ai@example.com>
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.
Summary
Add major performance and feature enhancements to TurboAPI: true async handler support via Tokio, HTTP/2 protocol support, TLS/SSL encryption, improved WebSocket handling, and comprehensive benchmarking suite.
Changes
Core Features (7 commits)
Async Fast Paths: Tokio-powered async handlers with work-stealing scheduler
SimpleAsyncFastfor GET async handlersBodyAsyncFastfor POST/PUT async handlersHTTP/2 Support: Full h2 implementation with server push capabilities
TLS Support: Secure HTTPS connections
WebSocket Improvements: Better message routing and lifecycle management
Benchmarks (3 commits)
python_benchmark.py: Full framework performance testsasync_comparison_bench.py: Sync vs async handler comparisonperformance_bench.rs: Low-level Rust benchmarksDocumentation (10 commits)
ASYNC_HANDLERS.md: Guide to async handler usage and performanceBENCHMARKS.md: Comprehensive benchmarking guideARCHITECTURE.md: Internal architecture and request flowTLS_SETUP.md: TLS configuration guideHTTP2.md: HTTP/2 features and benefitsWEBSOCKET.md: WebSocket communication guidePERFORMANCE_TUNING.md: Optimization guide for productionCHANGELOG.md: Updated with v0.5.0 changesdocs/README.md: Documentation indexPerformance Improvements
Testing
Breaking Changes
None - all changes are backward compatible.
Related Issues
Closes #XXXX (if applicable)