Skip to content

CC-Odin/HerculiPaper

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HerculiPaper

HerculiPaper is a high-performance Minecraft server implementation designed to support 1000+ players while maintaining 20 TPS and preserving vanilla-like gameplay. Built on top of Purpur 1.21.8, it brings ShreddedPaper-style regionization, advanced threading optimizations, and targeted performance improvements.

🚀 Performance Highlights

  • 🏗️ Regionized Threading: Advanced region-based task scheduling for true parallelism
  • ⚡ Optimized Hot Paths: Thread-safe entity tracking, collision detection, and packet broadcasting
  • 🔄 Async Operations: Non-blocking chunk I/O, player saves, and portal teleportation
  • 📊 Smart Caching: WeakSeqLock-based entity snapshots and packet caching
  • 🎯 Allocation Reduction: Thread-local pools and optimized data structures
  • 📈 Real-time Monitoring: Built-in performance profiling and diagnostics

🎮 Designed for Large Servers

Target: 1000+ concurrent players at stable 20 TPS
Approach: Performance-first with vanilla gameplay preservation
Philosophy: Enable through configuration, disable for compatibility

📋 Key Features

Threading & Concurrency

  • Region Scheduler: Parallel processing of world regions
  • Thread-Safe Collections: Concurrent entity maps, player tracking, and scoreboards
  • Async Chunk Pipeline: Non-blocking chunk loading and generation
  • Safe Event Dispatch: Bukkit events properly synchronized to main thread
  • PerThreadNeighborUpdater: Thread-local wrapper for NeighborUpdater to avoid cross-thread races during redstone/shape updates

Network Optimizations

  • Threaded Broadcasting: Parallel packet sending with recipient queues
  • Packet Caching: Reuse common packets across players
  • Lazy Network Writes: Batch and merge network operations
  • Ping Deferral: Reduce network overhead during high load
  • Fast Viewer Membership Map: O(1) membership checks to cut CHM churn in tracking

Entity Performance

  • WeakSeqLock Integration: Lock-free entity tracking snapshots
  • Collision Pooling: Thread-local allocation pools for collision detection
  • Tracking Caps: Configurable limits to prevent performance degradation
  • Optimized Pathfinding: Async pathfinding recalculation
  • NaturalSpawner Hot Path Optimizations: Early exits and reduced per-attempt work
    • Hoisted per-group NearbyPlayers lookup and reused player array
    • Per-invocation mobsAt() cache keyed by (ChunkPos, category)
    • Capped initial random attempts by remaining capacity and attempt cap
    • Early-return when maxSpawns <= 0 and break when no players in view-distance
  • AI Nearest-Player Fast Path: EntityGetter.getNearestPlayer(...) and related queries backed by regionized NearbyPlayers where safe
  • AI Tick Throttling: Config-gated goal selector throttling for far entities (tick every 4th tick beyond threshold)
  • Tracker Optimization Suite:
    • Replaced ConcurrentHashMap vanish cache with fastutil Object2LongOpenHashMap
    • Batched viewer array rebuilds (immediate on ≥8 changes, deferred otherwise)
    • Eliminated redundant map lookups in tracking hot path
    • Skip tracking updates for stationary entities (moved <1.0 blocks)
    • Skip tracking every other tick for far entities (>64 blocks from players)
  • AI Query Caching: 4-tick cache for nearest player lookups to reduce pathfinding overhead
    • Used by TemptGoal and other AI goals that query for nearby players
  • Player Block Check Optimization: Skip expensive block intersection checks for stationary players (moved <0.1 blocks)
  • Async Join Protocol Changes: Eliminate main thread blocking during player joins (4ms/join → ~0ms)

Monitoring & Diagnostics

  • Built-in Profiler: JFR integration and custom metrics
  • Real-time Commands: /herculi command suite for live monitoring
  • Visual Chunk Maps: /herculi mpmap for region visualization
  • Performance Probes: Detailed metrics for all optimizations

🛠️ Quick Start

Building

Initial setup:

./gradlew applyAllPatches

Build server jar:

./gradlew createMojmapBundlerJar

Jars are produced under purpur-server/build/libs.

Installation

  1. Download or build the HerculiPaper jar
  2. Replace your existing server jar
  3. Start the server - config/herculi.yml will be created automatically
  4. Configuration is pre-optimized for 1000+ players - no changes needed!
  5. Use /herculi commands to monitor performance

