π Performance Highlights
β‘ Ultra-Low Latency
- 10-20ΞΌs parsing latency in release mode
- Zero-copy parsing with stack-allocated buffers
- SIMD-accelerated pattern matching (memchr)
- Lock-free ArrayQueue for event delivery
π Optimization Highlights
- β Zero heap allocation for hot paths
- β SIMD pattern matching for all protocol detection
- β Static pre-compiled finders for string search
- β Inline functions with aggressive optimization
- β Event type filtering for targeted parsing
- β Conditional Create detection (only when needed)
π₯ Quick Start
Installation
cd your_project_dir
git clone https://github.com/0xfnzero/sol-parser-sdk
Performance Testing
Test parsing latency with the optimized example:
# Run performance test (requires sudo for high-precision timing)
# Expected output:
# gRPCζ₯ζΆζΆι΄: 1234567890 ΞΌs
# δΊδ»Άζ₯ζΆζΆι΄: 1234567900 ΞΌs
# δΊδ»Άθ§£ζθζΆ: 10 ΞΌs <-- Ultra-low latency!
Why sudo? The example uses libc::clock_gettime(CLOCK_REALTIME)
for microsecond-precision timing, which may require elevated permissions on some systems.
Basic Usage
use ;
async
ποΈ Supported Protocols
DEX Protocols
- β PumpFun - Meme coin trading (ultra-fast zero-copy path)
- β PumpSwap - PumpFun swap protocol
- β Raydium AMM V4 - Automated Market Maker
- β Raydium CLMM - Concentrated Liquidity
- β Raydium CPMM - Concentrated Pool
- β Orca Whirlpool - Concentrated liquidity AMM
- β Meteora AMM - Dynamic AMM
- β Meteora DAMM - Dynamic AMM V2
- β Meteora DLMM - Dynamic Liquidity Market Maker
- β Bonk Launchpad - Token launch platform
Event Types
Each protocol supports:
- π Trade/Swap Events - Buy/sell transactions
- π§ Liquidity Events - Deposits/withdrawals
- π Pool Events - Pool creation/initialization
- π― Position Events - Open/close positions (CLMM)
β‘ Performance Features
Zero-Copy Parsing
// Stack-allocated 512-byte buffer for PumpFun Trade
const MAX_DECODE_SIZE: usize = 512;
let mut decode_buf: = ;
// Decode directly to stack, no heap allocation
STANDARD
.decode_slice
.ok?;
SIMD Pattern Matching
// Pre-compiled SIMD finders (initialized once)
static PUMPFUN_FINDER: =
new;
// 3-10x faster than .contains()
if PUMPFUN_FINDER.find.is_some
Event Type Filtering
// Ultra-fast path for single event type
if include_only.len == 1 && include_only == PumpFunTrade
Lock-Free Queue
// ArrayQueue with 100,000 capacity
let queue = new;
// Non-blocking push/pop (no mutex overhead)
let _ = queue.push;
if let Some = queue.pop
π― Event Filtering
Reduce processing overhead by filtering specific events:
Example: Trading Bot
let event_filter = include_only;
Example: Pool Monitor
let event_filter = include_only;
Performance Impact:
- 60-80% reduction in processing
- Lower memory usage
- Reduced network bandwidth
π§ Advanced Features
Create+Buy Detection
Automatically detects when a token is created and immediately bought in the same transaction:
// Detects "Program data: GB7IKAUcB3c..." pattern
let has_create = detect_pumpfun_create;
// Sets is_created_buy flag on Trade events
if has_create
Dynamic Subscription
Update filters without reconnecting:
grpc.update_subscription.await?;
Performance Metrics
let mut config = default;
config.enable_metrics = true;
let grpc = new_with_config?;
π Project Structure
src/
βββ core/
β βββ events.rs # Event definitions
βββ grpc/
β βββ client.rs # Yellowstone gRPC client
β βββ types.rs # Filter & config types
βββ logs/
β βββ optimized_matcher.rs # SIMD log detection
β βββ zero_copy_parser.rs # Zero-copy parsing
β βββ pumpfun.rs # PumpFun parser
β βββ raydium_*.rs # Raydium parsers
β βββ orca_*.rs # Orca parsers
β βββ meteora_*.rs # Meteora parsers
βββ instr/
β βββ *.rs # Instruction parsers
βββ lib.rs
π Optimization Techniques
1. SIMD String Matching
- Replaced all
.contains()
withmemmem::Finder
- 3-10x performance improvement
- Pre-compiled static finders
2. Zero-Copy Parsing
- Stack-allocated buffers (512 bytes)
- No heap allocation in hot path
- Inline helper functions
3. Event Type Filtering
- Early filtering at protocol level
- Conditional Create detection
- Single-type ultra-fast path
4. Lock-Free Queue
- ArrayQueue (100K capacity)
- Spin-wait hybrid strategy
- No mutex overhead
5. Aggressive Inlining
π Benchmarks
Parsing Latency (Release Mode)
Protocol | Avg Latency | Min | Max |
---|---|---|---|
PumpFun Trade (zero-copy) | 10-15ΞΌs | 8ΞΌs | 20ΞΌs |
Raydium AMM V4 Swap | 15-20ΞΌs | 12ΞΌs | 25ΞΌs |
Orca Whirlpool Swap | 15-20ΞΌs | 12ΞΌs | 25ΞΌs |
SIMD Pattern Matching
Operation | Before (contains) | After (SIMD) | Speedup |
---|---|---|---|
Protocol detection | 50-100ns | 10-20ns | 3-10x |
Create event detection | 150ns | 30ns | 5x |
π License
MIT License
π Contact
- Repository: https://github.com/0xfnzero/solana-streamer
- Telegram: https://t.me/fnzero_group
- Discord: https://discord.gg/vuazbGkqQE
β οΈ Performance Tips
- Use Event Filtering - Filter at the source for 60-80% performance gain
- Run in Release Mode -
cargo build --release
for full optimization - Test with sudo -
sudo cargo run --example basic --release
for accurate timing - Monitor Latency - Check
grpc_recv_us
and queue latency in production - Tune Queue Size - Adjust ArrayQueue capacity based on your throughput
- Spin-Wait Strategy - Tune spin count (default: 1000) for your use case
π¬ Development
# Run tests
# Run performance example
# Build release binary
# Generate docs