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>
289 lines
8.7 KiB
Markdown
289 lines
8.7 KiB
Markdown
# Gemini CLI Configuration
|
|
|
|
This directory contains Gemini configuration and tools for the MEV Bot project.
|
|
|
|
## 🚀 Quick Start Commands
|
|
|
|
### Essential Build & Test Commands
|
|
```bash
|
|
# Build the MEV bot binary
|
|
make build
|
|
|
|
# Run performance tests
|
|
.gemini/scripts/perf-test.sh
|
|
|
|
# Run optimization analysis
|
|
.gemini/scripts/optimize.sh
|
|
|
|
# Run benchmarks with profiling
|
|
make bench-profile
|
|
|
|
# Run concurrency tests
|
|
make test-concurrent
|
|
|
|
# Check for Go modules issues
|
|
go mod tidy && go mod verify
|
|
|
|
# Run linter with performance focus
|
|
golangci-lint run --fast
|
|
```
|
|
|
|
### Development Workflow Commands
|
|
```bash
|
|
# Setup development environment
|
|
export ARBITRUM_RPC_ENDPOINT="wss://arbitrum-mainnet.core.chainstack.com/53c30e7a941160679fdcc396c894fc57"
|
|
export ARBITRUM_WS_ENDPOINT="wss://arbitrum-mainnet.core.chainstack.com/53c30e7a941160679fdcc396c894fc57"
|
|
export METRICS_ENABLED="true"
|
|
|
|
# Run with timeout for testing
|
|
timeout 60 ./mev-bot start
|
|
|
|
# Debug with verbose logging
|
|
LOG_LEVEL=debug ./mev-bot start
|
|
|
|
# Profile performance with detailed analysis
|
|
.gemini/scripts/profile.sh
|
|
```
|
|
|
|
## Gemini Commands Directory
|
|
|
|
The `.gemini/commands/` directory contains predefined commands for performance optimization tasks:
|
|
|
|
- `optimize-performance.md` - Optimize application performance
|
|
- `analyze-bottlenecks.md` - Analyze performance bottlenecks
|
|
- `tune-concurrency.md` - Tune concurrency patterns
|
|
- `reduce-memory.md` - Reduce memory allocations
|
|
- `improve-latency.md` - Improve latency performance
|
|
|
|
## Gemini Settings
|
|
|
|
The `.gemini/settings.json` file contains Gemini's performance optimization configuration:
|
|
|
|
```json
|
|
{
|
|
"focus_areas": [
|
|
"Algorithmic Implementations",
|
|
"Performance Optimization",
|
|
"Concurrency Patterns",
|
|
"Memory Management"
|
|
],
|
|
"primary_skills": [
|
|
"Optimizing mathematical calculations for performance",
|
|
"Profiling and identifying bottlenecks in critical paths",
|
|
"Reducing memory allocations in hot code paths",
|
|
"Optimizing concurrency patterns for maximum throughput"
|
|
],
|
|
"performance_optimization": {
|
|
"enabled": true,
|
|
"profiling": {
|
|
"cpu": true,
|
|
"memory": true,
|
|
"goroutine": true,
|
|
"mutex": true
|
|
},
|
|
"optimization_targets": [
|
|
"Reduce latency to < 10 microseconds for critical path",
|
|
"Achieve > 100,000 messages/second throughput",
|
|
"Minimize memory allocations in hot paths",
|
|
"Optimize garbage collection tuning"
|
|
]
|
|
},
|
|
"concurrency": {
|
|
"worker_pools": true,
|
|
"pipeline_patterns": true,
|
|
"fan_in_out": true,
|
|
"backpressure_handling": true
|
|
},
|
|
"benchmarking": {
|
|
"baseline_comparison": true,
|
|
"regression_detection": true,
|
|
"continuous_monitoring": true
|
|
}
|
|
}
|
|
```
|
|
|
|
## 📋 Development Guidelines & Code Style
|
|
|
|
### Performance Optimization Guidelines
|
|
- **Profiling First**: Always profile before optimizing
|
|
- **Measure Impact**: Measure performance impact of changes
|
|
- **Maintain Readability**: Don't sacrifice code readability for marginal gains
|
|
- **Focus on Hot Paths**: Optimize critical code paths first
|
|
- **Test Regressions**: Ensure optimizations don't cause regressions
|
|
|
|
### Concurrency Patterns
|
|
- **Worker Pools**: Use worker pools for parallel processing
|
|
- **Pipeline Patterns**: Implement pipeline patterns for multi-stage processing
|
|
- **Fan-in/Fan-out**: Use fan-in/fan-out patterns for data distribution
|
|
- **Backpressure Handling**: Implement proper backpressure handling
|
|
|
|
### Memory Management
|
|
- **Object Pooling**: Use sync.Pool for frequently created objects
|
|
- **Pre-allocation**: Pre-allocate slices and maps when size is known
|
|
- **Minimize Allocations**: Reduce allocations in hot paths
|
|
- **GC Tuning**: Properly tune garbage collection
|
|
|
|
### Required Checks Before Commit
|
|
```bash
|
|
# Run performance tests
|
|
.gemini/scripts/perf-test.sh
|
|
|
|
# Run benchmark comparisons
|
|
.gemini/scripts/bench-compare.sh
|
|
|
|
# Check for performance regressions
|
|
.gemini/scripts/regression-check.sh
|
|
```
|
|
|
|
## Gemini's Primary Focus Areas
|
|
|
|
As Gemini, you're particularly skilled at:
|
|
|
|
1. **Algorithmic Implementations and Mathematical Computations**
|
|
- Implementing precise Uniswap V3 pricing functions
|
|
- Optimizing mathematical calculations for performance
|
|
- Ensuring numerical stability and precision
|
|
- Creating efficient algorithms for arbitrage detection
|
|
|
|
2. **Optimizing Performance and Efficiency**
|
|
- Profiling and identifying bottlenecks in critical paths
|
|
- Reducing memory allocations in hot code paths
|
|
- Optimizing concurrency patterns for maximum throughput
|
|
- Tuning garbage collection for low-latency requirements
|
|
|
|
3. **Understanding Complex Uniswap V3 Pricing Functions**
|
|
- Implementing accurate tick and sqrtPriceX96 conversions
|
|
- Calculating price impact with proper precision handling
|
|
- Working with liquidity and fee calculations
|
|
- Handling edge cases in pricing mathematics
|
|
|
|
4. **Implementing Concurrent and Parallel Processing Patterns**
|
|
- Designing efficient worker pool implementations
|
|
- Creating robust pipeline processing systems
|
|
- Managing synchronization primitives correctly
|
|
- Preventing race conditions and deadlocks
|
|
|
|
5. **Working with Low-Level System Operations**
|
|
- Optimizing memory usage and allocation patterns
|
|
- Tuning system-level parameters for performance
|
|
- Implementing efficient data structures for high-frequency access
|
|
- Working with CPU cache optimization techniques
|
|
|
|
## 🛠 Gemini Optimization Settings
|
|
|
|
### Workflow Preferences
|
|
- **Always profile first**: Use `go tool pprof` before making changes
|
|
- **Branch naming**: Use prefixes (`perf-worker-pool`, `opt-pipeline`, `tune-gc`)
|
|
- **Context management**: Focus on performance metrics and bottlenecks
|
|
- **Continuous monitoring**: Implement monitoring for performance metrics
|
|
|
|
### File Organization Preferences
|
|
- **Performance-critical code**: Place in `pkg/market/` or `pkg/monitor/`
|
|
- **Benchmark files**: Place alongside source files with `_bench_test.go` suffix
|
|
- **Profiling scripts**: Place in `.gemini/scripts/`
|
|
- **Optimization documentation**: Inline comments explaining optimization approaches
|
|
|
|
### Performance Monitoring
|
|
```bash
|
|
# Enable detailed metrics endpoint
|
|
export METRICS_ENABLED="true"
|
|
export METRICS_PORT="9090"
|
|
|
|
# Monitor all performance aspects
|
|
go tool pprof http://localhost:9090/debug/pprof/profile?seconds=30
|
|
go tool pprof http://localhost:9090/debug/pprof/heap
|
|
go tool pprof http://localhost:9090/debug/pprof/goroutine
|
|
go tool pprof http://localhost:9090/debug/pprof/mutex
|
|
|
|
# Run comprehensive performance analysis
|
|
.gemini/scripts/profile.sh
|
|
```
|
|
|
|
## 🔧 Environment Configuration
|
|
|
|
### Required Environment Variables
|
|
```bash
|
|
# Arbitrum RPC Configuration
|
|
export ARBITRUM_RPC_ENDPOINT="wss://arbitrum-mainnet.core.chainstack.com/53c30e7a941160679fdcc396c894fc57"
|
|
export ARBITRUM_WS_ENDPOINT="wss://arbitrum-mainnet.core.chainstack.com/53c30e7a941160679fdcc396c894fc57"
|
|
|
|
# Application Configuration
|
|
export LOG_LEVEL="info"
|
|
export METRICS_ENABLED="true"
|
|
export METRICS_PORT="9090"
|
|
|
|
# Development Configuration
|
|
export GO_ENV="development"
|
|
export DEBUG="true"
|
|
|
|
# Performance Configuration
|
|
export GOGC=20
|
|
export GOMAXPROCS=0
|
|
export CONCURRENCY_LEVEL=100
|
|
```
|
|
|
|
### Profiling Environment Variables
|
|
```bash
|
|
# Profiling Configuration
|
|
export PROFILING_ENABLED=true
|
|
export PROFILING_DURATION=30s
|
|
export PROFILING_OUTPUT_DIR=".gemini/profiles"
|
|
|
|
# Benchmark Configuration
|
|
export BENCHMARK_TIMEOUT=60s
|
|
export BENCHMARK_ITERATIONS=1000000
|
|
export BENCHMARK_CONCURRENCY=10
|
|
```
|
|
|
|
## 📝 Commit Message Conventions
|
|
|
|
### Format
|
|
```
|
|
perf(type): brief description
|
|
|
|
- Detailed explanation of performance optimization
|
|
- Measured impact of the change
|
|
- Profiling data supporting the optimization
|
|
|
|
🤖 Generated with [Gemini](https://gemini.example.com)
|
|
Co-Authored-By: Gemini <noreply@gemini.example.com>
|
|
```
|
|
|
|
### Types
|
|
- `worker-pool`: Worker pool optimizations
|
|
- `pipeline`: Pipeline pattern optimizations
|
|
- `memory`: Memory allocation reductions
|
|
- `gc`: Garbage collection tuning
|
|
- `concurrency`: Concurrency pattern improvements
|
|
- `algorithm`: Algorithmic optimizations
|
|
- `latency`: Latency improvements
|
|
- `throughput`: Throughput improvements
|
|
|
|
## 🚨 Performance Guidelines
|
|
|
|
### Always Profile
|
|
- Use `go tool pprof` to identify bottlenecks
|
|
- Measure baseline performance before optimization
|
|
- Compare performance before and after changes
|
|
- Monitor for regressions in unrelated areas
|
|
|
|
### Focus Areas
|
|
- **Critical Path**: Optimize the most time-consuming operations
|
|
- **Hot Paths**: Reduce allocations in frequently called functions
|
|
- **Concurrency**: Improve parallel processing efficiency
|
|
- **Memory**: Minimize memory usage and GC pressure
|
|
|
|
### Testing Performance
|
|
```bash
|
|
# Run comprehensive performance tests
|
|
.gemini/scripts/perf-test.sh
|
|
|
|
# Compare benchmarks
|
|
.gemini/scripts/bench-compare.sh
|
|
|
|
# Check for regressions
|
|
.gemini/scripts/regression-check.sh
|
|
|
|
# Generate flame graphs
|
|
.gemini/scripts/flame-graph.sh
|
|
``` |