⚙️ Configuration

Pre-Optimized Setup

HerculiPaper comes pre-configured for 1000+ players. The default config/herculi.yml enables all performance optimizations while maintaining vanilla compatibility.

Key Configuration Sections

🧵 Threading & Regionization

threading.enabled: true                    # Enable regionized threading
threading.region_pool_size: 0              # Auto-detect CPU cores
threading.region_shift: 4                  # 16x16 chunk regions

📡 Network Optimizations

networking.parallel_flush_enabled: true          # Parallel network flushing
broadcasting.threaded.enabled: true              # Threaded packet broadcasting
broadcasting.threaded.maxQueuesTotal: 50000      # Support 1000+ players
broadcasting.threaded.perTickDrainBudget: 4      # Drain batches per tick
broadcasting.threaded.dropPolicy: coalesce       # Drop/coalesce policy
broadcasting.threaded.drainIntervalMs: 2         # Drain cadence (ms)

🎯 Performance Features

fairness.enabled: true                             # Resource fairness system
portals.routing_enabled: true                      # Async portal teleports
async.player_save.enabled: true                    # Non-blocking player saves
async.player_save.pool_size: 2                     # Worker threads
threading.chunk_io_enable: true                    # Async chunk I/O pipeline
threading.chunk_io_max_inflight: 32                # Max parallel I/O

# Entity tracking & AI optimizations
entities.tracker.coalesce.enabled: true            # Coalesce packets for far viewers
entities.tracker.coalesce.farDistance: 96          # Distance threshold (blocks)
entities.tracker.coalesce.interval: 3              # Send to far viewers every N ticks
entities.ai.throttle.enabled: true                 # Throttle AI for far entities
entities.ai.throttle.distanceSq: 4096              # Distance² threshold (64²)

🔍 Monitoring

profiling.enabled: true                            # Built-in performance monitoring
guardrails.enabled: true                           # Safety checks and warnings

Configuration Philosophy

  • Performance First: All optimizations enabled by default
  • Vanilla Preservation: Gameplay mechanics unchanged
  • Safety Nets: Guardrails prevent threading issues
  • Monitoring Ready: Diagnostics enabled for production use

📚 Documentation & Commands

Command Reference

/herculi - Main Command Suite

/herculi profile start [jfr]    # Start performance profiling
/herculi profile stop           # Stop profiling and save results
/herculi locks                  # Show region lock statistics  
/herculi queues                 # Display executor queue status
/herculi probe [reset]          # Detailed performance metrics
/herculi mpmap [player]         # Visual chunk/region map
/herculi reload                 # Reload configuration

Performance Monitoring

  • Real-time TPS: Use /tps for server performance
  • Memory Usage: Use /memory for heap statistics
  • Region Status: Use /herculi locks for threading info
  • Network Load: Use /herculi probe for packet metrics

Configuration Files

  • config/herculi.yml - Main performance configuration
  • config/paper-global.yml - Paper settings (inherited)
  • config/purpur.yml - Purpur features (inherited)

Documentation Files

  • HERCULI.md - Detailed feature documentation
  • todo-tasks.txt - Development progress tracking
  • docs/ - Additional technical documentation

🏆 Performance Targets

Metric Target Achieved Through
Players 1000+ concurrent Regionized threading + optimized broadcasting
TPS Stable 20 TPS Async operations + allocation reduction
MSPT <50ms average Parallel processing + smart caching
Memory Reduced allocation Thread-local pools + object reuse
Network High throughput Packet batching + lazy writes

🔧 Advanced Features

WeakSeqLock Integration

  • Lock-free snapshots for entity tracking
  • Reduced contention in high-concurrency scenarios
  • Stable iteration over volatile collections

Fairness System

  • Resource budgets prevent any single operation from monopolizing CPU
  • Balanced processing across regions and players
  • Configurable limits for different workload types

Async Pipeline

  • Non-blocking chunk I/O with configurable parallelism
  • Async player saves with batching
  • Portal teleportation without main thread blocking

🚨 Production Readiness

Thread Safety: All optimizations include proper synchronization
Bukkit Compatibility: Events fire on correct threads
Plugin Support: Full compatibility with existing plugins
Monitoring: Built-in diagnostics and performance tracking
Graceful Degradation: Features can be disabled if needed

