π B-FAST Performance Analysis
Overview
B-FAST (Binary Fast Adaptive Serialization Transfer) is a binary serialization protocol optimized for bandwidth-constrained environments while maintaining excellent CPU performance.
π― Performance Summary
Simple Objects (10k)
- B-FAST: 4.83ms
- orjson: 8.19ms
- JSON: 12.0ms
- π 1.7x faster than orjson!
Round-Trip Performance (Serialize + Network + Deserialize)
100 Mbps Network
- B-FAST + LZ4: 16.1ms
- orjson: 91.7ms
- JSON: 114.5ms
- π 5.7x faster than orjson!
1 Gbps Network
- B-FAST + LZ4: 7.2ms
- orjson: 15.3ms
- JSON: 29.4ms
- π 2.1x faster than orjson!
10 Gbps Network
- B-FAST + LZ4: 6.3ms
- orjson: 7.7ms
- JSON: 20.9ms
- π 1.2x faster than orjson!
π Specialized Performance
NumPy Arrays (8MB)
- B-FAST: 3.29ms
- orjson: 46.34ms
- JSON: 318.21ms
- π 14x faster than orjson!
- π 96x faster than JSON!
π― Ideal Use Cases
β B-FAST Excels When:
- Network bandwidth is limited (mobile, IoT) - 5.7x faster
- Simple objects - 1.7x faster than orjson
- NumPy arrays are involved (ML, data science) - 14-96x faster
- Storage efficiency is important - 89% compression
- Large datasets - Up to 5.7x faster on slow networks
β Consider Alternatives When:
- Ultra-fast networks (10+ Gbps internal) - marginal difference
- Ecosystem compatibility is critical - JSON is still standard
- Very small payloads (< 1KB) - compression overhead
π Performance Characteristics
Linear Scaling
B-FAST performance scales linearly with data size:
- 100 objects: ~5.6ΞΌs per object
- 1,000 objects: ~5.5ΞΌs per object
- 10,000 objects: ~4.8ΞΌs per object
Memory Efficiency
- Zero-copy NumPy arrays
- Cache-aligned memory operations
- Efficient compression with LZ4
π¬ Technical Optimizations
Rust Implementation
- Direct memory access with unsafe operations
- Efficient type detection and serialization
- Optimized Pydantic integration - reads directly from memory
Compression
- Built-in LZ4 compression
- Fast decompression for client-side
- No external dependencies required
π Network Analysis
B-FAST's advantage increases as network speed decreases:
| Network Speed | B-FAST Advantage |
|---|---|
| 100 Mbps | 5.7x faster than orjson |
| 1 Gbps | 2.1x faster than orjson |
| 10 Gbps | 1.2x faster than orjson |
π Benchmark Methodology
Test Environment
- Data: 10,000 complex Pydantic objects
- Iterations: Multiple runs with warmup
- Network: Simulated transfer times
Test Data Structure
class User(BaseModel):
id: int
name: str
email: str
active: bool
scores: list[float]
Measurement Approach
- Pure serialization: CPU time only
- Round-trip: Serialize + network transfer + deserialize
- Network simulation: Realistic bandwidth calculations
- Statistical analysis: Average of multiple runs
π― Conclusion
B-FAST achieves its design goal of being the optimal choice for bandwidth-constrained environments while maintaining competitive CPU performance. The 89% payload reduction combined with 1.7x serialization speedup makes it ideal for mobile, IoT, and data-intensive applications.
π Next Steps
- Troubleshooting - Troubleshooting guide
- Frontend - TypeScript integration
- Home - Back to home