Merge pull request #33 from ludovic111/integrated-tick-context
Capture shared graphics context in integrated-server tick reports
This commit is contained in:
@@ -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