Merge remote-tracking branch 'origin/main' into feat/terrain-lod
# Conflicts: # crates/horizon-client/src/gfx.rs
This commit is contained in:
+8
-4
@@ -20,10 +20,14 @@ plan are in [docs/server.md](https://github.com/ludovic111/horizon/blob/main/doc
|
||||
Until then Horizon players can join offline servers only (`online_mode = false`). An offline server never
|
||||
checks accounts: anyone who reaches it can join under any name. Keep it on your LAN or a tailnet
|
||||
(Tailscale, ZeroTier), or share it only with friends you trust.
|
||||
- **No secure chat.** Chat isn't signed, and `enforce-secure-profile` has no effect. Vanilla clients show
|
||||
chat from the server as not secure.
|
||||
- **Nether and End:** the world follows a player through portals when they are alone on the server
|
||||
(v2026.10.17.09 and newer). With several players online, portals don't move remote players yet.
|
||||
- **Secure chat** works as on vanilla's server: in online mode, vanilla clients sign their chat, and with
|
||||
`enforce-secure-profile=true` (the default) unsigned chat is refused. On an offline server, or for a player
|
||||
without a chat session (Horizon's own client today), chat stays unsigned and shows as not secure.
|
||||
- **Nether and End:** each player travels on their own through portals, and operators with `execute in
|
||||
<dimension> run tp`. The players in the level they leave stop seeing them, and the ones in the level they
|
||||
arrive in start to, as on vanilla (checked against vanilla with two players, by command and through an End
|
||||
portal: `tools/test_server_dimension_players_parity.py`). The console can't send another player to a
|
||||
dimension yet (`execute in ... run tp NAME`).
|
||||
- **Movement checks and chunk pacing** (release v2026.10.17.16 and newer). The server pulls back players who
|
||||
move too fast ("moved too quickly"), as vanilla does, and sends chunks as fast as each client acknowledges
|
||||
them.
|
||||
|
||||
+127
-14
@@ -236,7 +236,15 @@ How the game loads them, without touching vanilla's path:
|
||||
so the same mod set gives the same ids. Saves store block names, so ids never reach the disk.
|
||||
- Loaders that read only `data/minecraft/` (recipes, loot, tags) read every namespace, as
|
||||
vanilla does. With no mods there is only `minecraft`, so nothing changes.
|
||||
- The overlay is cached like the resource-pack overlay and rebuilt when a mod file changes.
|
||||
- The overlay is built on the first start with a set of mods and kept for later starts. A stamp
|
||||
(`horizon-mod-content.stamp`) hashes the game executable, the base tables and every mod file's
|
||||
size and mtime. Adding, removing or editing a mod, or a new build of Horizon, rebuilds it. For
|
||||
ATM10's 40 data-tier mods the build takes about a minute of the first start on a busy machine.
|
||||
- **Worldgen.** Mods' structures, structure sets, template pools, processor lists, configured and
|
||||
placed features join the `worldgen/*.json` bundles. Their structure templates go under
|
||||
`worldgen/structure/<ns>/`. Their biome tags are merged into `worldgen/biome_tags.json`, minus
|
||||
the biomes and tags Horizon does not have. Mod biomes, noise and density functions are not
|
||||
carried yet.
|
||||
- **Limits.** Chunk sections size their global palette to the registry: 16 bits for vanilla's
|
||||
35,723 states (the same chunks, saves and packets as before), one more bit each time content
|
||||
mods double it, up to 2^20 states (1,048,576). Past that the content root is refused with the
|
||||
@@ -398,6 +406,71 @@ Mechanical, the same for every mod, and no agent:
|
||||
carries those over.
|
||||
5. Write `<id>.hmod`. For a data-tier mod, it is now ported.
|
||||
|
||||
Two cases the oracle fills in:
|
||||
|
||||
- **Loot registered in code.** Chipped ships 7 loot tables for about 7,000 blocks; the rest
|
||||
drop themselves through Java code. When a declared block has no table in the jar and the
|
||||
oracle shows vanilla's drop-self, carry writes that table in 26.3's shape. When only the
|
||||
states with one property value drop it (a door's lower half), the entry gets vanilla's
|
||||
`match_block` condition. Chipped: 6,843 tables added.
|
||||
- **Worldgen carry-over.** Structure libraries give vanilla's types other names. Carry maps
|
||||
these to vanilla's:
|
||||
- `lithostitched:jigsaw`, MoogsStructureLib's and Repurposed Structures' generic jigsaws
|
||||
become `minecraft:jigsaw`;
|
||||
- their `advanced_random_spread` becomes `minecraft:random_spread`;
|
||||
- their versioned, legacy and empty pool elements become vanilla's.
|
||||
|
||||
Three more rewrites make the mapped structures decode and start where their mod would:
|
||||
- **Block states.** 1.21.1 writes a block or fluid state as `{"Name", "Properties"}`, 26.3
|
||||
as `{"id", "properties"}` and refuses the old shape, which failed the whole processor
|
||||
list, feature or pool. Carry rewrites them (#816; 1,005 files in 17 of ATM10's mods).
|
||||
- **Start and placement rules** (#820 in the game, #821 in carry). Repurposed Structures'
|
||||
and Moog's jigsaws refuse to start in liquid and check biomes and terrain height in a
|
||||
radius; their spreads keep a minimum distance from the world origin and away from other
|
||||
sets (named by a structure set tag). Carry writes these under `horizon:start_checks`,
|
||||
`horizon:min_distance_from_world_origin` and `horizon:exclusion_zone`; the game runs them
|
||||
(`horizon-world`'s `structure/start_checks.rs`). Vanilla data has none of the keys. Moog's
|
||||
also spreads its structures 1.65 times as far apart as its files say, which carry now
|
||||
applies. MVS went from 829 starts to 90 in a 128×128-chunk square (seed 1234): 294 from the
|
||||
spacing, the rest from the start checks.
|
||||
- **Processors written in Java** are taken out of their lists (#822). The game, like
|
||||
vanilla, refuses a list holding a type it does not know, and with it every pool naming the
|
||||
list. The structures now generate undecorated (no pillars under them, spawners as the
|
||||
template has them); 1,427 processors of 146 types in ATM10's mods, the most common
|
||||
`lithostitched:block_swap`, Formations' `biome_replacements` and Repurposed Structures'
|
||||
pillar, fluid and void processors. Porting the common ones is next.
|
||||
|
||||
Each mod's `carry-report.json` lists what was mapped, the rules and processors lost by name,
|
||||
and the types left as they are. NeoForge's convention biome tags (`#c:is_forest`, ...) come
|
||||
from the loader jar (`<work>/loader/neoforge-<version>-universal.jar`, fetched dev-only and
|
||||
SHA-1 checked) and are written into the carry. The game skips the structures it cannot
|
||||
decode.
|
||||
|
||||
On ATM10's 42 data-tier mods with a jar (seed 1234, chunks -64..63, `chunkgen_bench
|
||||
--starts` over the carried worldgen): 286 starts with 15,097 pieces, 150 of them vanilla's
|
||||
(unchanged), and no pool that fails to decode (65 before #816 in the 64×64 centre).
|
||||
- 1,061 files were mapped (MVS 413, MNS 210, MSS 157, MES 110, Repurposed Structures 104,
|
||||
ChoiceTheorem's Overhauled Village 66), and 103 convention biome tags written.
|
||||
- When Dungeons Arise, Structory and Towns and Towers use vanilla's types already.
|
||||
- Still lost, written in Java:
|
||||
- YUNG's API: its own jigsaw assembler (priority pieces, per-piece caps, conditions,
|
||||
enhanced terrain adaptation) and 491 elements and jigsaws, behind every "YUNG's Better"
|
||||
mod;
|
||||
- Formations' structure and element types (179);
|
||||
- the nether jigsaw variants of Moog's and Repurposed (69), which search the column for
|
||||
land after the layout;
|
||||
- Moog's and Repurposed's layout rules: they centre the pieces on the start, bury or lift
|
||||
the structure to the terrain and cap pieces per pool;
|
||||
- Repurposed's mineshafts, mansions, monuments and cities, and MO Structures (38; its
|
||||
library is only on CurseForge).
|
||||
- CTOV's villages and outposts are added to vanilla's `villages` and `pillager_outposts`
|
||||
sets by Java code, as lithostitched's `add_structure_set_entries` worldgen modifiers do for
|
||||
many packs; a content mod has no way to add to a vanilla set yet, so none start.
|
||||
|
||||
In a world with the 40 mods, seed 1234, `/locate structure mvs:azelea_house` finds one 27
|
||||
blocks from spawn and it stands there as the template builds it; When Dungeons Arise's
|
||||
bandit towers and Structory's chapel locate too.
|
||||
|
||||
### 5. Code: one agent per mod
|
||||
|
||||
For tiers logic, machines and deep, in dependency order, as many agents at once as the AI
|
||||
@@ -473,12 +546,15 @@ user's jars are, and its facts and results stay in the work folder. The first re
|
||||
| Glassential-renewed 3.4.7 | 105/114 | 5177/5177 | 5177/5177 | 4727/5177 | 6447/6447 | 210/210 | 105/105 | 143/143 | 106/115 |
|
||||
| Factory Blocks 1.4.0 | 42/49 | 42/42 | 0/42 | 42/42 | 294/294 | 84/84 | 42/42 | 1/1 | 42/49 |
|
||||
| Cloud Glass 1.1.0 | 16/16 | 16/16 | 16/16 | 0/16 | 112/112 | 32/32 | – | 31/31 | 16/16 |
|
||||
| Chipped 4.0.2 | 6857/6981 | 46212/46443 | 46443/46443 | 46396/46443 | 149093/149093 | 13548/13714 | 11984/12378 | 6/13 | 6849/6973 |
|
||||
|
||||
What fails is what API 0.2 cannot express yet: shapes of their own (Japanese doors, hedges,
|
||||
paths a sixteenth high, glass without collision), sound events of the mod's own
|
||||
(`factory_blocks:metal_sound`), and blocks whose vanilla class has no vanilla block with the
|
||||
same states (garage doors, double gates, engraved and facing paths, fans). Every drop, recipe
|
||||
and tag of the declared blocks matches.
|
||||
and tag of the declared blocks matches. Chipped's 124 missing blocks are its own classes (workbenches and
|
||||
`DirectionBlock`), and its workbench recipes need those blocks. Its drops match since carry writes
|
||||
the self-drop tables it registers in code (step 4).
|
||||
|
||||
### 7. Coverage report
|
||||
|
||||
@@ -520,9 +596,9 @@ files; `inventory`; `carry` and the harness on the eight mods we downloaded; `re
|
||||
By tier, the 367 not yet: data 57 (carry-over and the harness, no agent: their jars were not
|
||||
downloaded), logic 66 (API 0.3), machines 97 (0.4), deep 92 (0.5), client 35, unclassified 20.
|
||||
Ported: Macaw's Trapdoors. Partial: Macaw's Doors, Fences and Walls, Paths and Pavings,
|
||||
Glassential, Factory Blocks, Cloud Glass (see the harness table) and MVS, whose 784 worldgen
|
||||
files are carried but not yet read by the game. Of the 8, 7 are MIT and one LGPL; nothing is
|
||||
published.
|
||||
Glassential, Factory Blocks, Cloud Glass, Chipped (see the harness table) and MVS, whose
|
||||
structures now generate (see step 4). Of the 9, 7 are MIT, one LGPL and Chipped is under the
|
||||
Terrarium License; nothing is published.
|
||||
|
||||
## Measuring "10x"
|
||||
|
||||
@@ -582,8 +658,9 @@ vanilla's 35,723; the per-state tables are the next thing to measure), while the
|
||||
inside its 2 GB heap. Caveats, so none of this is a "10x" claim yet: other sessions and CI
|
||||
runners kept the machine's load average between 30 and 56 on 14 threads, so the confidence
|
||||
intervals are as wide as the means (`perf_bench.py --table`); Horizon's frames are paced near
|
||||
the display's 144 Hz at 8 chunks; Horizon's title time includes building the content overlay on
|
||||
a first start (about 5 s, cached afterwards); and the pack runs 1.21.1 against Horizon's 26.3.
|
||||
the display's 144 Hz at 8 chunks; Horizon's title time includes building the content overlay
|
||||
(about 5 s for six mods; it was rebuilt on every start then, and is kept for later starts now);
|
||||
and the pack runs 1.21.1 against Horizon's 26.3.
|
||||
A quiet rerun with more games is the next measurement.
|
||||
|
||||
**Where the RAM goes (2026-10-17).** RSS overstates it on macOS. `ps` counts pages the allocator
|
||||
@@ -620,8 +697,46 @@ indexes ids by a hash checked against the states: -22 MB live for vanilla, -124
|
||||
ATM10's, -30 MB and -140 MB of footprint. The startup peaks are what is left. Each step parses
|
||||
its per-state tables whole: as JSON trees, or as NBT trees of 300-600 MB each for ATM10
|
||||
(`block-properties.nbt`, the collision, support, occlusion and movement tables). The peak
|
||||
reaches 3.9 GB during worldgen loading, and the footprint stays near the peak. Typed, streaming
|
||||
readers for those tables are the next cut.
|
||||
reaches 3.9 GB during worldgen loading, and the footprint stays near the peak.
|
||||
|
||||
The NBT tables now stream: the readers check each state's identity as it is read, and no
|
||||
`states` tree is built (#753). That tree was about 240 MB for each table. With the carried
|
||||
ATM10 mods (153,511 states), the peak of each step falls by about 210 MB:
|
||||
|
||||
| step | before MB | after MB |
|
||||
|---|---:|---:|
|
||||
| light | 911 | 699 |
|
||||
| collision | 945 | 733 |
|
||||
| motion | 1,427 | 1,215 |
|
||||
| worldgen, uncached | 3,000 | 2,788 |
|
||||
|
||||
The fluid tables no longer decode the 211 MB `gameplay-facts.json` a second time (#754). The
|
||||
content root is kept between starts (#756). What is left at startup:
|
||||
|
||||
- `facts.json` went through a JSON tree, then an NBT tree, in both the registry and the assets
|
||||
step. It now streams (#825): at ATM10's size (214,338 states) each step's peak fell from
|
||||
816 MB to 153 MB (registry) and 235 MB (assets), and the RSS after the assets step from
|
||||
1,344 MB to 442 MB;
|
||||
- on a first start, the content-root build and `Behaviours`' decode of `gameplay-facts.json`
|
||||
(cached afterwards in the behaviour snapshot).
|
||||
|
||||
**Against NeoForge, same 40 mods (2026-10-17).** The 40 data-tier mods carried from ATM10 (the
|
||||
42 without Regions Unexplored and MO Structures, whose libraries are only on CurseForge),
|
||||
against their jars on NeoForge 21.1.259 with `-Xmx2G`. `perf_bench.py --port-work`, RD 8, one
|
||||
game each, load average 80-125 on 14 threads; `--warm` measures a later start:
|
||||
|
||||
| game | title / world s | RSS steady / peak MB | footprint steady / peak MB |
|
||||
|---|---|---|---|
|
||||
| Horizon before #756 (every start) | 81.1 / 102.8 | 4,008 / 4,164 | 2,368 / 2,554 |
|
||||
| Horizon, first start | 105.2 / 128.8 | 3,795 / 3,993 | 2,306 / 2,560 |
|
||||
| **Horizon, later starts** | **21.6 / 33.7** | **2,629 / 2,935** | **2,445 / 2,731** |
|
||||
| NeoForge + 40 mods | 53.2 / 119.9 | 3,099 / 3,203 | 3,304 / 3,381 |
|
||||
|
||||
On later starts, Horizon uses 15 % less RSS and 26 % less footprint than NeoForge with the
|
||||
same mods. It reaches the title 2.5x sooner and the world 3.6x sooner, and its flights ran at
|
||||
93-233 FPS against NeoForge's 27-62. The first start is slower than NeoForge's to the title,
|
||||
because it builds the content root once. One game per row on a loaded machine is not a
|
||||
benchmark; a quiet rerun with repeats is still to do.
|
||||
|
||||
## The working version for 2026-10-23
|
||||
|
||||
@@ -648,11 +763,9 @@ In scope (each is a PR or a small stack):
|
||||
6. **Measured:** load time, RAM and FPS of that pack on NeoForge 1.21.1 against Horizon, with
|
||||
the full ATM10 on NeoForge as the reference row.
|
||||
|
||||
Out of scope for that date, and next in order: worldgen carry-over (the 30 or so structure and biome mods;
|
||||
the first one looked at, Moog's Voyager Structures, declares all 130 structures and 116 structure
|
||||
sets with MoogsStructureLib's own `generic_jigsaw_structure` and `advanced_random_spread` types and
|
||||
NeoForge's `c:` biome tags, so its carry needs a mapping to vanilla's jigsaw and random spread
|
||||
types plus the oracle's biome tags, not only bundle merging),
|
||||
Out of scope for that date, and next in order: the rest of worldgen carry-over (mods'
|
||||
structures, sets, pools and features generate now, see step 4; mod biomes, noise and density
|
||||
functions, and the structure types written in Java such as YUNG's and Formations', do not yet),
|
||||
behaviour callbacks and server events (0.3), block entities, menus, capabilities and net
|
||||
(0.4), the first agent-ported logic-tier mod as the pilot of step 5, then machines. Porting all
|
||||
of ATM10 is a campaign. Each step publishes its coverage number; we make no claim beyond what
|
||||
|
||||
@@ -109,7 +109,7 @@ game accepts, test hooks included.
|
||||
- **Observe:** `state` (position, rotation, velocity, health, food, saturation,
|
||||
XP, effects, game mode, dimension, time, weather, the screen and what the
|
||||
crosshair points at), `looking-at`, `entities [RADIUS] [TYPE]` (mobs with
|
||||
ids and health, dropped items, orbs), `block X Y Z`, `blocks X1 Y1 Z1 X2 Y2 Z2`,
|
||||
ids and health, dropped items, orbs), `block X Y Z`, `blocks X1 Y1 Z1 X2 Y2 Z2`, `light X1 Y1 Z1 X2 Y2 Z2`,
|
||||
`find-block BLOCK [RADIUS]`, `inventory` (stacks with their components as
|
||||
SNBT), `screen` (the open screen or title menu, its buttons and slots) and
|
||||
`messages` (chat, title, subtitle and action bar).
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
# Paletted container access
|
||||
|
||||
The `unpack`/`get` cell reader and `BlockSection::get`/`set` are hot in the
|
||||
chunk workers: light and mesh workers unpack a section's 4,096 cells before
|
||||
propagating or meshing, and world-generation workers write one block at a time
|
||||
through `BlockSection::set`.
|
||||
|
||||
The write path resolved the old cell and probed the palette three times; the
|
||||
bulk readers dispatched the palette per cell; and the storage layer revalidated
|
||||
indices and values a section had already checked. All three are addressed.
|
||||
|
||||
## Changes
|
||||
|
||||
`BlockSection::set` (`crates/horizon-world/src/chunk.rs`) previously resolved the
|
||||
old cell through `get` and then probed the section's palette map three times for
|
||||
one non-trivial write: once to key the old state by id (`local_ids[&old]`), once
|
||||
to test the incoming state (`contains_key`), and once to find it (`get`). The
|
||||
slot at the written index already *is* the old state's id, so the old state is
|
||||
now read straight from storage, and the incoming state is resolved with a single
|
||||
map probe. The palette-reuse, free-slot and growth paths are unchanged, so the
|
||||
encoded palette, counts, free list and NBT output stay identical.
|
||||
|
||||
`BlockSection::get` and `set` validate the section index and the state id once,
|
||||
then read and write through `PackedStorage::read`/`write`
|
||||
(`crates/horizon-core/src/storage.rs`). These skip the storage-level bounds and
|
||||
value checks and the `Result` that `PackedStorage::get`/`set` keep for external
|
||||
callers: a section index is below 4,096 and a palette id always fits the width
|
||||
`bits_for_palette` chose. Both new methods `debug_assert` their contract and are
|
||||
used for the hot read, the hot write and the palette-growth re-encode.
|
||||
|
||||
`PalettedContainer::unpack` and `unpack_u16`
|
||||
(`crates/horizon-core/src/paletted.rs`) matched on the palette variant inside the
|
||||
per-cell loop. `Single`, `List` and `Global` are now dispatched once before the
|
||||
loop, leaving each arm a branch-free indexed loop.
|
||||
|
||||
No allocation, layout or wire format changes.
|
||||
|
||||
## Reproduce
|
||||
|
||||
```sh
|
||||
cargo test -p horizon-world --lib --profile fast benchmark_section_get_set -- --ignored --nocapture
|
||||
cargo test -p horizon-core --lib --profile fast benchmark_unpack -- --ignored --nocapture
|
||||
```
|
||||
|
||||
The ignored tests compare the new code against copies of the pre-optimization
|
||||
implementations, kept in the test modules (`baseline_get`/`baseline_set`,
|
||||
`baseline_unpack`). They check every resulting palette, count, free list, cell
|
||||
and NBT before timing. Rounds alternate baseline/optimized order with `black_box`
|
||||
and report the median and best nanosecond- or microsecond-per-operation; the best
|
||||
round is the estimate of uninterrupted CPU time on a contended machine.
|
||||
|
||||
`benchmark_section_get_set` uses a 32-state registry and 50,000 random writes and
|
||||
reads per round over a section whose palette grows through the 4- and 5-bit
|
||||
widths (24 distinct states); 51 rounds. `benchmark_unpack` fills a 4,096-entry
|
||||
list palette (12 states) and the global palette, 2,000 calls per round, 25
|
||||
rounds.
|
||||
|
||||
AMD Ryzen 5 5600X, Linux x86_64, rustc 1.99.0, optimized `fast` profile,
|
||||
nonincremental, no LTO:
|
||||
|
||||
| Operation | Original main | New | Speedup |
|
||||
| --- | ---: | ---: | ---: |
|
||||
| `BlockSection::set` | 13.15 ns/write | 9.12 ns/write | 1.44x |
|
||||
| `BlockSection::get` | 2.33 ns/read | 1.45 ns/read | 1.61x |
|
||||
| `unpack`, list palette | 1.910 us/call | 1.834 us/call | 1.04x |
|
||||
| `unpack`, global palette | 2.270 us/call | 2.179 us/call | 1.04x |
|
||||
|
||||
The distinct-state differential test
|
||||
`chunk::tests::set_matches_baseline_under_random_edits` drives the optimized
|
||||
`set` and `get` and the originals over the same 50,000-edit streams for 1, 2, 16,
|
||||
17, 24 and 64 distinct states, including periodic whole-section collapses that
|
||||
clear the storage and reclaim palette slots, and asserts equal results, bits,
|
||||
palette, counts, free list, `local_ids` and NBT throughout.
|
||||
@@ -0,0 +1,81 @@
|
||||
# Nether-portal section-scan benchmark
|
||||
|
||||
Run with the pinned prepared client resources:
|
||||
|
||||
```sh
|
||||
CARGO_BUILD_JOBS=6 cargo run --profile fast -p horizon-client --example portal_scan_bench -- \
|
||||
.local/horizon-client/26.3
|
||||
```
|
||||
|
||||
The example keeps the original `Game::may_hold_portal` alongside the resident
|
||||
cache (`portal_sections`). Both run in the same optimized binary, alternating
|
||||
measurement order. Each workload has one discarded warmup pair and seven pairs
|
||||
of 300 ticks. It reports resource loading and fixture construction separately.
|
||||
This measures the section scan only, not the whole `entity_portals` span, the
|
||||
sweep that follows a positive answer, or the rest of the tick.
|
||||
|
||||
The fixture is a 17x17 chunk world (289 chunks), each with 24 sections, and 500
|
||||
entity reaches spread over it (an item or mob box 0.25 wide and the small move
|
||||
that produces the swept box). A reach touches 1-4 sections. Four palettes:
|
||||
sparse (one non-portal state), dense (128 distinct), global (300 distinct, a
|
||||
global palette whose `maybe_has` walks the whole state range) and dense_portal
|
||||
(the dense palette with a portal in every fifth section). These are controlled
|
||||
fixtures, not a claim about typical generated terrain.
|
||||
|
||||
Steady includes the initial cache fill amortized over 300 ticks. Cold recreates
|
||||
the cache each tick, including allocation and destruction; reload clears it each
|
||||
tick while retaining capacity. Edit workloads alternate a block value in three
|
||||
or all 289 chunks before every scan. Timing includes the `Arc::make_mut` move of
|
||||
the 176-byte chunk wrapper caused by weak cache handles; the baseline holds no
|
||||
such handles. Both paths keep the original outer reach list.
|
||||
|
||||
The scan is parity-checked in the same run: the cached and per-tick answers must
|
||||
agree for every reach over every sample, or the example panics.
|
||||
|
||||
Measured on an AMD Ryzen 5 5600X (12 logical CPUs), Linux x86-64, rustc 1.99.0
|
||||
(b940084d7), using `fast` (release optimization, LTO off, 16 codegen units).
|
||||
Resource loading took 705 ms; fixture construction took 66 ms sparse, 360 ms
|
||||
dense, 392 ms global and 385 ms dense_portal, shared by both implementations.
|
||||
|
||||
Median microseconds per tick (seven paired samples):
|
||||
|
||||
| Palette | Workload | Original | Cached | Speedup |
|
||||
| --- | --- | ---: | ---: | ---: |
|
||||
| sparse | steady | 40.058 | 16.836 | 2.38x |
|
||||
| sparse | cold | 40.203 | 48.619 | 0.83x |
|
||||
| sparse | reload | 40.828 | 44.552 | 0.92x |
|
||||
| sparse | edit_1pct | 41.282 | 52.200 | 0.79x |
|
||||
| sparse | edit_all | 50.119 | 4192.396 | 0.01x |
|
||||
| dense | steady | 244.610 | 21.869 | 11.19x |
|
||||
| dense | cold | 292.533 | 1505.691 | 0.19x |
|
||||
| dense | reload | 250.397 | 1301.608 | 0.19x |
|
||||
| dense | edit_1pct | 256.522 | 69.132 | 3.71x |
|
||||
| dense | edit_all | 263.829 | 5904.581 | 0.04x |
|
||||
| global | steady | 6179.070 | 360.082 | 17.16x |
|
||||
| global | edit_1pct | 6251.530 | 1565.249 | 3.99x |
|
||||
| dense_portal | steady | 256.854 | 21.078 | 12.19x |
|
||||
| dense_portal | cold | 240.498 | 1526.251 | 0.16x |
|
||||
| dense_portal | reload | 347.879 | 2037.123 | 0.17x |
|
||||
| dense_portal | edit_1pct | 368.684 | 118.108 | 3.12x |
|
||||
| dense_portal | edit_all | 282.876 | 7194.112 | 0.04x |
|
||||
|
||||
The global palette's `maybe_has` walks the whole ID range, so rescanning every
|
||||
chunk each tick (cold, reload, edit_all) is intractable; those rows are not
|
||||
measured for it.
|
||||
|
||||
Keep: the steady scan improves for every palette (2.4x to 17x), which is the
|
||||
case that repeats each tick in real play. Under constant edits the cache also
|
||||
improves the dense and global palettes (edit_1pct 3-4x) because the original
|
||||
rescans through the per-tick map. Rescanning every chunk every tick (cold,
|
||||
reload, edit_all) is slower than the original because a miss scans all 24
|
||||
sections of a chunk, where the original only touched the sections a reach
|
||||
overlaps. No whole-game speedup is inferred from this microbenchmark; real
|
||||
terrain's palette sizes and block-write frequency determine the gain. Lighting
|
||||
and other chunk changes conservatively invalidate a chunk's mask.
|
||||
|
||||
The cache adds a weak handle and mask per visited resident chunk, retains no
|
||||
unloaded block data, and is pruned when a chunk unloads (`sync_tick_chunks`) and
|
||||
cleared on resource reload, like `random_tick_sections`. Editing a cached chunk
|
||||
can move its 176-byte wrapper (plus Arc bookkeeping) on the first edit after it
|
||||
is cached; it does not force a deep copy of the block data. The original outer
|
||||
reach-list allocation remains.
|
||||
+2
-2
@@ -82,7 +82,8 @@ not tick cost, so it is in scope here (see section 9).
|
||||
|
||||
| Area | Status |
|
||||
|---|---|
|
||||
| `online-mode=true` | **Works** (ServerLoginPacketListenerImpl): a 1024-bit RSA key pair at start ("Generating keypair"), the encryption request, the shared secret and challenge, AES/CFB8, and the session service's `hasJoined` check (with the address when `prevent-proxy-connections` is on), with vanilla's log lines and messages. `test_online_mode_parity.py` runs the same logins against vanilla's server and Horizon's with a mock session service. Not yet: secure chat (chat is unsigned, as on a server that doesn't enforce it). |
|
||||
| `online-mode=true` | **Works** (ServerLoginPacketListenerImpl): a 1024-bit RSA key pair at start ("Generating keypair"), the encryption request, the shared secret and challenge, AES/CFB8, and the session service's `hasJoined` check (with the address when `prevent-proxy-connections` is on), with vanilla's log lines and messages. `test_online_mode_parity.py` runs the same logins against vanilla's server and Horizon's with a mock session service. |
|
||||
| Secure chat | **Works** (`SignedMessageChain`, `LastSeenMessagesValidator`, `MessageSignatureCache`): the chat session update and its profile key, checked against the services' `playerCertificateKeys`; signed chat, `say`, `me` and `msg`, relayed with their signatures and last-seen lists; `enforce-secure-profile` (with `online-mode`) refuses unsigned chat; and vanilla's log lines (`[Not Secure]`, the decoder's warnings, the kicks). Offline servers and players without a chat session chat unsigned, as on vanilla. `test_secure_chat_parity.py` runs the same signed and unsigned players against vanilla's server and Horizon's, with test keys and a mock services server. |
|
||||
| Nether and End | **Players can't change dimension.** The engine keeps one dimension loaded (`Game::enter_dimension` moves only the local single-player player), and the hub serves one `dimension` to everyone. |
|
||||
| Refused logins | Logged as vanilla does: `Disconnecting <name> (/address): <reason>`, then `<name> (/address) lost connection: <reason>`, and the session errors (`Username '<name>' tried to join with an invalid session`, `Couldn't verify username because servers are unavailable`). |
|
||||
| Gameplay for remote players | The LAN guest leftovers apply: an item used on a block is used twice, the recipe book doesn't work, status effects don't apply to guests, arrows don't record their owner, team friendly fire is ignored (#484). Block desync and short freezes are reported on a same-machine server (#500). |
|
||||
@@ -507,7 +508,6 @@ machine, then published in `benchmarks/`; and item 5.
|
||||
|
||||
**Out (next):**
|
||||
|
||||
- secure chat on the server (online mode itself works);
|
||||
- the Nether and End for remote players;
|
||||
- the headless engine and its RAM win;
|
||||
- a server-only prepare without a JDK;
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
# Constant surface-rule specialization benchmark
|
||||
|
||||
The upstream PR contains only the surface change and tests, reapplied to upstream main. The measurements below were collected with #796 present; they are historical incremental measurements, not new timings for the rebased upstream head.
|
||||
|
||||
This surface-only change is based on the bulk unary density optimization in [upstream PR #796](https://github.com/ludovic111/horizon/pull/796). Measurements compare against `eb3789038e3184c98a1459fe638947200217d360`, which already includes that optimization; its savings are not counted again.
|
||||
|
||||
With one worker, primary initialized Overworld terrain time improved from 10.664 to 10.298 ms/input chunk (3.43%). Terrain plus decoration improved from 12.645 to 12.242 (3.19%). With four workers, terrain improved 2.48% and combined time 2.07%. Nether terrain improved 4.16% / 3.93% with one/four workers; combined improved 3.76% / 3.63%. The second Overworld site improved terrain 2.53% / 2.81%. End improved 2.95% with one worker but regressed 2.93% with four, with substantial paired noise. This meets the revised 3% median gate on selected representative cases, not the original 5% gate or every workload.
|
||||
|
||||
Cases were declared before editing. Each used one discarded pair followed by five alternating baseline/candidate pairs, with identical work and builds. The primary case used seed 12345, center (0,0), 256 terrain chunks and 196 decorated interior chunks, at one/four workers across all three dimensions. The second Overworld case used seed -1 at (32,-32). An offset 9×9 generation pass initialized the same seeded generator without pre-generating the measured region. Wall time is elapsed/input count; combined time includes the complete decoration phase and required borders. Cold startup was measured separately.
|
||||
|
||||
Machine: AMD Ryzen 5 5600X, 32 GiB RAM, Linux, Rust 1.99.0. Optimized `fast` profile: release optimization, LTO off, 16 codegen units. Runs and builds were sequential; background desktop activity was not isolated. Memory use was effectively unchanged. The benchmark used the existing chunkgen benchmark with identical optional initialization and exact timing instrumentation on both revisions. `crates/horizon-world/examples/chunkgen_bench.rs` is the standard workload entry point; its thread-multiplied human-readable ms/chunk display differs from actual elapsed/count.
|
||||
|
||||
Validation passed: 102 targeted Rust tests; 162 world-crate tests; 24 exact complete-field baseline/candidate terrain and decorated comparisons across three dimensions, two sites/seeds, and one/four workers; and six fresh pinned Java 26.3 client/server suites covering material stages, rule library, conditions, temperature, extensions, and surface generation. Differential snapshots included block states/palettes, quart biomes, binary entities/block entities, scheduled ticks, all six heightmaps, ordered postprocessing, non-air counts, and chunk metadata. Compilation/binding errors, dynamic queries, and short-circuit behavior have regression coverage. The final production executable matched the measured candidate byte-for-byte.
|
||||
|
||||
The repository quick PR check also passed public-tree validation, Python tests, formatting, clippy, and world tests. Validation is scoped to the declared corpora and does not establish complete gameplay parity. Generated timing files, diagnostic runners, patches, and validation logs are retained locally outside the repository and are not included in this PR.
|
||||
Reference in New Issue
Block a user