Overview
Pumpkin is built in Rust with a focus on high performance, leveraging multi-threading, async I/O, and optimized data structures. This guide covers optimization strategies for production deployments.Rust Compiler Optimizations
Release Profile
Pumpkin’sCargo.toml is already configured with aggressive optimizations:
Cargo.toml
- LTO: Enables cross-crate optimizations, reduces binary size, improves runtime performance
- Strip: Removes debug information, significantly reduces binary size
- Codegen Units: Single unit allows maximum optimization at cost of longer compile time
Always Build with Release Mode
Runtime Configuration
Tokio Async Runtime
Pumpkin uses Tokio as its async runtime:Worker Threads
Tokio automatically uses all available CPU cores. To limit:Rayon Parallel Processing
Pumpkin uses Rayon for CPU-intensive tasks like chunk processing:Thread Pool Size
TOKIO_WORKER_THREADS or use physical core count.
Rayon calls from Tokio runtime are non-blocking and use channels for coordination.
Memory Optimization
Heap Allocation
Rust’s efficient memory management minimizes allocations:- Uses
Arcfor shared ownership (reference counting) Bytescrate for zero-copy buffer handlingDashMapfor concurrent hash maps
Caching
Pumpkin implements LRU caching:- Chunk data
- Block states
- Entity lookups
Memory Limits
While Rust doesn’t have JVM-style heap limits, you can use system limits:Network Performance
TCP Configuration
Optimize TCP settings for Minecraft traffic:Packet Compression
Pumpkin supports packet compression (configured inconfiguration.toml):
- Higher threshold (512-1024): Less CPU usage, more bandwidth
- Lower threshold (128-256): More CPU usage, less bandwidth
- 0: Compress everything (high CPU load)
- -1: Disable compression (high bandwidth usage)
Encryption
Encryption is required for online mode. Pumpkin uses efficient AES-CFB8:Storage Performance
World Format
Pumpkin uses Minecraft’s Anvil format with async I/O:- Chunk loading is non-blocking
- Leverages
tokio::fsfor async file operations - Supports concurrent chunk reads
Storage Backend
SSD Strongly Recommended:- NVMe SSD: Best performance
- SATA SSD: Good performance
- HDD: Acceptable for small worlds, will bottleneck chunk loading
File System
Linux:- ext4: Recommended, excellent performance
- XFS: Good for large worlds
- btrfs: Supports snapshots but may have performance overhead
Chunk Loading Optimization
View Distance
Configured per-player or globally:- View distance of 10: ~1256 chunks per player
- View distance of 16: ~3216 chunks per player
- Small servers (< 10 players): 12-16 chunks
- Medium servers (10-50 players): 8-12 chunks
- Large servers (50+ players): 6-10 chunks
Chunk Caching
Pumpkin caches loaded chunks in memory using efficient data structures:Multi-threading Architecture
Async Tasks
Pumpkin extensively uses async/await:Parallel Processing
CPU-intensive operations use Rayon:Lock-free Data Structures
Minimizes contention:CPU Affinity
Linux
Pin Pumpkin to specific cores:Docker
Monitoring
Tokio Console (Development)
Pumpkin supports tokio-console for async task inspection:Backtrace Configuration
System Monitoring
Benchmarking
Criterion Benchmarks
Pumpkin includes benchmark suite:Profile for Optimization
Production Deployment Checklist
Build Configuration
- Use
cargo build --release - Verify LTO is enabled in Cargo.toml
- Strip debug symbols
- Use latest stable Rust version
System Configuration
- Use SSD/NVMe storage
- Allocate sufficient RAM (4GB minimum, 8GB+ recommended)
- Configure TCP buffer sizes
- Set appropriate file descriptor limits
Runtime Configuration
- Set
TOKIO_WORKER_THREADSto physical core count - Set
RAYON_NUM_THREADSto match worker threads - Tune compression threshold based on bandwidth
- Configure appropriate view distance
- Disable debug logging in production
Security Hardening
- Run as non-root user (Docker: UID 2613)
- Use read-only filesystem where possible
- Drop unnecessary capabilities
- Enable firewall rules
Performance Metrics
Expected Performance
Hardware: 8-core CPU, 16GB RAM, NVMe SSD- Tick Rate: Stable 20 TPS (50ms ticks)
- Player Capacity: 100+ concurrent players
- Chunk Loading: < 5ms per chunk (cached)
- Memory Usage: ~2-4GB with 50 players
Bottleneck Identification
High CPU Usage:- Reduce view distance
- Lower compression threshold
- Reduce entity count
- Lower view distance
- Reduce loaded chunks
- Check for memory leaks (report bugs)
- Upgrade to SSD
- Reduce world save frequency (if configurable)
- Use filesystem with better I/O performance
- Increase compression threshold
- Reduce view distance
- Optimize network stack settings
Docker-Specific Optimizations
Resource Limits
Storage Driver
Use overlay2 for best performance:Host Network Mode (Advanced)
For minimal network overhead:Next Steps
- Server Configuration - Configure Pumpkin settings
- Docker Deployment - Deploy with Docker
- Advanced Configuration - Set up logging and monitoring
