Files
mev-beta/.qwen/config/optimization.md
2025-09-14 10:09:55 -05:00

51 lines
2.1 KiB
Markdown

# Qwen Code Performance Optimization Settings
## Workflow Preferences
- **Always commit changes**: Use `git commit -am "math: descriptive message"` for mathematical implementations
- **Branch naming**: Use prefixes (`math-sqrt-price`, `algo-liquidity-calc`, `perf-uniswap`)
- **Context management**: Focus on mathematical precision and performance
- **Parallel processing**: Leverage Go's concurrency patterns for independent calculations
## File Organization Preferences
- **Mathematical functions**: Place in `pkg/uniswap/` or `pkg/math/`
- **Test files**: Place alongside source files with `_test.go` suffix
- **Documentation**: Inline comments explaining mathematical formulas
- **Precision libraries**: Use `github.com/holiman/uint256` for uint256 arithmetic
## Performance Monitoring
```bash
# Enable metrics endpoint for performance tracking
export METRICS_ENABLED="true"
export METRICS_PORT="9090"
# Monitor memory usage of mathematical calculations
go tool pprof http://localhost:9090/debug/pprof/heap
# Monitor CPU usage of mathematical functions
go tool pprof http://localhost:9090/debug/pprof/profile?seconds=30
# Run benchmarks for mathematical functions
go test -bench=. -benchmem ./pkg/uniswap/...
```
## Precision Requirements
- **Uint256 Arithmetic**: Use `github.com/holiman/uint256` for all uint256 calculations
- **Floating Point**: Use `math/big` for floating-point calculations when needed
- **Rounding**: Implement proper rounding strategies for financial calculations
- **Overflow Handling**: Handle overflow and underflow conditions properly
## Optimization Focus Areas
1. **Mathematical Computation Efficiency**
- Minimize computational overhead in pricing functions
- Optimize sqrtPriceX96 to price conversions
- Efficient tick calculations
2. **Memory Allocation Reduction**
- Object pooling for frequently created mathematical objects
- Pre-allocation of slices and buffers
- Minimize garbage collection pressure
3. **Algorithmic Optimization**
- Mathematical formula simplification
- Lookup table implementation for repeated calculations
- Caching strategies for expensive computations