Chunks and networking
Most of a server's work for players is sending them data: the world around them and what moves in it. Vanillite is built so that this work grows as little as possible with the number of players.
Chunk data stored in network format
A chunk is a 16×16 column of the world. Minecraft sends chunks to players in a compact, packed format. Vanillite keeps chunks in memory in exactly that format.
Why this helps: sending a chunk to a player is mostly a plain copy, with no conversion. And the packed format is small, so it uses about as little RAM as Vanilla. Each chunk section also keeps small counters (for example "how many blocks here need random ticks", or "this section holds only redstone conductors"), so whole sections can be skipped when nothing in them matters: a mob spawn attempt that lands in such a section is turned down without reading the blocks.
Chunks go to each player in batches, like in Vanilla: the client reports how fast it can take them, and the server sends no more than that. A batch is filled with chunks that are ready, so it does not stay small while the nearest chunks are still being generated. For a player who is moving (walking fast or flying), the chunks ahead of them in their direction come first.
Status: built.
Loading and saving in the background
Loading a chunk from disk, generating it and lighting it all run as background jobs on the worker threads. The world's own thread does not wait for the disk, and finished jobs and disk reads are picked up between ticks too, so the next step of a chunk starts right away. Jobs for chunks ahead of moving players run first, and a generation step for a chunk that nobody needs any more is skipped. A step that runs on the world's own thread (the last ones of a chunk) needs no job slot, so it is never held back while all slots are busy: a chunk whose terrain is ready becomes full at once, also in the middle of a big area of new terrain. One exception copies Vanilla on purpose: when a block change or redstone reaches a chunk that is not loaded, the chunk is loaded right then, like in Vanilla, so contraptions at the border behave the same. Such loads are counted and logged once a minute per world, so they are easy to find; at debug log level each one is logged with where it came from. To keep them rare, a chunk runs block and fluid ticks only once the 3 × 3 chunks around it are full, as in Vanilla. A limit (performance.chunks.max-jobs) keeps the queue of waiting jobs from growing without end. Chunks nobody needs any more stay loaded a little longer (performance.chunks.unload-delay), so walking back is cheap, and are then saved and unloaded. When a player walks into a new chunk, only the chunks at the edge of their area are updated, not the whole area (Chunks). Players standing in the same chunk share that work. Like in Vanilla, the chunks around a player follow them only when the server accepts a move of the client (walking, riding, a spectator's camera) or when the player enters the world, so a teleport shows the same chunks at the same tick as Vanilla.
Chunks a player waits for go live between ticks. A chunk that a player is waiting for (for example after a /tp into new terrain) can finish its last step or its disk load between two ticks. It used to wait for the next tick and then for the next sending pass, so the first chunk after a teleport arrived two ticks late. Now the world's own thread makes such a chunk full right away and sends it, as long as there is time left before the next tick's deadline (2 ms are kept free, and room is kept for the next tick's batch). The chunk is the same as if it had waited. In the developers' own chunk benchmark (a local check, not the published suite) the first chunk after a /tp came after 78 ms instead of 104 ms (median).
A player who joins is placed in the world once the chunks around the spawn are full, so nobody stands above chunks that do not exist yet. The work for the spawn areas of players who are logging in or have just joined goes before all other chunk work; only the order changes, not the result. With performance.chunks.warm-spawn (on in the paper, spigot and performance profiles) the 9 × 9 chunks around the world spawn are also kept loaded from the start, so the first player finds them ready (Performance settings).
To generate a chunk, Vanillite also needs parts of its neighbours. These neighbours are only kept in memory while a chunk is actually being generated. Terrain that already exists on disk loads without them, which saves RAM while players fly over old terrain.
Cold chunks. Loaded chunks that do not tick (the outer ring of a player's view and everything beyond the simulation distance) are packed in memory after performance.chunks.cold-after seconds: their blocks and light go into one LZ4 or zstd block, which saves RAM. Heightmaps, biomes and uniform sections stay as they are. A packed chunk is unpacked when something reads it again, for example when a player walks towards it; that costs some microseconds once. Scheduling, entities, block entities and mob spawn checks never need it unpacked. The setting is performance.chunks.cold-packing: off in the vanilla profile, lz4 in paper, zstd in performance. The game is the same either way. There is no published measurement of the RAM it saves yet. How the server keeps its memory in check otherwise: Memory and startup.
New worlds are stored in Vanillite's own world format: smaller files that load and save faster, with a checksum for every chunk. Worlds in Vanilla's format (Anvil region files) are read and written as they are, with a faster zlib library, so the files stay readable by Vanilla. vanillite export writes a copy in the other format at any time (see First start). Mobs and other entities are saved with their chunks in separate entity records, like Vanilla's entity files.
Saving is built to lose nothing. If the disk is full or read-only, chunks that cannot be written stay in memory, are still served to players, and every save tries them again. If a saved chunk cannot be read, the server generates it again, but first copies the damaged record into the unreadable folder of that dimension. A damaged region file, level.dat or player file is kept as a copy before anything new is written over it. Measurements: World storage.
Status: built.
Encode once, send to many
When something happens that many players must see, the server builds the network message once and sends the same bytes to everyone, instead of building it again for each player. Compression is also done once.
Why this helps: with hundreds of players in one area, this saves a lot of CPU time.
Status: built in the network layer and used by entity tracking and chunk sending: each chunk's packet is built once and shared by every player who receives it, until the chunk changes. With Anti-Xray on, the chunk is masked once and the masked packet is shared the same way. To save RAM, the server keeps such a packet only as the finished compressed message; the uncompressed data it was made from is dropped after the first use and rebuilt only if a player needs another form (see Memory and startup). The first compression is a fast one, so the first players are not kept waiting. When a second player needs the same chunk, a background job compresses the packet again at a stronger level (performance.chunks.packet-recompression) and replaces the kept one if the chunk has not changed, so later players receive about a tenth fewer bytes. All entity updates of a tick are built once and then packed into one batch per player, so each player's connection is woken only once per tick; the packing runs in parallel on the worker threads. The same goes for the effects of survival (damage, sounds, entity events): they are collected per receiver and queued once, not packet by packet. A single batch is encrypted in the buffer it was built in, without one more copy. Plugins that listen to packets do not break this: a packet is still built once, and a change by a listener is one shared copy unless it is meant for a single player.
Entity tracking without "everyone with everyone"
The entity tracker decides which player sees which entity, and sends movement updates. A simple tracker would compare every player with every entity, which gets very slow with many players.
Vanillite's tracker remembers which players are near each cell of 4×4 chunks. When an entity moves into another chunk, it only checks the players registered in the cells around it, and then tests each of them exactly. The cells keep the lists short: a crowd that walks from chunk to chunk changes few lists instead of dozens. So the work per tick grows with what actually moves, not with "players × entities". What each player sees is kept as a compact list of yes/no bits, so even with thousands of players close together this costs only a few bytes per player and entity. A player's own view of the entities is checked again when the player moves, enters another chunk section or changes the view distance, like in Vanilla. On a server with several cores these checks run in parallel on the tick helper threads (see Threads and ticks); the changes are then applied one after another in Vanilla's order, so every player's stream stays the same. Under overload it can send movement updates less often, if you turn that on (see Performance settings). Natural mob spawning uses the same idea: each chunk knows the players near it (Players and tick time).
Entities are stored in columns (all positions together, all speeds together, and so on). A pass over all entities then reads memory in order, which is fast.
Status: built. It runs in every world tick and shows players, mobs, items, arrows and vehicles to the players near them.
Bounded queues
Each connection has a limited queue for incoming and outgoing packets. A slow or hostile client cannot make the server collect endless data for it. The queues only take memory while packets actually wait, and the world takes the waiting packets of a player in one go each tick. The network runs on its own threads and never blocks the game.
Status: built in the network layer.
See also: Performance settings (chunk, storage and tracking settings), Security by design, Players and tick time, Chunks.
Next: World generation.