2.1 KiB
2.1 KiB
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/orpkg/math/ - Test files: Place alongside source files with
_test.gosuffix - Documentation: Inline comments explaining mathematical formulas
- Precision libraries: Use
github.com/holiman/uint256for uint256 arithmetic
Performance Monitoring
# 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/uint256for all uint256 calculations - Floating Point: Use
math/bigfor floating-point calculations when needed - Rounding: Implement proper rounding strategies for financial calculations
- Overflow Handling: Handle overflow and underflow conditions properly
Optimization Focus Areas
-
Mathematical Computation Efficiency
- Minimize computational overhead in pricing functions
- Optimize sqrtPriceX96 to price conversions
- Efficient tick calculations
-
Memory Allocation Reduction
- Object pooling for frequently created mathematical objects
- Pre-allocation of slices and buffers
- Minimize garbage collection pressure
-
Algorithmic Optimization
- Mathematical formula simplification
- Lookup table implementation for repeated calculations
- Caching strategies for expensive computations