DH Optimizer
DH Optimizer is a lightweight, external performance addon for Distant Horizons on Fabric (Minecraft 1.21 / 1.21.1). It reduces Distant Horizons CPU, GPU, disk, and memory overhead without modifying Distant Horizons' files or breaking visual quality.
Unofficial Addon Notice: This is an independent community optimization mod that uses non-destructive Mixins. It does not redistribute or alter Distant Horizons binaries.
✨ What This Mod Improves (In Plain English)
Distant Horizons renders massive horizons by managing thousands of LOD sections, shaders, and SQLite database reads in the background. **DH Optimizer** streamlines those heavy bottlenecks behind the scenes:
🎨 Smoother GPU & Frame Rendering
- Hardware Early-Z Split Pass: Moves distant opaque LOD terrain (beyond the near-clip fade shell) to a
discard-free GLSL shader path so your GPU can skip hidden pixels early. - Optimized Terrain & SSAO Shaders: Eliminates per-pixel array allocations and redundant trigonometry inside Distant Horizons shaders while preserving vanilla DH visuals.
- OpenGL State Deduplication: Binds VAOs once per pass, avoids redundant IBO/VBO state churn, and skips empty event dispatch loops on every buffer draw.
60 FPS Adaptive Governor: Keeps visual quality 100% identical to vanilla Distant Horizons whenever your game runs at 60+ FPS. If frame times stay above
16.6 ms, it smoothly scales DH SSAO resolution/samples with hysteresis (no flickering) to recover smooth framerates.💾 Faster LOD Storage & Compression
- SQLite Turbo Engine: Enables SQLite
WALmode, memory-mapped I/O (mmap), page caching, and reuses compiledPreparedStatementobjects per connection instead of recompiling queries repeatedly. Zero-Copy Zstd Streams: Uses pooled native
zstd-jnicontexts and direct buffer access to avoid unnecessary intermediate byte-array copies when saving or loading LOD data.⚡ Lower CPU Usage & Fewer GC Micro-Stutters
- FPS-Aware Background Thread Governor: Replaces coarse thread sleeps with sub-millisecond
LockSupport.parkNanosbackoff so DH background workers yield CPU cache headroom to the Render thread when FPS drops. - Lock-Free & Fast-Path Internals: Replaces contended positional locks with striped locks, adds an
O(1)fast path for untinted block colors, snapshots section config lookups once per section, and bypasses unneededPhantomReferencetracking on heap-only pooled lists. - Multiplayer Payload LRU Cache: Caches encoded LOD sync payloads on servers/hosts so multiple players receiving the same section don't force redundant re-compression.