Skip to content
TheProKnightGamerPublic

About

Multithreaded server ticking for Minecraft: dimensions and world regions tick in parallel. Forge and NeoForge, 1.20.1 to 26.2, server-side only.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Skein logo: a creeper wrapped in stacked layers

Skein

Multithreaded server ticking for Minecraft
Version 1.2.0 · Forge and NeoForge · 1.20.1, 1.21.1, 1.21.11 and 26.2 · server-side only · all rights reserved


A Minecraft server does nearly all of its game work on one thread. Skein spreads that work out. Each dimension ticks on its own thread. Inside a dimension, random ticks, entities and block entities are cut into regions of the world that are far enough apart to tick at the same time. A barrier closes before anything downstream can see the difference, so every tick still ends exactly where vanilla ends it. Players joining a server running Skein don't need it installed.

  • Dimension threading. The Overworld, the Nether and the End tick side by side, and the server waits for all of them before connections, players and chunk sending run, which is exactly where vanilla runs those. Tick events still fire on the server thread, in their usual order.
  • Region threading inside a dimension. The level is cut into square cells, and any reach a tick can have (a mob's pathfinding, a hopper's neighbour, a sapling becoming a tree) stays inside a safety margin, so cells that run together never touch the same blocks. Four offset grids mean no position sits on an edge. Mobs that reach further than the margin, like villagers, get their own coarser passes instead of falling back to the main thread.
  • Redstone in parallel, in vanilla's exact order. Scheduled ticks (repeaters, comparators, observers, fluids, falling blocks) run in groups of what can affect each other, each in vanilla's order, and what the groups share is put back in vanilla's order too, down to the sub-tick numbers of new ticks. A fuzzer checks it tick for tick against vanilla.
  • A cluster tier for dense farms. Thousands of items, XP orbs or snowballs piled into one spot are ordered by what they can actually reach, rather than by where they are.
  • It knows when not to bother. Every phase is timed both ways, and a phase that doesn't pay for its barrier quietly runs the vanilla way. /skein status shows the verdict.
  • TNT cannons. A piston pushing a stack of tens of thousands of primed TNT used to cost the square of the stack: every TNT asked about every other one. Skein answers those queries from a short per-section list of the entities that can actually be collided with, and spreads a big push over the worker threads. The TNT still ends up exactly where vanilla puts it.

After 1.2.0 (in the source, not in a release yet)

  • Cells no longer wait for their whole pass. The entity and random-tick phases ran pass by pass, and every pass waited for its slowest cell while the rest of the pool stood idle. A cell now starts as soon as the cells around it that come before it have finished; two cells still never run together unless they are as far apart as cells of one pass. Villagers and other wide mobs get smaller cells with it. Against 1.2.0 on 1.21.1 NeoForge a crowded farm of 5,760 animals ticks 15% faster, 1,440 penned animals 11% and a two-player survival server 5%; a server whose only work is hoppers is unchanged.
  • Sable (NeoForge 1.21.1). Mobs beside a physics structure lost ticks ("refused to load chunk" in the log) and mobs elsewhere could be collided with one. Sable's plot chunks are now read through Sable, each worker has its own copy of Sable's collision scratch space, and whatever can reach a structure ticks on its level's thread (report).
  • New config keys entities.orderedCells and randomTicks.orderedCells, both on. Nothing else changes in a config.

