Skip to content

About

Extremely fast chunk generation for minecraft.

Resources

Stars

0 stars

Watchers

0 watching

Forks

 
 

Latest commit

 

History

74 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SuperChunk

Extremely fast chunk generation for Minecraft. A server-side worldgen performance mod for NeoForge 1.21.1. It merges C2ME, ScalableLux, Lithium, Noisium, and VMP into a single jar, adds its own exact worldgen optimizations (written up in analysis/), and offloads terrain generation to the GPU via OpenCL.

11× vanilla

Chunky pregen, radius 2048 (66,049 chunks), fresh worlds, RTX 3070 + i7-14700K, quiet box. Four configurations, each at its own best settings, run interleaved over two rounds (2026-08-08):

Configuration chunks/sec Wall time vs vanilla
Vanilla NeoForge 1.21.1 114.9 9 m 35 s 1.0×
The same upstream mods, separately 626.0 1 m 45 s 5.4×
SuperChunk, CPU only 836.1 1 m 19 s 7.3×
SuperChunk + GPU offload 1,258.2 52 s 11.0×

Reproducibility across the two rounds: vanilla 114.1/115.7, upstream 623.1/629.0, CPU-only 836.1/836.1, GPU 1246.2/1270.2. Measuring the steady state instead of the whole wall (excluding Chunky's ramp-up and tail) gives 120 / 644 / 852 / 1,341 cps.

Every configuration got the same 16 GB heap, the same Generational ZGC, 22 C2ME workers where applicable, and the same raised Chunky in-flight chunk limit — so this compares the mods, not who remembered the flags. The upstream row is C2ME 0.4.0-alpha.0.115 + Lithium 0.15.4 + ScalableLux 0.3.0-alpha.0.6 + Noisium 2.3.0, each with its own default config; VMP is not in it because it has no NeoForge build, and its SuperChunk port is player-watching work that does nothing in a pregen with no players.

So: merging the upstream mods and tuning them is worth +34% over running them separately, and the GPU offload is worth a further +50% on top of that.

No faults, crashes, or OOMs in any run. Generation is checked against vanilla over hundreds of millions of blocks. The default fp32 compact-ID mode can produce rare block differences; see Parity below.

Round 10 (2026-08-07) adds +12.6% on top of that, measured head-to-head at radius 3072 (148,225 chunks) with each build at its own best settings — 1,090 → 1,228 chunks/sec steady-state, two interleaved pairs, the new build winning both. It comes from four changes that are individually provable rather than tuned:

  • fewer fp64 operations in the OpenCL noise chain, by exact IEEE identities (bit-identical output, verified by hash in fp32 and fp64, and by the boot parity gate on every build);
  • raising Chunky's in-flight chunk limit, which is worth nothing on its own and only pays because the kernel got faster (see the note under Install);
  • a memo of the per-block biome lookup that was 10.5% of all worldgen CPU, verified against the code it replaces over 359 million lookups with zero mismatches;
  • the same wrap identity applied to the CPU noise path.

Install

  1. Install NeoForge 1.21.1 (Java 21), client or dedicated server.

  2. Drop superchunk-<version>.jar into mods/. That one jar works on both sides — it bundles the OpenCL bindings it needs and leaves a client's own LWJGL alone. The OpenCL driver comes from your GPU vendor's normal driver.

  3. GPU offload is off by default. Turn it on with gpu.enabled=true in config/superchunk.properties; it needs an OpenCL GPU with double-precision (fp64) support, and falls back to the CPU path cleanly when none is usable.

  4. Optional tuning — worker count and heap are the only machine-specific knobs. Worldgen threads are c2me.globalExecutorParallelism in config/superchunk.properties (C2ME sizes them automatically by default); heap is the usual JVM flag, e.g. -Xmx16G.

    Pregenerating with Chunky? You no longer need -Dchunky.maxWorkingCount. Chunky caps in-flight chunks with a semaphore whose size defaults to 50 — sized for vanilla's synchronous chunk pipeline, so it hard-caps throughput at 50 / per-chunk latency no matter how fast generation is. SuperChunk now sets it from pregen.chunkyWorkingCount (default auto = 192 per GB of heap, clamped 256–3072). An explicit -D still wins; default opts out. It is worth nothing on its own and everything in combination: raising it alone is −0.5%, the round-10 kernel work alone is −1.4% (a faster kernel drains the GPU batcher and shrinks its batches), and together they are +6.3%.

  5. SuperChunk is quiet by default: it logs only warnings and errors. Set logging.verbose=true in config/superchunk.properties to also see its startup summaries and any diagnostics you enable — do that before capturing a log for a bug report.

Do not also install standalone C2ME, ScalableLux, Noisium, or VMP — they're inside this jar. Standalone Lithium is fine: if one is present, SuperChunk's bundled copy stands down and the installed one takes over.

Skein: With the updated Skein cell bridge, SuperChunk supports parallel dimensions, entities, random blocks, block entities, and opted-in scheduled ticks. It automatically disables the conflicting shared Lithium caches before mixins load, for either bundled or standalone Lithium. Skein checks Lithium's actual startup configuration. Older Skein builds retain dimension-only support. SuperChunk keeps ownership of serialization, so Skein's parallel-saving phase stays off. Reloads preserve these rules. Command blocks and command minecarts wait for cell and dimension barriers within the same server tick, preserving selectors and conditional command chains. See compatibility.txt for the tested versions and limitations.

What's inside

  • C2ME — multithreaded chunk generation, IO, and loading
  • ScalableLux — Starlight lighting engine, parallel light updates; new chunks light about 20% faster here, skipping work whose result is already known (analysis/lighting-2026-10-23.md)
  • Lithium — general game-logic optimizations
  • Noisium — worldgen noise, biomes, direct palette placement
  • VMP — area-based player watching and chunk sending
  • FlowSched — the async scheduler C2ME and ScalableLux build on
  • dev.superchunk.gpu — original OpenCL worldgen offload
  • dev.superchunk.worldgen — CPU worldgen shortcuts that keep vanilla's output; ore placement is about a third cheaper and surface building takes less than half its old time, with the same blocks (analysis/ores-2026-10-24.md, analysis/surface-2026-10-24.md)
  • dev.superchunk.chunkio — chunk saves and loads read and write section palettes directly instead of through DataFixerUpper, with the same bytes (analysis/chunk-save-encode-2026-10-30.md)

How the GPU path works

Worker threads hand chunks off at the noise-status seam and are immediately freed. A drainer thread batches those requests and dispatches fused multi-chunk kernels — all ~104 density functions are compiled to OpenCL by a custom AST emitter — then a completer thread slices the results per chunk. A decide kernel chained after them picks every block of the batch (terrain, aquifer water and lava, ore veins) and reads back one byte per block, which the chunk is written from directly ("compact IDs", on by default with the GPU). The corner kernel computes the terrain's 2D shape (continentalness, erosion, ridges and the offset/factor/jaggedness splines) once per corner column in a small pre-pass instead of at every corner, and sloped_cheese once per corner. That cut the corner kernel, most of the GPU's time, by 83–89%, with the same output bit for bit (analysis/gpu-corner-hoist-2026-10-21.md). The decide kernel also adds the terrain adaptation around structures (the Beardifier) from lookup tables the CPU fills with its own functions, so chunks with villages and other structures no longer fall back to the CPU's per-block loop (analysis/gpu-beard-2026-10-22.md). Kernels launch one warp per work-group, so the small batches a server usually sends spread over the whole GPU instead of a few of its cores (analysis/gpu-small-batches-2026-10-22.md). Compiled program binaries are cached to disk, so the one-time JIT only recurs when your driver changes (warm boot is ~11–13 s; a cold cache takes several minutes). On NVIDIA, where most of a build is ptxas, SuperChunk compiles at ptxas level 1 (-cl-nv-opt-level=1): a cold boot on an RTX 3070 takes ~5 min instead of ~7.5, with the same output and throughput (-Dsuperchunk.gpu.nvOptLevel). What shipped, the measurements, and what is next: GPU-AHEAD-PLAN.md.

Main files live in src/main/java/dev/superchunk/gpu/dfc/.

Distant Horizons

DH's distant generation is wired into the same GPU batcher the server uses. In DH's INTERNAL_SERVER mode its chunk requests already ran through SuperChunk's chunk system, and SuperChunk now also registers itself as DH's C2ME accessor so DH stops reporting "C2ME missing, slow world gen expected". In DH's own batch generator (SURFACE/FEATURES, the dedicated-server default) each generation group is prefetched through the cross-chunk batcher, which also gets those chunks the GPU-computed block ids they previously could not reach.

SuperChunk also speeds up DH's own code:

  • its world-gen region's lock on every block read;
  • its id-map rebuild for each merged chunk;
  • building a chunk's LOD and heightmaps, which read every block, biome and light value one by one (now once per palette id, biome cell and data point);
  • the occlusion culler's opacity lookups;
  • its byte-at-a-time reads of stored sections;
  • its rough surface generator, which makes every LOD below full detail in play: it found each column's surface with about 30 evaluations of the terrain's density, and now computes the height-independent part of the terrain (continentalness, erosion, ridges, the terrain splines) once per column, about 85% less time per column with the same surface.

The climate lookups DH makes for chunks that have no biomes yet reuse their per-column values, depth included. Each patch of DH's code applies only to the DH code it was checked against (DH 3.3.3, matched by a hash of the methods it relies on), so a DH update turns a patch off instead of breaking DH.

Measured on DH 3.3.3 (/dh pregen, 36,864 chunks, DH's default 14 threads, RTX 3070, 2026-10-30, busy box):

DH configuration chunks/sec CPU per chunk
DH alone, no SuperChunk 292 46.4 ms
+ SuperChunk, CPU only 717 21.5 ms
+ SuperChunk, GPU 925 16.6 ms

/dh pregen makes full-detail LODs only. In play, DH makes most of the view from its rough surface generator: per column searched, 383-455 µs of DH's density evaluations became 59-64 µs (DH's own search on 32,768 overworld columns, the same surface height in every one). Before the DH patches the pregen runs above were 599 (CPU) and 697 (GPU) chunks/sec. The LODs are identical to what DH builds alone (compared section by section in DH's repeatable terrain-only mode, and chunk by chunk against DH's own LOD builder in a verify mode). That comparison also found two places where SuperChunk's terrain differed from vanilla, both fixed: aquifer water at cave edges (all worlds) and a stale biome memo in DH's region.

Kill switches: -Dsuperchunk.compat.distantHorizons=false (all of it), -Dsuperchunk.dh.fastPaths=false (only the patches of DH's code). Details and counters in compatibility.txt.

Parity

The corner and interpolation math runs in fp64 and is bit-exact to vanilla, with every density function gated at registration. The compact-ids decide chain (on by default) lets the GPU pick block identity; it was shipped only after a flip census showed zero divergence across 455.9M blocks. Strict mode is one flag away: -Dsuperchunk.gpu.compactIds=off.

An additional seed tested on 2026-09-21 found one stone/air difference in 143,200,256 compared blocks with fp32 decisions, reproduced at the same coordinate in both the original and optimized jars. The original zero-flip census therefore does not establish universal equivalence. See analysis/optimization-2026-09-21.md for the optimization results and precision checks.

The CPU noise fill has a whole-pregen check besides the lockstep verify flags: with -Dsuperchunk.debug.noiseFillHash=<file> every chunk's fill is hashed, and since a chunk's fill depends only on its position and seed, two runs must agree chunk for chunk (tools/noisehashdiff.py). Its first run found that SuperChunk's older cross-chunk aquifer cache let the first chunk to compute an aquifer cell decide it for its neighbours where vanilla computes it per chunk (5–7 chunks per 4,882 differed); fixed 2026-09-25, see analysis/worldgen-big-2026-09-25.md. -Dsuperchunk.debug.surfaceHash=<file> does the same after the surface pass.

One deliberate difference from vanilla: when a datapack or mod feature reads a chunk farther away than world generation allows, vanilla fails the whole chunk (and the chunks around it can then never load); SuperChunk skips that feature in that chunk and logs it once. Chunks vanilla can generate are unaffected. -Dsuperchunk.worldgen.skipOutOfRegionFeatures=false restores vanilla's behaviour. See compatibility.txt (DATAPACKS).

Building

./gradlew build          # shippable jar: build/libs/superchunk-<version>.jar
./gradlew deployBundle   # copies it to build/deploy/

Install the plain jar, not the -core one — that rides inside it.

Docs

  • GPU-AHEAD-PLAN.md — the GPU path: what shipped, measurements, parity envelope, next steps
  • compatibility.txt — tested mods and datapacks, fixes, and incompatibilities
  • MERGE_NOTES.md — how the five upstream mods were merged
  • analysis/ — per-engine merge analyses
  • analysis/optimization-2026-09-21.md — CPU/GPU consumer optimizations, regression checks, and fresh-world benchmarks
  • analysis/optimization-round2-2026-09-21.md — further biome, aquifer, surface, serialization, and GPU allocation improvements
  • analysis/publication-review-2026-09-22.md — independent review, Skein compatibility, and publication checks
  • analysis/optimization-2026-09-24.md — exact biome-lookup (climate R-tree, zoom jitter) and allocation optimizations, with live parity and compatibility checks
  • analysis/review-2026-09-25.md — code and performance review: chunk-save, hang and compatibility fixes, quiet logging, remaining backlog
  • analysis/jjthunder-freeze-2026-09-25.md — diagnosis of a world freeze with the JJThunder To The Max datapack, and the 2026-09-26 follow-up (features reading too far are skipped instead of failing the chunk)
  • analysis/worldgen-big-2026-09-25.md — noise-fill CPU pass (lerp tables, bulk multiply, air-cell skip), the pregen hash check, and the aquifer cell cache exactness fix
  • analysis/cpu-per-chunk-2026-10-11.md — CPU cost per chunk: cell sign skip, shared corner columns and surface levels, region center chunk, lean surface writes, allocation; the surface hash check
  • analysis/chunk-save-encode-2026-10-30.md — chunk saves encode each section's block and biome palettes without DataFixerUpper's codecs: the same bytes, about 40% less time per container
  • dist/README.md — end-user install notes

License

LGPL-3.0-only for the combined work (see LICENSE); MIT components retain their notices in NOTICE. Credits: C2ME, FlowSched, and VMP (ishland), Lithium (CaffeineMC), ScalableLux (RelativityMC), Noisium (Steveplays28).

About

Extremely fast chunk generation for minecraft.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages