Skip to content
WitherBlitzPublic

About

Performance mod for Horizon (Minecraft Java 26.3 in Rust): chunk workers behind the render thread, an adaptive chunk-worker governor and background FPS caps. 1% lows x2.4 on a laptop iGPU.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Sunset

A performance mod for Horizon, the Rust rewrite of Minecraft: Java Edition 26.3. Sunset smooths out Horizon's frame times on laptops and integrated GPUs by keeping chunk loading out of the way of rendering. It also takes ideas (no code) from Java's optimization mods (Sodium, Dynamic FPS, More Culling, ServerCore) and writes them in Rust for Horizon's engine.

On a Core Ultra 7 155U laptop with Intel integrated graphics, measured with Horizon's own benchmark over two interleaved rounds on a quiet machine (docs/benchmarks.md):

Stock Horizon (Nightly 11-03) Horizon main (packed quads) Horizon main + Sunset 0.3
Average FPS 170 239 229
1% low 59 85 142
0.1% low 34 40 109
Frames of 50 ms or more, per run 2.5 0.5 0

Horizon's own new compact quad layout raises the average. Sunset removes the stutters that remain: 1% lows go up 67% and 0.1% lows nearly triple over the same Horizon without it.

What it does

Chunk workers behind the render thread (Windows). Horizon runs world generation, lighting and meshing on one pool of workers, one per CPU thread. On Linux and macOS it puts them behind the render thread; on Windows that step does nothing, so all 13 workers compete at normal priority with the graphics driver's own threads, and the render thread then waits 70-300 ms in Queue::submit for a driver that can't get a core. Sunset sets Horizon's helper threads to below-normal priority as they start. This one change took the 0.1% low from 35 to 88 FPS.

Adaptive chunk-worker governor (the idea behind Sodium's chunk-build budget and ServerCore's load-based throttling). While you're in a world with no screen open, Sunset limits how many workers may start new jobs. It starts at half, cuts the limit by a quarter when a frame stutters, and adds one worker back for every 4 seconds of smooth frames. No job is dropped or reordered; running jobs are never interrupted. In menus, the pause screen and while a world loads, every worker runs. On a 15 W chip whose CPU and GPU share one power and memory budget, fewer cores meshing at once leaves more for the GPU. Modes: auto (default), off, or a fixed worker count.

Background FPS (the idea of Dynamic FPS). 30 FPS when the window is unfocused with a world open, 5 FPS when minimised, instead of drawing at full speed for nobody. Horizon keeps the lower of every limit, and benchmarks and horizon-ctl runs are left alone.

Leaf culling across sections (opt-in). Horizon's hollow leaf culling, extended across section borders where the neighbouring data is real. It makes tree canopies look visibly thinner and measured no faster, so it's off.

Block-entity caches (opt-in). Horizon's own caches for chests, signs, banners and the like, which it leaves off.

docs/ideas.md lists every Java optimization mod considered (and OptiFine's options), what Horizon already does (most of Sodium's renderer is already in it), and why the rest is left for later. Sunset 0.3.0 also had greedy meshing; 0.3.1 removes it, since Horizon's own compact quad layout saves the same GPU time (docs/benchmarks.md has the measurements).

Where the time goes

On the laptop above (the full numbers are in docs/benchmarks.md):

  • CPU: about 70% of the game's CPU cycles go to the chunk workers (world generation, light, meshing), 13-20% to the render thread and 8-10% to the single-player server thread.
  • GPU: the terrain pass takes nearly all of a frame's GPU time (2.1-5.8 ms); the second terrain pass with water 0.7-2 ms; the HUD, the hand, animated textures and screen effects a few tenths of a millisecond together.
  • Render thread: about 1.5 ms of CPU work per frame, then about 2 ms waiting for the GPU. The GPU sets the pace.

Install

Sunset is a native mod: the Horizon launcher compiles it into the game. It needs launcher 0.2.37 or later, and the first build takes 15-30 minutes. Native mods run with your user's rights, so read the source first. It's about 1,200 lines, half of them tests and comments, in mixins/sunset/.

  • From GitHub: in the launcher, Mods → Add from GitHub → https://github.com/WitherBlitz/Sunset, then Build.
  • From a release: download sunset-0.3.1.hnmod from Releases, put it in the instance's horizon-native-mods folder, and build.
  • From the command line:
    horizon-launcher native-build path\to\Sunset\mixins\sunset --instance <instance> --trust-native-code

Sunset 0.3.1 pins Horizon main at f40d4df (2026-11-04), the first commit with Horizon's compact quad layout: the launcher downloads that commit's source and builds on it. Sunset hooks engine functions that aren't official hook points (the worker pool's job choice, behind_server, the mesher), so each new Horizon needs its pin checked. The launcher says so if they no longer match. For Nightly 2026-11-03, use the 0.1.0 release.

Settings

Options → Mods → Sunset → Settings, or in chat:

Command
/sunset Status: active and held-back workers, stutter cuts, FPS, settings
/sunset governor auto|off|<N> The worker governor
/sunset bgfps <N|off> FPS cap in the background (default 30)
/sunset minfps <N|off> FPS cap when minimised (default 5)
/sunset leaves on|off Leaf culling across sections (default off)
/sunset culling on|off Block-entity caches (default off)
/sunset reset Defaults

Turning Sunset off in Options → Mods turns off everything except the helper-thread priority, which is set when each thread starts.

How it works

Native mods are horizon-mixins bundles: TOML that injects small Rust helpers into named functions of Horizon's source before it's compiled.

File Injected into Does
pool.rs module horizon_threads::sunset_pool The worker cap, the gate, the Windows priority call
gate.rs HEAD of horizon_threads::jobs::choose A worker over the cap waits here before choosing a job
behind.rs HEAD of horizon_threads::behind_server Helper threads go to below-normal priority on Windows
runtime.rs module game::sunset Settings, the governor (AIMD), background FPS; also the Cargo library for tests
frame.rs HEAD of native_frame Once a frame: frame time to the governor, cap to the pool, culling options
framerate.rs HEAD of native_framerate_limit Background FPS
leaves.rs, mesh_region.rs, leaf_cell.rs module mesher::sunset_leaves, Mesher::mesh_reusing, leaf_culling::in_section Leaf culling across section borders
list.rs, settings.rs, click.rs, command.rs Options → Mods, settings page, /sunset UI

Settings live in memory and are only written when you change them. Horizon's native_setting reads a file on every call, so a mod that reads it every frame does disk I/O every frame.

Develop

cargo test   # the governor, settings, commands, the pool gate and leaf culling, without a game
powershell -ExecutionPolicy Bypass -File tools\package.ps1   # target\sunset-<version>.hnmod

On Windows without Visual Studio, use the launcher's own GNU toolchain (%APPDATA%\horizon-launcher\rust\1.99.1-x86_64-pc-windows-gnu, with its bin and mingw64\bin on PATH).

License

MIT. Sunset contains no Minecraft code or assets and no code from any Java mod: only ideas, described in docs/ideas.md. Horizon is an unofficial fan project, not affiliated with Mojang or Microsoft.

About

Performance mod for Horizon (Minecraft Java 26.3 in Rust): chunk workers behind the render thread, an adaptive chunk-worker governor and background FPS caps. 1% lows x2.4 on a laptop iGPU.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages