Merge pull request #33 from ludovic111/integrated-tick-context
Capture shared graphics context in integrated-server tick reports
This commit is contained in:
@@ -68,6 +68,8 @@ jobs:
|
||||
cp dist/client-graphics-smoke.json dist/client-graphics-macos-world.json
|
||||
- name: Compile the private dispatch fixture
|
||||
run: python -c "from tools.build_mod import build_dispatch_fixture; build_dispatch_fixture()"
|
||||
- name: Compile the private integrated-server graphics fixture
|
||||
run: python -c "from tools.build_mod import build_integration_fixture; build_integration_fixture('server-graphics', 'dev.horizonlab.metrics.ServerGraphicsIntegration', fixture_dependencies={})"
|
||||
- name: Compile the private tick-manager state fixture
|
||||
run: python -c "from tools.build_mod import build_integration_fixture; build_integration_fixture('tick-state', 'dev.horizonlab.metrics.TickStateIntegration')"
|
||||
- name: Compile the private terrain tick membership fixture
|
||||
@@ -87,6 +89,9 @@ jobs:
|
||||
- name: Install headless graphics libraries for applied-hook checks
|
||||
if: runner.os == 'Linux'
|
||||
run: sudo apt-get update && sudo apt-get install -y xvfb libgl1 libegl1 libvulkan1 mesa-vulkan-drivers libasound2t64 libxkbcommon0
|
||||
- name: Verify integrated-server graphics report against the actual device
|
||||
if: runner.os == 'Linux' || runner.os == 'macOS'
|
||||
run: python tools/test_server_graphics.py ${{ runner.os == 'macOS' && '--native-display' || '' }}
|
||||
- name: Exercise the applied dispatcher hooks and upstream rejection path
|
||||
if: runner.os == 'Linux'
|
||||
run: python tools/test_dispatch.py
|
||||
@@ -130,6 +135,7 @@ jobs:
|
||||
dist/terrain-position-integration.json
|
||||
dist/quad-reuse-integration.json
|
||||
dist/quad-size-integration.json
|
||||
dist/server-graphics-smoke.json
|
||||
dist/client-graphics-smoke.json
|
||||
dist/client-graphics-macos-title.json
|
||||
dist/client-graphics-macos-world.json
|
||||
|
||||
@@ -6,7 +6,7 @@ Client-first performance research for Minecraft Java **26.3**, preserving vanill
|
||||
|
||||
## Play on your Mac
|
||||
|
||||
Download **horizon-mac-starter-0.20.0.zip** from [Releases](https://github.com/ludovic111/minecraft-optimization-lab/releases), extract it and open `Mac-Start.command`. It verifies and installs official universal Prism Launcher in `~/Applications` if needed, then opens the balanced pack import. Sign into Microsoft **inside Prism yourself**. This project needs no credentials.
|
||||
Download **horizon-mac-starter-0.21.0.zip** from [Releases](https://github.com/ludovic111/minecraft-optimization-lab/releases), extract it and open `Mac-Start.command`. It verifies and installs official universal Prism Launcher in `~/Applications` if needed, then opens the balanced pack import. Sign into Microsoft **inside Prism yourself**. This project needs no credentials.
|
||||
|
||||
Use native **Java 25 ARM64**, maximum heap **6144 MiB**, minimum **512 MiB** on your 16 GB M2 Pro. Prism can download Java automatically. Start at 1280×800 or 1920×1200; full Retina resolution is a larger GPU workload. [START-HERE.txt](packs/START-HERE.txt) has details. The same `.mrpack` files import into Prism on Windows and Linux.
|
||||
|
||||
@@ -216,3 +216,5 @@ python3 tools/check_public_tree.py --history
|
||||
CI checks offline tools/Rust and compiles the original mod/builds packs on Linux, Windows and Apple Silicon macOS. Game dependencies download to ephemeral `.local/`; CI uploads only our original JAR and packs. Compilation is not Mac GPU gameplay testing. Publication checks allow Java only under our original `dev/horizonlab` namespace; review diffs as well.
|
||||
|
||||
[MIT](LICENSE) covers only our original tracked work. Dependencies retain their licenses. Mojang [removed obfuscation](https://www.minecraft.net/en-us/article/removing-obfuscation-in-java-edition) without changing [Minecraft's EULA](https://www.minecraft.net/en-us/eula). Decompiled game source remains local; published code implements independent tooling and instrumentation.
|
||||
|
||||
Integrated-server reports record the shared graphics backend at recording start; see [the context and comparison limits](docs/server-graphics-context.md).
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
# First test on the M2 Pro Mac
|
||||
|
||||
For the 16 GB M2 Pro, start with the published 0.20.0 packs. Core and balanced
|
||||
For the 16 GB M2 Pro, start with the published 0.21.0 packs. Core and balanced
|
||||
pass title/demo-world rendering and save/exit probes on the hosted macOS ARM64
|
||||
software renderer. Gameplay and FPS on this physical Mac remain unmeasured.
|
||||
The Linux software-rendering observations do not predict an M2 speedup.
|
||||
|
||||
## Import after installing Prism
|
||||
|
||||
1. Download [horizon-mac-starter-0.20.0.zip](https://github.com/ludovic111/minecraft-optimization-lab/releases/download/v0.20.0/horizon-mac-starter-0.20.0.zip)
|
||||
1. Download [horizon-mac-starter-0.21.0.zip](https://github.com/ludovic111/minecraft-optimization-lab/releases/download/v0.21.0/horizon-mac-starter-0.21.0.zip)
|
||||
and extract it in Finder.
|
||||
2. In Prism, choose **Add Instance > Import**, then select
|
||||
`horizon-m2-balanced-0.20.0.mrpack` from the extracted folder. The individual
|
||||
`horizon-m2-balanced-0.21.0.mrpack` from the extracted folder. The individual
|
||||
`.mrpack` is the import file; the starter ZIP contains several different packs.
|
||||
[Prism's import guide](https://prismlauncher.org/wiki/help-pages/zip-import/)
|
||||
describes the supported archive formats.
|
||||
@@ -38,8 +38,8 @@ experiments to try after this first launch succeeds.
|
||||
|
||||
## Measure performance at the same view distance
|
||||
|
||||
Import `horizon-baseline-0.20.0.mrpack` and
|
||||
`horizon-core-performance-0.20.0.mrpack` from the same starter folder. Both use
|
||||
Import `horizon-baseline-0.21.0.mrpack` and
|
||||
`horizon-core-performance-0.21.0.mrpack` from the same starter folder. Both use
|
||||
12 full-detail chunks, 12 simulation chunks and no distant LOD or shaders. Core
|
||||
adds the pinned performance mods; all original experimental controllers are off.
|
||||
Comparing these two isolates the core stack more closely than comparing baseline
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
# Integrated-server graphics context
|
||||
|
||||
Client rendering competes with the integrated server for CPU time. Version 0.21
|
||||
copies GPU, backend and driver into the tick report when F8 or `/horizon bench`
|
||||
starts a single-player recording. The values come from the client/render thread
|
||||
and are copied into immutable metadata; server ticks never access GPU APIs.
|
||||
|
||||
Reports identify `server_runtime_kind` as integrated, dedicated or unknown.
|
||||
`client_graphics_capture_status` is `captured_at_recording_start` only when all
|
||||
three graphics fields are supplied for an integrated server. The server-only
|
||||
command does not inspect client graphics. Old callers retain their compatible
|
||||
four-argument recording entrypoint and report unknown runtime context.
|
||||
|
||||
The offline viewer and CLI flag differing runtime kinds, graphics backends and
|
||||
drivers. Legacy reports remain readable, with unknown-context warnings. A
|
||||
matched start snapshot does not establish unchanged graphics throughout the
|
||||
recording, equivalent client quality, world work or scheduling. Rendering changes
|
||||
still require paired frame reports and an explicitly controlled experiment.
|
||||
This metadata change makes no FPS, TPS or RAM improvement claim.
|
||||
|
||||
```sh
|
||||
python3 tools/build_mod.py
|
||||
python3 tools/test_server_graphics.py --native-display --backend opengl
|
||||
# Separate fresh private instance; Linux software renderer research only:
|
||||
python3 tools/test_server_graphics.py --native-display --backend vulkan
|
||||
```
|
||||
|
||||
The private fixture starts a normal 10-second frame/tick recording through the
|
||||
client recorder, checks both reports against the actual device, saves the demo
|
||||
world and exits. It does not change simulation rate or gameplay rules. Windows
|
||||
compiles the fixture; Linux and hosted macOS check the actual game-selected backend. An explicit
|
||||
`--backend` experiment still rejects fallback; the default metadata check does
|
||||
not require a particular renderer. Full logs,
|
||||
worlds and fixture JARs remain private and outside playable downloads.
|
||||
@@ -31,7 +31,8 @@ public final class HorizonLab implements ModInitializer {
|
||||
.then(Commands.argument("seconds", IntegerArgumentType.integer(10, 600))
|
||||
.executes(command -> {
|
||||
boolean started = startTicks(StringArgumentType.getString(command, "label"),
|
||||
IntegerArgumentType.getInteger(command, "seconds"), Path.of("horizon-benchmarks"), "server");
|
||||
IntegerArgumentType.getInteger(command, "seconds"), Path.of("horizon-benchmarks"), "server",
|
||||
command.getSource().getServer().isDedicatedServer() ? "dedicated" : "integrated", Map.of());
|
||||
command.getSource().sendSuccess(() -> Component.literal(started
|
||||
? "Horizon: recording tick times; run the intended workload now."
|
||||
: "Horizon: a tick recording is already active."), false);
|
||||
@@ -42,10 +43,16 @@ public final class HorizonLab implements ModInitializer {
|
||||
}
|
||||
|
||||
public static synchronized boolean startTicks(String label, int seconds, Path output, String profile) {
|
||||
return startTicks(label, seconds, output, profile, "unknown", Map.of());
|
||||
}
|
||||
|
||||
public static synchronized boolean startTicks(String label, int seconds, Path output, String profile,
|
||||
String runtimeKind, Map<String, ?> clientContext) {
|
||||
if (ticks != null) return false;
|
||||
Map<String, Object> context = dev.horizonlab.metrics.SoftwareContext.capture();
|
||||
context.put("profile", profile);
|
||||
context.put("minecraft", "26.3");
|
||||
context.putAll(dev.horizonlab.metrics.ServerContext.capture(runtimeKind, clientContext));
|
||||
ticks = new Recording(label, "ticks", output, seconds, context);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ public final class HorizonClient implements ClientModInitializer {
|
||||
context.putAll(dev.horizonlab.metrics.SoftwareContext.capture());
|
||||
frames = new Recording(label, "frames", output, seconds, context);
|
||||
previousStart = 0;
|
||||
if (client.getSingleplayerServer() != null) HorizonLab.startTicks(label, seconds, output, profile);
|
||||
if (client.getSingleplayerServer() != null) HorizonLab.startTicks(label, seconds, output, profile, "integrated", context);
|
||||
message("Recording " + seconds + " seconds. Close chat, keep the game focused, and run your route.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package dev.horizonlab.metrics;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/** Copies a recording-start snapshot; never accesses a graphics device on a server thread. */
|
||||
public final class ServerContext {
|
||||
private ServerContext() {}
|
||||
|
||||
public static Map<String, Object> capture(String runtimeKind, Map<String, ?> clientContext) {
|
||||
Map<String, Object> result = new LinkedHashMap<>();
|
||||
String kind = switch (runtimeKind) {
|
||||
case "integrated", "dedicated" -> runtimeKind;
|
||||
default -> "unknown";
|
||||
};
|
||||
result.put("server_runtime_kind", kind);
|
||||
boolean captured = kind.equals("integrated") && clientContext != null;
|
||||
for (String key : new String[]{"gpu", "graphics_backend", "graphics_driver"}) {
|
||||
Object value = clientContext == null ? null : clientContext.get(key);
|
||||
if (!(value instanceof String text) || text.isBlank()) captured = false;
|
||||
}
|
||||
result.put("client_graphics_capture_status", captured ? "captured_at_recording_start" : "not_supplied");
|
||||
if (captured) for (String key : new String[]{"gpu", "graphics_backend", "graphics_driver"})
|
||||
result.put(key, clientContext.get(key));
|
||||
return Map.copyOf(result);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "horizonlab",
|
||||
"version": "0.20.0",
|
||||
"version": "0.21.0",
|
||||
"name": "Horizon Lab",
|
||||
"description": "Client frame pacing and server tick measurements for reproducible optimization experiments.",
|
||||
"authors": [
|
||||
|
||||
@@ -5,6 +5,16 @@ import java.util.Map;
|
||||
|
||||
public final class MetricsTest {
|
||||
public static void main(String[] args) {
|
||||
var sourceContext = new java.util.LinkedHashMap<String, Object>();
|
||||
sourceContext.putAll(Map.of("gpu", "GPU", "graphics_backend", "OpenGL", "graphics_driver", "Driver", "private_path", "secret"));
|
||||
var serverContext = ServerContext.capture("integrated", sourceContext);
|
||||
sourceContext.put("graphics_backend", "Vulkan");
|
||||
check(serverContext.get("graphics_backend").equals("OpenGL"), "graphics snapshot does not track later mutations");
|
||||
check(!serverContext.containsKey("private_path"), "server context only copies graphics allowlist");
|
||||
check(serverContext.get("client_graphics_capture_status").equals("captured_at_recording_start"), "integrated graphics captured");
|
||||
check(!ServerContext.capture("dedicated", sourceContext).containsKey("gpu"), "dedicated server does not claim client graphics");
|
||||
check(ServerContext.capture("integrated", Map.of("gpu", "GPU")).get("client_graphics_capture_status").equals("not_supplied"), "partial graphics snapshot is unavailable");
|
||||
check(ServerContext.capture("unrecognized", Map.of()).get("server_runtime_kind").equals("unknown"), "legacy server kind unknown");
|
||||
SampleStats empty = SampleStats.of(new long[0], 0);
|
||||
check(empty.count() == 0 && empty.meanRate() == 0, "empty recording");
|
||||
SampleStats fixed = SampleStats.of(new long[]{10_000_000, 10_000_000, 10_000_000}, 3);
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
package dev.horizonlab.metrics;
|
||||
|
||||
import com.google.gson.JsonParser;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
||||
import net.minecraft.client.gui.screens.TitleScreen;
|
||||
import net.minecraft.network.chat.contents.TranslatableContents;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.world.level.levelgen.WorldOptions;
|
||||
import net.minecraft.world.level.levelgen.presets.WorldPresets;
|
||||
|
||||
/** Private metadata fixture; ordinary disposable demo, no simulation changes. */
|
||||
public final class ServerGraphicsIntegration implements ClientModInitializer {
|
||||
private boolean opening, finished;
|
||||
private long ready, started;
|
||||
|
||||
@Override public void onInitializeClient() {
|
||||
ClientTickEvents.END_CLIENT_TICK.register(client -> {
|
||||
if (finished || client.gui.overlay() != null) return;
|
||||
if (!opening && client.gui.screen() instanceof TitleScreen screen) {
|
||||
opening = true;
|
||||
client.createWorldOpenFlows().createFreshLevel("Demo_World", MinecraftServer.DEMO_SETTINGS,
|
||||
WorldOptions.DEMO_OPTIONS, WorldPresets::createNormalWorldDimensions, screen);
|
||||
return;
|
||||
}
|
||||
if (client.gui.screen() != null && client.gui.screen().getTitle().getContents() instanceof TranslatableContents title
|
||||
&& title.getKey().equals("demo.help.title")) { client.gui.setScreen(null); return; }
|
||||
if (client.level == null || client.player == null || client.gui.screen() != null || client.isPaused()
|
||||
|| !client.isWindowActive()) { ready = 0; return; }
|
||||
long now = System.nanoTime();
|
||||
if (ready == 0) ready = now;
|
||||
if (started == 0 && now - ready >= 2_000_000_000L) {
|
||||
try {
|
||||
var method = Class.forName("dev.horizonlab.client.HorizonClient").getDeclaredMethod("start", String.class, int.class);
|
||||
method.setAccessible(true);
|
||||
if (!method.invoke(null, "server-graphics-fixture", 10).equals(1)) throw new AssertionError("Recording failed to start");
|
||||
started = now;
|
||||
} catch (ReflectiveOperationException error) { throw new AssertionError("Private recorder start failed", error); }
|
||||
}
|
||||
if (started == 0 || now - started < 14_000_000_000L) return;
|
||||
Path output = client.gameDirectory.toPath().resolve("horizon-benchmarks");
|
||||
try (var paths = Files.list(output)) {
|
||||
var reports = paths.filter(p -> p.toString().endsWith(".json") && p.getFileName().toString().startsWith("server-graphics-fixture-")).toList();
|
||||
if (reports.size() != 2) throw new AssertionError("Expected completed frame and tick reports");
|
||||
var device = RenderSystem.getDevice().getDeviceInfo();
|
||||
var result = new com.google.gson.JsonObject();
|
||||
for (Path path : reports) {
|
||||
var report = JsonParser.parseString(Files.readString(path)).getAsJsonObject();
|
||||
if (!report.get("gpu").getAsString().equals(device.name())
|
||||
|| !report.get("graphics_backend").getAsString().equals(device.backendName())
|
||||
|| !report.get("graphics_driver").getAsString().equals(device.driverInfo()))
|
||||
throw new AssertionError("Report graphics differ from actual device");
|
||||
if (report.get("kind").getAsString().equals("ticks")) {
|
||||
if (!report.get("server_runtime_kind").getAsString().equals("integrated")
|
||||
|| !report.get("client_graphics_capture_status").getAsString().equals("captured_at_recording_start"))
|
||||
throw new AssertionError("Integrated graphics status missing");
|
||||
for (String key : new String[]{"server_runtime_kind", "client_graphics_capture_status", "gpu", "graphics_backend", "graphics_driver"}) result.add(key, report.get(key));
|
||||
}
|
||||
}
|
||||
finished = true;
|
||||
System.out.println("HORIZON_SERVER_GRAPHICS_RESULT " + result);
|
||||
client.stop();
|
||||
} catch (Exception error) { throw new AssertionError("Private server graphics fixture failed", error); }
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
"minecraft": "26.3",
|
||||
"java_major": 25,
|
||||
"fabric_loader": "0.19.5",
|
||||
"pack_version": "0.20.0",
|
||||
"pack_version": "0.21.0",
|
||||
"options_data_version": 5023,
|
||||
"projects": {
|
||||
"sodium": {
|
||||
|
||||
@@ -256,6 +256,26 @@ class ComparisonTests(unittest.TestCase):
|
||||
"stats": {"count": 1000, "meanRate": 100, "lowOnePercentRate": 50,
|
||||
"meanMs": 10, "p95Ms": 15, "p99Ms": 20, "maxMs": 30}}
|
||||
|
||||
def test_integrated_tick_graphics_and_server_kind(self):
|
||||
baseline = self.tick_report()
|
||||
baseline.update(server_runtime_kind="integrated", client_graphics_capture_status="captured_at_recording_start",
|
||||
gpu="GPU", graphics_backend="OpenGL", graphics_driver="Driver")
|
||||
candidate = copy.deepcopy(baseline)
|
||||
candidate["graphics_backend"] = "Vulkan"
|
||||
result = compare_benchmarks.compare(baseline, candidate)
|
||||
self.assertTrue(any("graphics_backend" in item for item in result["mismatches"]))
|
||||
self.assertFalse(any("were not captured" in item for item in compare_benchmarks.server_context_warnings(baseline, candidate)))
|
||||
candidate["server_runtime_kind"] = "dedicated"
|
||||
self.assertTrue(any("server_runtime_kind" in item for item in compare_benchmarks.compare(baseline, candidate)["mismatches"]))
|
||||
|
||||
def test_legacy_and_missing_integrated_graphics_are_unknown(self):
|
||||
legacy = self.tick_report()
|
||||
self.assertTrue(any("runtime kind was not captured" in item for item in compare_benchmarks.server_context_warnings(legacy, legacy)))
|
||||
legacy.update(server_runtime_kind="integrated", client_graphics_capture_status="captured_at_recording_start", gpu="GPU", graphics_backend="OpenGL")
|
||||
self.assertTrue(any("client graphics were not captured" in item for item in compare_benchmarks.server_context_warnings(legacy, legacy)))
|
||||
dedicated = {"server_runtime_kind": "dedicated", "client_graphics_capture_status": "not_supplied"}
|
||||
self.assertFalse(any("were not captured" in item for item in compare_benchmarks.server_context_warnings(dedicated, dedicated)))
|
||||
|
||||
def test_rate_improvement_and_setting_mismatch(self):
|
||||
baseline = self.report()
|
||||
candidate = copy.deepcopy(baseline)
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
</main>
|
||||
<script>
|
||||
'use strict';
|
||||
const SETTINGS=['minecraft','kind','os','os_version','architecture','gpu','graphics_backend','graphics_driver','java_version','heap_max_bytes','framebuffer_width','framebuffer_height','render_distance','simulation_distance','vsync','fps_limit','graphics_preset','ambient_occlusion','improved_transparency','mipmap_levels','entity_distance_scaling','entity_shadows','particles','clouds','cloud_range','fov','world_difficulty','dh_capture_status','dh_rendering_enabled','dh_renderer_mode','dh_lod_radius_chunks','dh_horizontal_quality','dh_vertical_quality','dh_max_horizontal_resolution','dh_transparency','dh_lod_shading','dh_lod_only_mode','dh_camera_quality_dropoff','dh_ambient_occlusion','iris_capture_status','iris_shaders_enabled','iris_shader_pack'];
|
||||
const SETTINGS=['minecraft','kind','os','os_version','architecture','gpu','graphics_backend','graphics_driver','server_runtime_kind','client_graphics_capture_status','java_version','heap_max_bytes','framebuffer_width','framebuffer_height','render_distance','simulation_distance','vsync','fps_limit','graphics_preset','ambient_occlusion','improved_transparency','mipmap_levels','entity_distance_scaling','entity_shadows','particles','clouds','cloud_range','fov','world_difficulty','dh_capture_status','dh_rendering_enabled','dh_renderer_mode','dh_lod_radius_chunks','dh_horizontal_quality','dh_vertical_quality','dh_max_horizontal_resolution','dh_transparency','dh_lod_shading','dh_lod_only_mode','dh_camera_quality_dropoff','dh_ambient_occlusion','iris_capture_status','iris_shaders_enabled','iris_shader_pack'];
|
||||
const state={baseline:null,candidate:null},generation={baseline:0,candidate:0};
|
||||
let comparison=null,chartData=null;
|
||||
const $=id=>document.getElementById(id);
|
||||
@@ -102,6 +102,15 @@ function compareTickStates(a,b){
|
||||
warnings.push('Tick-manager state is sampled after measured server invocations. Changes entirely between samples, paused intervals and completed world work are not verified.');
|
||||
return{differences,warnings};
|
||||
}
|
||||
function serverContextWarnings(a,b){
|
||||
const warnings=[];
|
||||
for(const [label,r] of [['Baseline',a],['Candidate',b]]){
|
||||
if(!['integrated','dedicated'].includes(r.server_runtime_kind))warnings.push(label+' server runtime kind was not captured; integrated/dedicated equivalence is unknown.');
|
||||
if(r.server_runtime_kind==='integrated'&&!(r.client_graphics_capture_status==='captured_at_recording_start'&&['gpu','graphics_backend','graphics_driver'].every(key=>typeof r[key]==='string'&&r[key].trim().length)))warnings.push(label+' integrated-server client graphics were not captured; shared rendering workload is unknown.');
|
||||
}
|
||||
warnings.push('Integrated-server graphics context is a recording-start snapshot; later graphics changes and full client workload equivalence are not verified.');
|
||||
return warnings;
|
||||
}
|
||||
function compareReports(a,b){
|
||||
if(a.kind!==b.kind)throw Error('Compare frame runs with frame runs, or tick runs with tick runs.');
|
||||
const differences=SETTINGS.filter(key=>JSON.stringify(a[key])!==JSON.stringify(b[key])).map(key=>({setting:key,baseline:a[key]??null,candidate:b[key]??null}));
|
||||
@@ -109,6 +118,7 @@ function compareReports(a,b){
|
||||
const warnings=['World, camera route, shaders and terrain-cache warm-up still need to match. These are not verified by the captured settings.'];
|
||||
warnings.push(...softwareWarnings(a,b));
|
||||
if(a.kind==='ticks'){
|
||||
warnings.push(...serverContextWarnings(a,b));
|
||||
const tick=compareTickStates(a,b);differences.push(...tick.differences);warnings.push(...tick.warnings);
|
||||
}
|
||||
for(const key of ['compact_object_headers','garbage_collectors']){
|
||||
@@ -166,6 +176,8 @@ function renderDetails(side){
|
||||
fields.push(['JVM', 'Compact headers: '+(r.compact_object_headers===true?'on':r.compact_object_headers===false?'off':'not captured')+' · GC: '+(Array.isArray(r.garbage_collectors)?r.garbage_collectors.join(', '):'not captured')]);
|
||||
fields.push(['Java',[r.java_vendor,r.java_vm_name,r.java_runtime_version||r.java_version].filter(Boolean).join(' · ')||'Not captured']);
|
||||
if(r.kind==='ticks'){
|
||||
fields.push(['Server runtime',['integrated','dedicated'].includes(r.server_runtime_kind)?r.server_runtime_kind:'Not captured']);
|
||||
if(r.server_runtime_kind==='integrated')fields.push(['Shared client graphics',r.client_graphics_capture_status==='captured_at_recording_start'?[r.gpu,r.graphics_backend,r.graphics_driver].filter(Boolean).join(' · ')+' (at recording start)':'Not captured']);
|
||||
if(tickStateAvailable(r)){
|
||||
const first=r.tick_state_first,last=r.tick_state_last;
|
||||
fields.push(['Configured ticks',format(first.configured_tick_rate)+' / s at first sample · '+format(last.configured_tick_rate)+' / s at last sample']);
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ def test_metrics():
|
||||
destination = BUILD / "metric-tests"
|
||||
destination.mkdir(parents=True, exist_ok=True)
|
||||
sources = [SOURCE / "main/java/dev/horizonlab/metrics" / name
|
||||
for name in ["SampleStats.java", "Recording.java", "ProcessMemoryMonitor.java", "TickState.java"]]
|
||||
for name in ["SampleStats.java", "Recording.java", "ProcessMemoryMonitor.java", "TickState.java", "ServerContext.java"]]
|
||||
sources.append(SOURCE / "test/java/dev/horizonlab/metrics/MetricsTest.java")
|
||||
subprocess.run(["javac", "--release", "25", "-d", str(destination), *map(str, sources)], check=True)
|
||||
subprocess.run(["java", "-cp", str(destination), "dev.horizonlab.metrics.MetricsTest"], check=True)
|
||||
|
||||
@@ -7,7 +7,7 @@ import math
|
||||
from pathlib import Path
|
||||
|
||||
MATCH_FIELDS = ("minecraft", "kind", "os", "os_version", "architecture", "gpu", "graphics_backend", "graphics_driver",
|
||||
"java_version", "heap_max_bytes", "framebuffer_width", "framebuffer_height", "render_distance",
|
||||
"server_runtime_kind", "client_graphics_capture_status", "java_version", "heap_max_bytes", "framebuffer_width", "framebuffer_height", "render_distance",
|
||||
"simulation_distance", "vsync", "fps_limit", "graphics_preset", "ambient_occlusion",
|
||||
"improved_transparency", "mipmap_levels", "entity_distance_scaling", "entity_shadows", "particles",
|
||||
"clouds", "cloud_range", "fov", "world_difficulty", "dh_capture_status", "dh_rendering_enabled", "dh_renderer_mode",
|
||||
@@ -92,6 +92,21 @@ def software_warnings(baseline, candidate):
|
||||
return warnings
|
||||
|
||||
|
||||
def server_context_warnings(baseline, candidate):
|
||||
warnings = []
|
||||
for name, report in [("baseline", baseline), ("candidate", candidate)]:
|
||||
kind = report.get("server_runtime_kind")
|
||||
if kind not in ["integrated", "dedicated"]:
|
||||
warnings.append(f"{name} server runtime kind was not captured; integrated/dedicated equivalence is unknown.")
|
||||
if kind == "integrated":
|
||||
captured = report.get("client_graphics_capture_status") == "captured_at_recording_start" and all(
|
||||
isinstance(report.get(key), str) and report[key].strip() for key in ["gpu", "graphics_backend", "graphics_driver"])
|
||||
if not captured:
|
||||
warnings.append(f"{name} integrated-server client graphics were not captured; shared rendering workload is unknown.")
|
||||
warnings.append("Integrated-server graphics context is a recording-start snapshot; later graphics changes and full client workload equivalence are not verified.")
|
||||
return warnings
|
||||
|
||||
|
||||
def compare(baseline, candidate):
|
||||
for report in [baseline, candidate]:
|
||||
if report.get("schema") != 1 or report.get("kind") not in ["frames", "ticks"]:
|
||||
@@ -105,6 +120,7 @@ def compare(baseline, candidate):
|
||||
warnings = ["World, route, warm-up, shader state and LOD cache must also match; these are not verified by this tool."]
|
||||
warnings.extend(software_warnings(baseline, candidate))
|
||||
if baseline["kind"] == "ticks":
|
||||
warnings.extend(server_context_warnings(baseline, candidate))
|
||||
tick_mismatches, tick_warnings = compare_tick_states(baseline, candidate)
|
||||
mismatches.extend(tick_mismatches)
|
||||
warnings.extend(tick_warnings)
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Check recording-start graphics context in a real integrated-server report."""
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import platform
|
||||
import shutil
|
||||
import sys
|
||||
|
||||
try:
|
||||
from . import build_mod, build_pack
|
||||
from .test_culling_rays import run_fixture
|
||||
except ImportError:
|
||||
import build_mod, build_pack
|
||||
from test_culling_rays import run_fixture
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--native-display', action='store_true')
|
||||
parser.add_argument('--backend', choices=['opengl', 'vulkan'], help='Require this observed backend; default accepts the game-selected backend')
|
||||
args = parser.parse_args()
|
||||
root = build_pack.ROOT
|
||||
fixture = build_mod.build_integration_fixture('server-graphics',
|
||||
'dev.horizonlab.metrics.ServerGraphicsIntegration', fixture_dependencies={})
|
||||
version = build_pack.read_lock()['pack_version']
|
||||
mod = root / 'dist' / f'horizon-lab-{version}.jar'
|
||||
digest = hashlib.sha256(mod.read_bytes()).hexdigest()
|
||||
instance = root / '.local/runtime' / ('server-graphics-' + (args.backend or 'default'))
|
||||
if instance.exists():
|
||||
raise RuntimeError('Use a fresh private fixture directory; existing worlds and reports are not overwritten')
|
||||
build_pack.prepare_instance('core-performance', instance, mod)
|
||||
if args.backend:
|
||||
options = instance / 'options.txt'
|
||||
import re
|
||||
text, count = re.subn(r'^preferredGraphicsBackend:.*$', 'preferredGraphicsBackend:' + json.dumps(args.backend), options.read_text(), flags=re.MULTILINE)
|
||||
if count != 1:
|
||||
raise AssertionError('Expected one backend preference')
|
||||
options.write_text(text)
|
||||
if hashlib.sha256((instance / 'mods' / mod.name).read_bytes()).hexdigest() != digest:
|
||||
raise AssertionError('Runtime mod differs from intended build')
|
||||
shutil.copy2(fixture, instance / 'mods/server-graphics-fixture.jar')
|
||||
command = [sys.executable, str(root / 'tools/runtime.py'), 'demo', '--instance', str(instance), '--heap', '3G', '--compact-headers']
|
||||
if platform.system() == 'Linux' and not args.native_display:
|
||||
command = ['xvfb-run', '-a', *command]
|
||||
run = run_fixture(command, instance, os.environ.copy())
|
||||
marker = 'HORIZON_SERVER_GRAPHICS_RESULT '
|
||||
results = [json.loads(line.split(marker, 1)[1]) for line in run.stdout.splitlines() if marker in line]
|
||||
if run.returncode or len(results) != 1:
|
||||
raise RuntimeError('Integrated-server graphics fixture failed; inspect its private runtime log')
|
||||
result = results[0]
|
||||
if result.get('server_runtime_kind') != 'integrated' or result.get('client_graphics_capture_status') != 'captured_at_recording_start':
|
||||
raise AssertionError('Integrated graphics were not captured')
|
||||
if args.backend and result.get('graphics_backend', '').lower() != args.backend:
|
||||
raise AssertionError('Observed graphics backend differs from the requested experiment')
|
||||
if not (instance / 'saves/Demo_World/level.dat').is_file():
|
||||
raise AssertionError('Disposable world was not saved')
|
||||
report = {'schema': 1, 'platform': platform.platform(), 'architecture': platform.machine(),
|
||||
'minecraft': '26.3', 'original_mod_sha256': digest, 'launcher_exit_code': run.returncode,
|
||||
'requested_backend': args.backend or 'pack_default', 'result': result, 'limits': ['Short report-context check, not FPS or physical M2 performance.',
|
||||
'Graphics context is captured at recording start, not continuously monitored.',
|
||||
'World files and full logs remain private.']}
|
||||
output = root / 'dist/server-graphics-smoke.json'
|
||||
output.write_text(json.dumps(report, indent=2) + '\n')
|
||||
print(json.dumps(report), flush=True)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user