📊 Monitoring Your Server

Essential Commands

# Check overall performance
/herculi probe

# Monitor region threading
/herculi locks

# View network performance  
/herculi queues

# Visual chunk status
/herculi mpmap

Key Metrics to Watch

  • Region task balance - Should be evenly distributed
  • Broadcast queue depth - Should stay low under normal load
  • Cache hit rates - Higher is better for network performance
  • Async operation counts - Indicates offloaded work

🔗 Upstream & License

HerculiPaper builds on Purpur and Paper. All upstream licenses apply to original material.

Performance patches are licensed under MIT. Upstream code retains original licensing.


🎯 Why HerculiPaper?

Traditional servers struggle with 200+ players due to single-threaded limitations.
HerculiPaper breaks these barriers through:

  • Parallel Processing: Multiple CPU cores working simultaneously
  • Smart Optimization: Target bottlenecks with surgical precision
  • Vanilla Preservation: No gameplay changes, just pure performance
  • Production Ready: Built for real-world high-load scenarios

Result: Servers that scale linearly with hardware instead of hitting artificial limits.


Below is the upstream Purpur README kept for reference.

Purpur

Purpur

MIT License Build Status CodeFactor Grade Join us on Discord

Stargazers Forks Watchers

Purpur is a drop-in replacement for Paper servers designed for configurability, new fun and exciting gameplay features, and performance built on top of Paper.

Contact

Join us on Discord:

Join us on Discord

Downloads

Downloads can be obtained from the downloads page or the downloads API.

Build Status

Downloads API endpoints:

  • List versions of Minecraft with builds available: https://api.purpurmc.org/v2/purpur
  • List builds for a version of Minecraft: https://api.purpurmc.org/v2/purpur/<version>
  • Download a specific build of a specific version: https://api.purpurmc.org/v2/purpur/<version>/<build>/download
  • Download the latest build for a version of Minecraft: https://api.purpurmc.org/v2/purpur/<version>/latest/download

License

All patches are licensed under the MIT license, unless otherwise noted in the patch headers.

MIT License

See PaperMC/Paper, and PaperMC/Paperweight for the license of material used by this project.

bStats

bStats Graph Data

API

Dependency Information

Maven

<repository>
    <id>purpur</id>
    <url>https://repo.purpurmc.org/snapshots</url>
</repository>
<dependency>
    <groupId>org.purpurmc.purpur</groupId>
    <artifactId>purpur-api</artifactId>
    <version>1.21.8-R0.1-SNAPSHOT</version>
    <scope>provided</scope>
</dependency>

Gradle

repositories {
    maven("https://repo.purpurmc.org/snapshots")
}
dependencies {
    compileOnly("org.purpurmc.purpur:purpur-api:1.21.8-R0.1-SNAPSHOT")
}

Yes, this also includes all API provided by Paper, Spigot, and Bukkit.

Building and setting up

Initial setup

First, clone this repository. Do not download it.

Then run the following command in the root directory:

./gradlew applyAllPatches

The project is now ready for use in your IDE.

Creating a patch

See CONTRIBUTING.md.

Compiling

Use the command ./gradlew build to build the API and server. Compiled JARs will be placed under purpur-api/build/libs and purpur-server/build/libs. These JARs are not used to start a server.

To compile a server-ready purpurclip jar, run ./gradlew createMojmapBundlerJar. To install the purpur-api and purpur dependencies to your local Maven repo, run ./gradlew publishToMavenLocal. The compiled purpurclip jar will be in purpur-server/build/libs.

Special Thanks To:

YourKit

YourKit-Logo

YourKit, makers of the outstanding Java profiler, support open source projects of all kinds with their full-featured Java and .NET application profilers. We thank them for allowing us to use their software so we can make Purpur the best it can be.

JetBrains

JetBrains Logo

JetBrains, creators of the IntelliJ IDEA, supports Purpur with one of their Open Source Licenses. IntelliJ IDEA is the recommended IDE for working with Purpur, and most of the Purpur team uses it.

Our Contributors

Contributors

Our Sponsors

GitHub Sponsors

Our Backers

Sponsors

About

Purpurfork for updating ShreddedPaper

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 99.1%
  • Shell 0.9%