What's new in 1.2.0

  • Mob spawning on the worker threads. The spawner's questions (the nearest player, the biome's and structures' mob lists, the placement and light checks) are asked for every chunk at once on the pool. The level thread then spawns in vanilla's order, so the mob caps hold exactly.
  • Quiet servers: the walks over every loaded chunk, the save sweep and sorting entities into cells run on the pool, and an idle worker waits for work a learned time instead of a fixed one.
  • Small and shared hosts: fewer thread wake-ups where other work competes for the cores.
  • Busy and crowded levels: the one-tick tickets chunk lookups leave go in once per purge, and a level packed into a cell or two per thread is split over nine passes of smaller cells.
  • Compatibility: C2ME; Create's redstone links no longer wait on a rotation walk's lock (a watchdog stall); mods that let items merge further than vanilla; dedicated servers whose mods put a client-only class on the classpath (pull request #1); with Async or DimThreads installed Skein switches itself off and says why.
  • New config keys spawning.enabled, spawning.minChunks and entities.fineGridMinEntities, and on 1.21.11 and 26.2 randomTicks.parallelChunkScan. Upgrading from 1.1.0 needs no config changes.

What's new in 1.1.0

  • Redstone in parallel, in vanilla's exact order, on by default and timed both ways like the other phases. Block entities can be ordered the same way (blockEntities.vanillaOrderLimit, opt-in).
  • TNT cannons: collision lookups only ask entities that can be collided with, and big piston pushes are spread over the workers. The Orbital Skybender went from 288 to 54 ms/tick.
  • Faster everywhere else: villagers and other wide-reaching mobs get their own coarser passes instead of the main thread, the governor re-measures properly, and the server thread takes the busiest dimension. On 1.21.1 NeoForge, mobs 28%, mixed 20% and a quiet server 17% below 1.0.1.
  • Compatibility: Alternate Current, Create belts, SpeeDeeEntity 1.0.2 and SuperChunk's mid-tick chunk tasks, wherever those mods exist for the version.
  • All eight versions carry the same features, and every one boots with every hook applied.

Upgrading from 1.0.x: an existing config/skein-common.toml keeps scheduledTicks.enabled = false, the old default. Set it to true to run redstone in parallel.

Versions

Each folder is a complete project for one Minecraft version and loader. They share the same features, commands and config keys, so a server can change version or loader and keep its config. New work lands in one folder first and is ported to the rest; as of 1.2.0 all eight carry the same work. Fixes for another mod apply where that mod exists for the version: Create on 1.20.1 and 1.21.1 NeoForge, SuperChunk on 1.20.1, 1.21.1 NeoForge and 1.21.11 NeoForge, Alternate Current on NeoForge 1.21.1, 1.21.11 and 26.2, Sable on NeoForge 1.21.1.

Folder Minecraft Loader Java
26.2-neoforge 26.2 NeoForge 26.2.0+ 25
26.2-forge 26.2 Forge 65+ 25
1.21.11-neoforge 1.21.11 NeoForge 21.11+ 21
1.21.11-forge 1.21.11 Forge 61+ 21
1.21.1-neoforge 1.21.1 NeoForge 21.1+ 21
1.21.1-forge 1.21.1 Forge 52+ 21
1.20.1-neoforge 1.20.1 NeoForge 47.1 17
1.20.1-forge 1.20.1 Forge 47+ 17

Put the jar for your version (a release build, or one you build yourself) in the server's mods folder. There are no other dependencies. Skein also runs in singleplayer, where the integrated server gets the same treatment.

Performance

The same generated world on each version and loader, on a dedicated server with and without Skein (8 worker threads, nine connected players). Each cell is vanilla ms/tick → Skein ms/tick.

1440 entities in pens farmland at randomTickSpeed 80 all at once, plus 480 entities in the Nether
26.2 NeoForge 12.1 → 5.8 (2.1x) 6.5 → 2.4 (2.7x) 27.8 → 8.3 (3.4x)
26.2 Forge 12.4 → 6.3 (2.0x) 6.7 → 2.4 (2.8x) 28.0 → 8.4 (3.4x)
1.21.11 NeoForge 14.6 → 6.9 (2.1x) 8.8 → 2.8 (3.2x) 28.3 → 9.0 (3.2x)
1.21.11 Forge 12.4 → 5.9 (2.1x) 6.2 → 2.5 (2.5x) 28.0 → 8.4 (3.3x)
1.21.1 NeoForge 13.9 → 8.6 (1.6x) 8.4 → 3.7 (2.3x) 25.0 → 11.4 (2.2x)
1.21.1 Forge 12.1 → 7.2 (1.7x) 5.7 → 2.7 (2.1x) 23.2 → 10.2 (2.3x)
1.20.1 NeoForge 14.7 → 8.6 (1.7x) 4.5 → 2.6 (1.7x) 24.8 → 10.2 (2.4x)
1.20.1 Forge 15.4 → 8.7 (1.8x) 4.5 → 2.7 (1.7x) 25.1 → 10.2 (2.5x)

Those are release 1.0.1. 1.1.0 is faster again, measured on 1.21.1 NeoForge: the mob scenario 28% and the mixed scenario 20% below 1.0.1, and a quiet server 17% below, from villagers no longer ticking serially, an adaptive governor that re-measures properly, and cheaper bookkeeping (report). On a quiet server, Skein stays within run-to-run noise of vanilla, because phases that don't pay switch off.

1.2.0 against 1.1.0 and vanilla on 1.21.1 NeoForge, run back to back in alternating order, three rounds each (median ms/tick; the machine had other work running, which slows vanilla's heaviest scenario most; results):

vanilla 1.1.0 1.2.0 1.2.0 vs vanilla 1.2.0 vs 1.1.0
Several tests at once: 1,440 entities in pens, 576 hoppers, farmland, 480 entities in the Nether 32.1 12.0 10.4 3.1x -13%
Crowded farm: Several tests at once, with 5,760 entities in the pens 82.8 28.6 26.4 3.1x -6%
Entities: 1,440 entities in 144 pens 19.2 8.3 7.6 2.5x -8%
Random ticks: 512×512 farmland at randomTickSpeed 80 10.2 4.5 3.8 2.7x -16%
Hoppers: 576 hoppers moving 9,216 items 3.6 2.8 2.4 1.5x -14%
Mob spawning: vanilla natural spawning, 9 players 30.6 18.7 13.4 2.3x -32%
Small survival server: vanilla natural spawning, 2 players 8.6 6.2 5.1 1.7x -16%

Small and shared hosts. On a machine with other work to run, waking the worker threads had cost the server thread up to two or three milliseconds a batch. The server thread now stops waking at the first slow wake and leaves the rest to the first worker that arrives, never runs a batch on more threads than the JVM has processors, and ticks idle dimensions in turn instead of handing them to a worker. On four CPUs shared with other work, a two-player server's tick fell 12% and a nine-player one's 3%; with cores to spare nothing changed (report).

Busy levels. Where the level's own thread sets the tick, a sixteenth of it had gone to adding the one-tick chunk tickets the workers' lookups parked, most of them repeats of a ticket already added that tick. Each now goes in once; the rest changed nothing in vanilla. On the busiest bench scenario the tick fell 8% for 7% less CPU (report).

Crowded levels. On a level of 5,760 penned animals (vanilla: 70 ms a tick), Skein's entity passes each waited on their busiest cell, so sixteen workers were no faster than eight. A level with 512 or more entities, crowded into fewer than two cells for each thread, now splits them over nine passes of quarter-size cells instead of four, with the same safety margin between the cells of a pass: 7.5% shorter ticks for 3% less CPU. A level whose mobs are spread around scattered players has cells to spare and keeps the four passes (report).

Passes that don't wait (after 1.2.0). A debug build that recorded which thread ran each cell showed where a crowded level's time still went: not to a slow thread (over 200 ticks every thread ran within 5% of the others) and not to how the pool handed cells out, but to the barrier after every pass. In any one pass some thread is 1.3 to 1.6 times slower than the rest, whichever one the machine has just moved to a shared core, and with a cell or two for each thread the whole pass waited for it: the passes of an entity phase took 20.5 ms where their work shared evenly was 11.5. The phase is now one batch in which a cell waits only for the cells of earlier passes it could reach. Against 1.2.0, in back-to-back pairs of runs on a machine with other work; the tick and the CPU are the median over a scenario's pairs (results):

1.2.0 ms/tick tick CPU per tick pairs
Crowded farm: 5,760 entities in pens, 576 hoppers, farmland, 480 entities in the Nether 24.8 -15% +1% 4
Several tests at once: the same with 1,440 entities in the pens 10.5 -14% -5% 4
Entities: 1,440 entities in 144 pens 7.2 -11% +1% 4
Mob spawning: vanilla natural spawning, 9 players 12.1 -3% +1% 4
Small survival server: vanilla natural spawning, 2 players 4.8 -5% +4% 6
Random ticks: 512×512 farmland at randomTickSpeed 80 3.8 -10% -5% 6
Hoppers: 576 hoppers moving 9,216 items 2.4 0% +4% 4
Quiet server: 9 players, each with a small pen, three hopper rings and a patch of farmland 2.8 -11% +2% 4

The entity phase alone is 15 to 23% shorter on the penned scenarios and 11 to 14% on the survival server. A phase runs this way only while its cells average 50 microseconds or more: every cell that becomes ready may wake a worker, which is more than a cell of chunks random-ticking at the default speed is worth, so those keep their passes and a server of hoppers alone ticks as it did (report).

TNT cannons (Orbital Skybender, 26.2 NeoForge, a 30,660-TNT payload): release 1.0.1 averaged 288 ms/tick with 1.5-second spikes and built only 38% of the payload in nine minutes; with 1.1.0's TNT work it builds all of it at 54 ms/tick, and its biggest pushes went from 1.2 seconds to under 0.1 (report). A repeating command block summoning 62 TNT a tick that each explode at once (Orbital Strike Cannon's size-1 stab, 1.21.1 NeoForge): vanilla 29.0 ms/tick, 1.2.0 6.7 ms (4.3x) (results).

Correctness

Skein is built around not changing what the game does, only when it happens:

  • redstone run in parallel (scheduledTicks) matches vanilla tick for tick, with block entities ordered as well: a fuzzer builds 48 random circuits (pistons, observers, comparators, falling sand, minecarts on detector rails, pressure plates, tripwire, sculk sensors, hoppers, water) and compares every block, entity and pending tick, in order, with vanilla for 600 ticks, over six seeds and 2 to 16 threads (how)
  • items moved through 121 hopper rings are counted before and after: 7,744 in, 7,744 out, in every configuration
  • nine sealed water and lava basins stepped 400 ticks give byte-identical results, serial and parallel
  • a TNT cannon's 5,070-TNT payload ends in exactly vanilla's positions and fuses
  • worker threads never load chunks; anything near the edge of loaded terrain ticks on the main thread
  • vanilla state that is unsafe to share (redstone torch burnout, wire power, raids, loot random sequences, points of interest, captured drops) is made thread-safe or deferred to the barrier
  • a type that throws or hangs while ticking in parallel is moved back to the main thread, and remembered

Scheduled ticks (redstone, fluids, falling blocks) keep vanilla's order exactly, and what they share -- block events, new entities, the sub-tick numbers of new ticks -- is put back in vanilla's order too. Block entities can do the same (blockEntities.vanillaOrderLimit); it is off by default because a dense contraption such as a TNT cannon is then one group on one thread. Elsewhere the order of work within a single tick can change (for entities and random ticks vanilla's is insertion order and a shuffle; Skein's is deterministic but different), and a few reactions arrive one pass later in the same tick. Random draws and entity ids are not vanilla's either, but vanilla does not reproduce those between runs.

Compatibility

Every Skein hook is optional. If another mod rewrites a method Skein needs, Skein switches off only the feature that hook serves, logs which mod changed it, and the game keeps loading. Compatibility fixes for specific mods load only when that mod is installed. Tested with:

  • Lithium, and its 1.20.1 ports Canary and Radium. A handful of their options keep per-level caches that in-level threading would race on. Skein turns those off through each mod's own config mechanism, and takes over what they did where it matters (entity collision lookups).
  • Create (kinetic networks, belts, deployers, brass tunnels, redstone links, logistics), Neruina, Cupboard, Ritchie's Projectile Library, Iron's Spellbooks, SuperChunk, SpeeDeeEntity, Carpet and WorldEdit, Alternate Current on NeoForge 1.21.1, 1.21.11 and 26.2, and Sable (the physics behind Create Aeronautics) on NeoForge 1.21.1, where whatever can reach a physics structure ticks on its level's thread.
  • Optimisation mods: ModernFix, FerriteCore, C2ME, ScalableLux, Noisium, Clumps, FastSuite, FastFurnace, FastWorkbench, AI Improvements, Let Me Despawn, Get It Together, Drops!, Staaaaaaaaaaaack, Async Locator, Fast Async World Save, Better Chunk Loading, Smooth Chunk, Chunk Sending, FastLeafDecay, Leaves Be Gone, Structure Layout Optimizer, Smooth Boot, Recipe Essentials, Connectivity, Packet Fixer, spark and Chunky, with every phase running in parallel (report). Where a mod lets dropped items merge further than vanilla, an item's reach in a parallel pass follows that mod's setting.
  • Async and DimThreads thread the same work their own way. With either installed, Skein switches itself off and says why in the log and in /skein status; use one or the other.
  • Two large modpacks, run with every modded block placed and every modded entity summoned: Create Chronicles (264 mods, 1.21.1) and a private 230-mod 1.20.1 Forge pack.

Mods that keep their own unsynchronised per-level state are the one thing Skein can't detect. If a modded machine misbehaves, add its block entity to blockEntities.blacklist, or turn that phase off.

Commands

  • /skein status shows the workers and cell geometry, which phases are on, how much each actually overlaps, per-dimension tick times, and any types moved back to the main thread
  • /skein reload re-reads the config at the next tick boundary
  • /skein unquarantine gives quarantined dimensions and demoted types another chance

Config

config/skein-common.toml, documented inline. The keys you are most likely to touch:

[general]
    threadCount = 0            # 0 = processors - 1, capped at 16
    useAllCpuThreads = false   # use every logical processor (restart required)
    adaptive = true            # time each phase both ways and take the cheaper one
    crashPolicy = "DISABLE"    # DISABLE keeps the server up; RETHROW gives a normal crash report

[dimensions]
    enabled = true
    blacklist = []

[entities]
    enabled = true
    collisionIndex = true      # collision lookups only consider entities that can be collided with
    parallelPistonPushes = true
    blacklist = ["minecraft:ender_dragon"]

[blockEntities]
    enabled = true
    vanillaOrderLimit = 0      # 512: neighbours that can affect each other tick in vanilla's order
    blacklist = ["minecraft:beacon", "minecraft:conduit", "minecraft:bell", "minecraft:end_gateway"]

[scheduledTicks]
    enabled = true             # redstone, fluids and falling blocks in parallel, in vanilla's order

If something looks wrong, turn phases off in this order: scheduledTicks, blockEntities, entities, randomTicks, dimensions.

When it won't help

  • The server is bound by chunk generation, disk or network rather than by ticking. Those already run off the main thread in vanilla.
  • Nobody is online. Random ticks and spawning only happen near players.
  • One huge contraption in one place: Skein parallelises across space, and one machine is one place (piston pushes of big entity stacks are the exception, see above).

Building

Each folder builds on its own with its Gradle wrapper:

cd 1.21.1-neoforge
./gradlew build        # the jar is in build/libs/
./gradlew coreTest     # scheduling and barrier checks without starting Minecraft (part of build)
./gradlew runServer    # a dedicated development server in run/

Java 21 for 1.21.x, Java 25 for 26.2 and Java 17 for 1.20.1. On 1.20.1, build with --no-build-cache: a cached build can ship without its mixin refmap.

Each folder's README.md is the full technical reference for that build (how the split works, the safety model, every config key, known limits), and its docs/ folder holds the design notes and measurements behind each change.

Benchmarks

bench/ is the harness behind the numbers above: it installs a real dedicated server for each version, connects nine headless players, builds the same scenarios with vanilla commands, and compares vanilla against Skein, or one Skein build against another. bench/packs/ runs a CurseForge modpack with and without Skein and compares the error logs. See bench/README.md.

License

All rights reserved (LICENSE). Made by TheProKnightGamer.

About

Multithreaded server ticking for Minecraft: dimensions and world regions tick in parallel. Forge and NeoForge, 1.20.1 to 26.2, server-side only.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages