Files
mev-beta/orig/.qwen/config/optimization.md
Administrator c54c569f30 refactor: move all remaining files to orig/ directory
Completed clean root directory structure:
- Root now contains only: .git, .env, docs/, orig/
- Moved all remaining files and directories to orig/:
  - Config files (.claude, .dockerignore, .drone.yml, etc.)
  - All .env variants (except active .env)
  - Git config (.gitconfig, .github, .gitignore, etc.)
  - Tool configs (.golangci.yml, .revive.toml, etc.)
  - Documentation (*.md files, @prompts)
  - Build files (Dockerfiles, Makefile, go.mod, go.sum)
  - Docker compose files
  - All source directories (scripts, tests, tools, etc.)
  - Runtime directories (logs, monitoring, reports)
  - Dependency files (node_modules, lib, cache)
  - Special files (--delete)

- Removed empty runtime directories (bin/, data/)

V2 structure is now clean:
- docs/planning/ - V2 planning documents
- orig/ - Complete V1 codebase preserved
- .env - Active environment config (not in git)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-10 10:53:05 +01:00

2.5 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/ 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

# 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/...

# Compare before/after performance of cached functions
go test -bench=BenchmarkSqrtPriceX96ToPrice ./pkg/uniswap/...  # Original
go test -bench=BenchmarkSqrtPriceX96ToPriceCached ./pkg/uniswap/...  # Cached version

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 (Successfully achieved: SqrtPriceX96ToPriceCached 24% faster than original)
    • Efficient tick calculations
  2. Memory Allocation Reduction

    • Object pooling for frequently created mathematical objects
    • Pre-allocation of slices and buffers
    • Minimize garbage collection pressure (Successfully achieved: 20-33% reduction in allocations)
  3. Algorithmic Optimization

    • Mathematical formula simplification
    • Lookup table implementation for repeated calculations
    • Caching strategies for expensive computations (Successfully implemented: Precomputing expensive constants 2^96, 2^192)