feat(perf): OGLPerformance 1.2 advanced ROBUST node diagnostics (#424)

* feat(perf): bounded Linux host per-core CPU measurement in opt-in sampler

* feat(perf): shared read-only asset cache metrics interface

* feat(perf): read-only Flotsam cache hit, LRU, writer and byte-budget snapshot

* feat(perf): attach read-only asset cache diagnostics to signed heartbeat

* feat(perf): bounded per-region and Linux host-core telemetry projection

* feat(perf): read-only API projection of regional frame and host core diagnostics

* feat(perf): ROBUST diagnostic panel, curves, core meters, region and asset cache views

* feat(perf): browser-session trend charts, Linux core meters, per-region frame table and Flotsam analytics

* fix(perf): keep missing heap and allocation telemetry as gaps, not zero

* test(perf): Linux host CPU parser and bounded per-core sampling

* test(perf): node registry parses bounded signed host, region and asset samples

* feat(perf): bound telemetry to 64 regions so 42-region nodes are fully represented

* feat(perf): bound telemetry to 64 regions so 42-region nodes are fully represented

* feat(perf): bound telemetry to 64 regions so 42-region nodes are fully represented

* test(perf): read-only Flotsam cache diagnostic interface

* docs(perf): operator guide for bounded CPU/core, region, GC and asset diagnostics

* test(perf): retain all 42 regions with expanded bounded heartbeat cap

* feat(perf): reboot-aware browser trends and Flotsam cache hit ratios

* fix(perf): account for host cores omitted and document 64-region telemetry cap

* fix(perf): account for host cores omitted and document 64-region telemetry cap
This commit is contained in:
OpenGenesis (MPL 2.0) authored and GitHub committed 2026-11-10 21:30:13 +01:00
1 parent af7483ac61
commit 73cf90eb30
12 files changed
+741 -9

No files matched your search

+161 -3
View File
@@ -42,6 +42,25 @@ namespace NexVerse.Core.ControlPlane
public DateTimeOffset LastSeen { get; }
}
public sealed class NexRegionPerformanceSnapshot
{
public string RegionId { get; init; } = string.Empty;
public double HeartbeatHz { get; init; }
public double TargetHz { get; init; }
public long WindowFrames { get; init; }
public double WorkP95Ms { get; init; }
public double FrameP95Ms { get; init; }
public double FrameP99Ms { get; init; }
public double WorkOverBudgetPercent { get; init; }
public double FrameOverBudgetPercent { get; init; }
}
public sealed class NexHostCpuCoreSnapshot
{
public int CoreId { get; init; }
public double UsagePercent { get; init; }
}
public sealed class NexNodeSnapshot
{
public NexNodeSnapshot(
@@ -77,7 +96,9 @@ namespace NexVerse.Core.ControlPlane
string updateOperationId = "",
DateTimeOffset? updateAt = null,
int npcCount = 0,
IReadOnlyDictionary<string, double> performanceMetrics = null)
IReadOnlyDictionary<string, double> performanceMetrics = null,
IReadOnlyList<NexRegionPerformanceSnapshot> regionPerformance = null,
IReadOnlyList<NexHostCpuCoreSnapshot> hostCpuCores = null)
{
NpcCount = Math.Clamp(npcCount, 0, Math.Max(0, agentCount));
NodeId = nodeId ?? string.Empty;
@@ -115,6 +136,8 @@ namespace NexVerse.Core.ControlPlane
UpdateOperationId = updateOperationId ?? string.Empty;
UpdateAt = updateAt;
PerformanceMetrics = performanceMetrics ?? new Dictionary<string, double>(StringComparer.Ordinal);
RegionPerformance = regionPerformance ?? Array.Empty<NexRegionPerformanceSnapshot>();
HostCpuCores = hostCpuCores ?? Array.Empty<NexHostCpuCoreSnapshot>();
}
public string NodeId { get; }
@@ -151,6 +174,8 @@ namespace NexVerse.Core.ControlPlane
public DateTimeOffset? UpdateAt { get; }
// Only allowlisted, validated read-only process metrics from signed NodeAgent heartbeats.
public IReadOnlyDictionary<string, double> PerformanceMetrics { get; }
public IReadOnlyList<NexRegionPerformanceSnapshot> RegionPerformance { get; }
public IReadOnlyList<NexHostCpuCoreSnapshot> HostCpuCores { get; }
}
/// <summary>
@@ -177,7 +202,24 @@ namespace NexVerse.Core.ControlPlane
"perf_threadpool_pending_items",
"perf_threadpool_busy_workers",
"perf_region_sample_count",
"perf_region_sample_omitted"
"perf_region_sample_omitted",
"perf_host_cpu_cores_omitted",
"perf_asset_requests",
"perf_asset_memory_hits",
"perf_asset_disk_hits",
"perf_asset_weak_hits",
"perf_asset_memory_enabled",
"perf_asset_ram_entries",
"perf_asset_ram_bytes",
"perf_asset_ram_limit_bytes",
"perf_asset_memory_trims",
"perf_asset_file_writers",
"perf_asset_writer_target",
"perf_asset_writer_active",
"perf_asset_writer_pending_jobs",
"perf_asset_writes_rejected",
"perf_asset_inflight_bytes",
"perf_asset_inflight_limit_bytes"
};
private readonly ConcurrentDictionary<string, NodeRecord> m_Nodes =
@@ -469,6 +511,12 @@ namespace NexVerse.Core.ControlPlane
regionsRaw,
receivedAt);
}
// Signed opt-in telemetry is a replacement snapshot, never an
// append-only history. Bound the decoded arrays and input size.
record.RegionPerformance = ParseRegionPerformance(
nexEvent, record.Regions);
record.HostCpuCores = ParseHostCpuCores(nexEvent);
}
}
@@ -764,7 +812,9 @@ namespace NexVerse.Core.ControlPlane
record.UpdateOperationId,
record.UpdateAt,
record.NpcCount,
new Dictionary<string, double>(record.PerformanceMetrics, StringComparer.Ordinal));
new Dictionary<string, double>(record.PerformanceMetrics, StringComparer.Ordinal),
record.RegionPerformance.ToArray(),
record.HostCpuCores.ToArray());
}
}
@@ -780,6 +830,110 @@ namespace NexVerse.Core.ControlPlane
};
}
private static bool TryFinite(JsonElement item, string name,
double max, out double value)
{
value = 0;
if (item.ValueKind != JsonValueKind.Object ||
!item.TryGetProperty(name, out JsonElement e) ||
e.ValueKind != JsonValueKind.Number ||
!e.TryGetDouble(out double parsed) ||
!double.IsFinite(parsed) || parsed < 0 || parsed > max)
return false;
value = parsed;
return true;
}
private static NexRegionPerformanceSnapshot[] ParseRegionPerformance(
NexEvent nexEvent, Dictionary<string, RegionRecord> liveRegions)
{
if (!TryData(nexEvent, "perf_region_heartbeats_json", out string json) ||
json.Length > 49152)
return Array.Empty<NexRegionPerformanceSnapshot>();
try
{
using JsonDocument doc = JsonDocument.Parse(json,
new JsonDocumentOptions { MaxDepth = 8 });
if (doc.RootElement.ValueKind != JsonValueKind.Array ||
doc.RootElement.GetArrayLength() > 64)
return Array.Empty<NexRegionPerformanceSnapshot>();
var result = new List<NexRegionPerformanceSnapshot>();
var seen = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
foreach (JsonElement entry in doc.RootElement.EnumerateArray())
{
if (entry.ValueKind != JsonValueKind.Object ||
!entry.TryGetProperty("region_id", out JsonElement id) ||
id.ValueKind != JsonValueKind.String)
continue;
string regionId = id.GetString();
if (regionId == null || !Guid.TryParse(regionId, out Guid uuid))
continue;
regionId = uuid.ToString("D");
if (!liveRegions.ContainsKey(regionId) || !seen.Add(regionId))
continue;
if (!TryFinite(entry, "heartbeat_hz", 1000, out double heartbeat) ||
!TryFinite(entry, "target_hz", 1000, out double target) ||
!TryFinite(entry, "window_frames", 1e8, out double frames) ||
!TryFinite(entry, "work_p95_ms", 60000, out double workP95) ||
!TryFinite(entry, "frame_p95_ms", 60000, out double frameP95) ||
!TryFinite(entry, "frame_p99_ms", 60000, out double frameP99) ||
!TryFinite(entry, "work_over_budget_percent", 100, out double workOver) ||
!TryFinite(entry, "frame_over_budget_percent", 100, out double frameOver))
continue;
result.Add(new NexRegionPerformanceSnapshot
{
RegionId = regionId,
HeartbeatHz = heartbeat,
TargetHz = target,
WindowFrames = (long)frames,
WorkP95Ms = workP95,
FrameP95Ms = frameP95,
FrameP99Ms = frameP99,
WorkOverBudgetPercent = workOver,
FrameOverBudgetPercent = frameOver
});
}
return result.ToArray();
}
catch (JsonException)
{
return Array.Empty<NexRegionPerformanceSnapshot>();
}
}
private static NexHostCpuCoreSnapshot[] ParseHostCpuCores(NexEvent nexEvent)
{
if (!TryData(nexEvent, "perf_host_cpu_cores_json", out string json) ||
json.Length > 12288)
return Array.Empty<NexHostCpuCoreSnapshot>();
try
{
using JsonDocument doc = JsonDocument.Parse(json,
new JsonDocumentOptions { MaxDepth = 6 });
if (doc.RootElement.ValueKind != JsonValueKind.Array ||
doc.RootElement.GetArrayLength() > 128)
return Array.Empty<NexHostCpuCoreSnapshot>();
var result = new List<NexHostCpuCoreSnapshot>();
var seen = new HashSet<int>();
foreach (JsonElement item in doc.RootElement.EnumerateArray())
{
if (!TryFinite(item, "core_id", 4095, out double idValue) ||
Math.Truncate(idValue) != idValue ||
!TryFinite(item, "usage_percent", 100, out double load))
continue;
int core = (int)idValue;
if (seen.Add(core))
result.Add(new NexHostCpuCoreSnapshot
{ CoreId = core, UsagePercent = load });
}
return result.OrderBy(x => x.CoreId).ToArray();
}
catch (JsonException)
{
return Array.Empty<NexHostCpuCoreSnapshot>();
}
}
private static bool TryData(
NexEvent nexEvent,
string key,
@@ -1075,6 +1229,10 @@ namespace NexVerse.Core.ControlPlane
new Dictionary<string, double>(StringComparer.Ordinal);
public DateTimeOffset LastSeen;
public DateTimeOffset LastEventAt;
public NexRegionPerformanceSnapshot[] RegionPerformance =
Array.Empty<NexRegionPerformanceSnapshot>();
public NexHostCpuCoreSnapshot[] HostCpuCores =
Array.Empty<NexHostCpuCoreSnapshot>();
public Dictionary<string, RegionRecord> Regions { get; } =
new Dictionary<string, RegionRecord>(
@@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text.Json;
using System.Threading;
@@ -46,7 +47,9 @@ namespace NexVerse.Core.Observability
public sealed class OglPerformanceSampler
{
private const int MaximumReportedRegions = 32;
private const int MaximumReportedRegions = 64;
private const int MaximumReportedHostCores = 128;
private readonly Dictionary<int, (long Total, long Idle)> m_PreviousHostCores = new();
private readonly object m_Sync = new object();
private readonly Dictionary<string, RegionPosition> m_PreviousRegions =
new Dictionary<string, RegionPosition>(StringComparer.Ordinal);
@@ -86,6 +89,55 @@ namespace NexVerse.Core.Observability
return unchecked(current - previous) / wallDeltaSeconds;
}
// Aggregate /proc/stat counters per host CPU. Ignore guest and guest_nice:
// Linux already includes them in user/nice counters.
// Static parser is independently regression-testable without /proc access.
public static IReadOnlyDictionary<int, (long Total, long Idle)> ParseLinuxHostCpu(
IEnumerable<string> lines, int maximumCores = MaximumReportedHostCores)
{
Dictionary<int, (long Total, long Idle)> result = new();
if (lines == null || maximumCores < 1)
return result;
foreach (string line in lines)
{
if (result.Count >= Math.Min(4096, maximumCores)) break;
string[] parts = (line ?? "").Split((char[])null,
StringSplitOptions.RemoveEmptyEntries);
if (parts.Length < 5 || !parts[0].StartsWith("cpu", StringComparison.Ordinal) ||
!int.TryParse(parts[0].AsSpan(3), NumberStyles.None,
CultureInfo.InvariantCulture, out int index) ||
index < 0 || index > 4095)
continue;
long total = 0;
long idle = 0;
bool valid = true;
for (int j = 1; j < Math.Min(parts.Length, 9); ++j)
{
if (!long.TryParse(parts[j], NumberStyles.None,
CultureInfo.InvariantCulture, out long ticks) ||
ticks < 0 || total > long.MaxValue - ticks)
{
valid = false; break;
}
total += ticks;
if (j == 4 || j == 5)
idle += ticks;
}
if (valid && total > 0)
result[index] = (total, idle);
}
return result;
}
private static Dictionary<int, (long Total, long Idle)> ReadLinuxHostCoreCounters()
{
var result = new Dictionary<int, (long Total, long Idle)>();
foreach (var pair in ParseLinuxHostCpu(File.ReadLines("/proc/stat"),
4096))
result[pair.Key] = pair.Value;
return result;
}
public IReadOnlyDictionary<string, string> Capture(IReadOnlyList<OglRegionFrame> regions)
{
lock (m_Sync)
@@ -172,6 +224,44 @@ namespace NexVerse.Core.Observability
if (!active.Contains(id))
m_PreviousRegions.Remove(id);
// Linux /proc/stat reports host-wide core load, NOT per-core OpenSim
// process attribution. Keep this optional and capped.
if (OperatingSystem.IsLinux())
{
try
{
Dictionary<int, (long Total, long Idle)> samples = ReadLinuxHostCoreCounters();
var coreStats = new List<object>();
foreach (var core in samples.OrderBy(x => x.Key))
{
if (coreStats.Count >= MaximumReportedHostCores)
break;
if (m_PreviousHostCores.TryGetValue(core.Key, out var prior))
{
long elapsed = core.Value.Total - prior.Total;
long idle = core.Value.Idle - prior.Idle;
if (elapsed > 0 && idle >= 0 && idle <= elapsed)
{
coreStats.Add(new
{
core_id = core.Key,
usage_percent = Math.Round(
Math.Clamp(100.0 * (elapsed - idle) / elapsed, 0, 100), 2)
});
}
}
}
m_PreviousHostCores.Clear();
foreach (var item in samples)
m_PreviousHostCores[item.Key] = item.Value;
data["perf_host_cpu_cores_json"] = JsonSerializer.Serialize(coreStats);
data["perf_host_cpu_cores_omitted"] = Math.Max(0, samples.Count - MaximumReportedHostCores)
.ToString(CultureInfo.InvariantCulture);
}
catch (IOException) { m_PreviousHostCores.Clear(); }
catch (UnauthorizedAccessException) { m_PreviousHostCores.Clear(); }
}
data["perf_region_heartbeats_json"] = JsonSerializer.Serialize(regionStats);
data["perf_region_sample_count"] = regionStats.Count.ToString(CultureInfo.InvariantCulture);
data["perf_region_sample_omitted"] = Math.Max(0, active.Count - regionStats.Count)
@@ -1512,6 +1512,17 @@ namespace NexVerse.RegionModules.NodeAgent
.ToArray();
foreach (KeyValuePair<string, string> sample in m_PerformanceSampler.Capture(frames))
data[sample.Key] = sample.Value;
// The active shared cache is discovered through its existing
// region interface; NodeAgent remains decoupled from Flotsam.
if (scenes.Length > 0 &&
scenes[0].RequestModuleInterface<IAssetCache>()
is IOglAssetCacheMetricsProvider assetMetrics)
{
foreach (KeyValuePair<string, long> metric in assetMetrics.CaptureAssetCacheMetrics())
data[metric.Key] = metric.Value.ToString(
System.Globalization.CultureInfo.InvariantCulture);
}
}
catch (Exception error)
{
+225 -2
View File
@@ -87,7 +87,19 @@ input,textarea,select{width:100%;background:#08131e;color:var(--text);border:1px
.empty{color:var(--muted);padding:18px;border:1px dashed var(--line);border-radius:9px;text-align:center}
.portalgrid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:14px}.portalcard{border:1px solid var(--line);background:#0b1621;border-radius:11px;padding:18px}.portalcard h3{margin:0 0 7px;font-size:17px}.portalcard p{margin:0 0 12px;color:var(--muted)}.portalactions{display:flex;gap:8px;flex-wrap:wrap}.actionlink{display:inline-block;text-decoration:none;flex:0 0 auto}.portalmeta{margin-top:12px;color:var(--muted);font-size:12px}
.tablewrap{overflow:auto;border:1px solid var(--line);border-radius:9px}.datatable{width:100%;border-collapse:collapse;min-width:720px}.datatable th,.datatable td{padding:10px 12px;text-align:left;border-bottom:1px solid var(--line);white-space:nowrap}.datatable th{font-size:12px;color:var(--muted);background:#0a1520}.datatable tr:last-child td{border-bottom:0}.datatable td:first-child{font-weight:600}.authnote{margin-top:10px;color:var(--muted);font-size:12px}
.planner-controls{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px}.planner-actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:12px}.planner-actions .action{flex:0 0 auto}.gridlegend{display:flex;gap:8px;flex-wrap:wrap;margin:10px 0}.legenditem{display:inline-flex;gap:6px;align-items:center;color:var(--muted);font-size:12px}.legendswatch{width:13px;height:13px;border-radius:3px;border:1px solid var(--line)}.gridboardwrap{overflow:auto;max-height:680px;border:1px solid var(--line);border-radius:10px;background:#06101a;padding:12px}.gridboard{--cell:30px;display:grid;gap:2px;width:max-content;min-width:100%}.gridcell{width:var(--cell);height:var(--cell);min-width:var(--cell);padding:0;border:1px solid #22384b;border-radius:3px;background:#0c1a26;color:transparent;position:relative}.gridcell:hover{outline:2px solid var(--accent);z-index:2}.gridcell.free{background:#123326}.gridcell.occupied{background:#1d4c6a}.gridcell.reserved{background:#5a461c}.gridcell.conflict{background:#6a2323}.gridcell.selected{outline:2px solid #fff;z-index:3}.gridcell.preview-ok{box-shadow:inset 0 0 0 2px var(--good)}.gridcell.preview-bad{box-shadow:inset 0 0 0 2px var(--danger)}.gridcell.dimmed{opacity:.22}.gridcell[data-region-name]:after{content:'';position:absolute;inset:35%;border-radius:50%;background:rgba(255,255,255,.72)}.gridinfo{display:grid;grid-template-columns:1fr 1fr;gap:12px}.gridinfo pre{margin:0;min-height:150px}.gridcoord{font-family:ui-monospace,SFMono-Regular,Menlo,monospace}.planner-note{padding:10px 12px;border:1px solid var(--line);border-radius:8px;background:#0a1520;color:var(--muted);font-size:12px}.noderow{cursor:pointer}.noderow:hover{background:var(--panel2)}.node-state-online{color:var(--good)}.node-state-stale{color:var(--warn)}.node-state-offline{color:var(--danger)}.node-update-status{display:block;font-size:11px;margin-top:6px;white-space:normal;max-width:230px;color:var(--muted)}.node-update-status.good{color:var(--good)}.node-update-status.bad{color:var(--danger)}.node-update-status.warn{color:var(--warn)}
.planner-controls{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px}.planner-actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:12px}.planner-actions .action{flex:0 0 auto}.gridlegend{display:flex;gap:8px;flex-wrap:wrap;margin:10px 0}.legenditem{display:inline-flex;gap:6px;align-items:center;color:var(--muted);font-size:12px}.legendswatch{width:13px;height:13px;border-radius:3px;border:1px solid var(--line)}.gridboardwrap{overflow:auto;max-height:680px;border:1px solid var(--line);border-radius:10px;background:#06101a;padding:12px}.gridboard{--cell:30px;display:grid;gap:2px;width:max-content;min-width:100%}.gridcell{width:var(--cell);height:var(--cell);min-width:var(--cell);padding:0;border:1px solid #22384b;border-radius:3px;background:#0c1a26;color:transparent;position:relative}.gridcell:hover{outline:2px solid var(--accent);z-index:2}.gridcell.free{background:#123326}.gridcell.occupied{background:#1d4c6a}.gridcell.reserved{background:#5a461c}.gridcell.conflict{background:#6a2323}.gridcell.selected{outline:2px solid #fff;z-index:3}.gridcell.preview-ok{box-shadow:inset 0 0 0 2px var(--good)}.gridcell.preview-bad{box-shadow:inset 0 0 0 2px var(--danger)}.gridcell.dimmed{opacity:.22}.gridcell[data-region-name]:after{content:'';position:absolute;inset:35%;border-radius:50%;background:rgba(255,255,255,.72)}.gridinfo{display:grid;grid-template-columns:1fr 1fr;gap:12px}.gridinfo pre{margin:0;min-height:150px}.gridcoord{font-family:ui-monospace,SFMono-Regular,Menlo,monospace}.planner-note{padding:10px 12px;border:1px solid var(--line);border-radius:8px;background:#0a1520;color:var(--muted);font-size:12px}.noderow{cursor:pointer}.noderow:hover{background:var(--panel2)}.node-state-online{color:var(--good)}.node-state-stale{color:var(--warn)}.node-state-offline{color:var(--danger)}
.ogl-perf-chart{width:100%;height:148px;display:block;background:var(--panel2);border:1px solid var(--line);border-radius:8px}
.ogl-perf-stat{padding:12px;background:var(--panel2);border:1px solid var(--line);border-radius:9px;min-width:0}
.ogl-perf-stat strong{display:block;font-size:21px;padding:6px 0}
.ogl-perf-cpus{display:grid;grid-template-columns:repeat(auto-fill,minmax(114px,1fr));gap:8px;max-height:250px;overflow:auto;margin:12px 0}
.ogl-perf-core{border:1px solid var(--line);border-radius:7px;padding:7px;background:var(--panel2);font-size:12px}
.ogl-perf-core .meter{height:7px;margin-top:6px;background:var(--line);border-radius:5px;overflow:hidden}
.ogl-perf-core .fill{height:7px;background:var(--good);border-radius:5px}
.ogl-perf-core .fill.hot{background:var(--danger)}
.ogl-perf-plots{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
.ogl-perf-plots>div{min-width:0}
@media(max-width:820px){.ogl-perf-plots{grid-template-columns:1fr}}
.node-update-status{display:block;font-size:11px;margin-top:6px;white-space:normal;max-width:230px;color:var(--muted)}.node-update-status.good{color:var(--good)}.node-update-status.bad{color:var(--danger)}.node-update-status.warn{color:var(--warn)}
@media(max-width:1100px){.cards,.roadmap-summary{grid-template-columns:repeat(2,1fr)}.changegrid{grid-template-columns:1fr}.explorer{grid-template-columns:1fr}.endpointlist{max-height:420px;overflow:auto}.planner-controls{grid-template-columns:repeat(2,1fr)}}
@media(max-width:760px){.portalgrid{grid-template-columns:1fr}.shell{display:block}nav{position:static;height:auto;border-right:0;border-bottom:1px solid var(--line)}.navmeta{display:none}.navbtn{display:inline-block;width:auto}.brand{padding-bottom:12px}main{padding:22px 14px}.hero{display:block}.hero .pill{margin-top:14px}.cards,.roadmap-summary{grid-template-columns:1fr}.grid2,.version,.gridinfo{grid-template-columns:1fr}.planner-controls{grid-template-columns:1fr 1fr}.milestonehead{display:block}.milestonehead .status{margin-top:8px}}
@@ -861,6 +873,32 @@ body.ogl-sidebar-collapsed .ogl-admin-header,body.ogl-sidebar-collapsed main{gri
<div class="section">
<h2>Node-Details</h2><div class="authnote">„Update“ sichert die INIs, setzt Git auf origin/main zurück, kompiliert mit .NET 10 und entfernt die alte NexVerse-Deutschland.ini. Die Node wird NICHT automatisch neugestartet. Die Aktion verändert den produktiven Checkout. Vorher Backup und Wartungsfenster einplanen.</div><p role="status" aria-live="polite" id="nodesUpdateInfo">Kein Update beauftragt.</p><pre id="nodeDetail">Noch kein Node ausgewählt.</pre>
</div>
<div class="section" id="oglPerformanceDetails">
<h2>OGLPerformance · CPU, RAM, GC und Regionen</h2>
<p class="sectionlead" id="oglPerfSelected">Wähle einen Simulator in der Node-Tabelle, um die Diagnose anzuzeigen.</p>
<div class="cards">
<div class="card"><div class="label">Prozess-CPU</div><div class="value" id="oglPerfCpu">–</div><div class="sub">Alle verfügbaren Kerne gemittelt</div></div>
<div class="card"><div class="label">RAM-Working-Set</div><div class="value" id="oglPerfRam">–</div><div class="sub">Speicher des Simulatorprozesses</div></div>
<div class="card"><div class="label">GC-Fragmentierung</div><div class="value" id="oglPerfFragmented">–</div><div class="sub">Managed GC Heap</div></div>
<div class="card"><div class="label">GC-Pause</div><div class="value" id="oglPerfGc">–</div><div class="sub">Anteil des Messintervalls</div></div>
</div>
<p class="authnote">Die Verlaufskurven werden ausschließlich während dieser geöffneten Browser-Sitzung gesammelt (maximal 120 Messpunkte pro Node). Sie sind kein serverseitig gespeichertes Langzeitmonitoring. Fehlende Werte werden nicht als Null interpretiert.</p>
<div class="ogl-perf-plots">
<div><h3>CPU · Prozess (%)</h3><canvas class="ogl-perf-chart" id="oglPerfChartCpu" width="720" height="148" role="img" aria-label="Verlauf Prozess CPU"></canvas></div>
<div><h3>RAM · Working Set und Heap (GiB)</h3><canvas class="ogl-perf-chart" id="oglPerfChartRam" width="720" height="148" role="img" aria-label="Verlauf RAM Working Set und Managed Heap"></canvas></div>
<div><h3>GC-Pausen (%)</h3><canvas class="ogl-perf-chart" id="oglPerfChartGc" width="720" height="148" role="img" aria-label="Verlauf Garbage Collector Pausen"></canvas></div>
<div><h3>Allokationsrate (MiB/s)</h3><canvas class="ogl-perf-chart" id="oglPerfChartAlloc" width="720" height="148" role="img" aria-label="Verlauf .NET Allokationsrate"></canvas></div>
</div>
<h3>Linux-Host · CPU pro logischem Kern</h3>
<p class="sectionlead" id="oglPerfHostInfo">Host-Kernlast noch nicht verfügbar. Dies ist keine Zuordnung der OpenSim-Threads zu einem Kern; auf Windows kann diese Linux-Messung fehlen.</p>
<div class="ogl-perf-cpus" id="oglPerfHostCores"></div>
<h3>Regionen · Frame-Laufzeit und tatsächliche Heartbeats</h3>
<p class="sectionlead" id="oglPerfRegionInfo">Nur Regionen mit aktivierter OGLPerformance-Telemetrie, begrenzt auf 64 Messwerte je Heartbeat.</p>
<div class="tablewrap"><table class="datatable"><thead><tr><th>Region</th><th>Heartbeat</th><th>Ziel</th><th>Frames</th><th>Work P95</th><th>Frame P95</th><th>Frame P99</th><th>Work über Budget</th><th>Frame über Budget</th></tr></thead><tbody id="oglPerfRegionBody"></tbody></table></div>
<h3>Assetcache · Flotsam</h3>
<p class="sectionlead" id="oglPerfCacheInfo">Diagnose des optionalen RAM-Caches, Cache-Treffern und unabhängigen Disk-Schreibworkern. Messwerte werden aus dem bestehenden signierten Heartbeat geliefert.</p>
<div class="grid2" id="oglPerfCacheGrid"></div>
</div>
<div class="section">
<h2><span class="icon">✦</span> OGL Feature Control · Simulator-Lizenzen</h2>
<p class="sectionlead">Grid-Inhaber vergeben hier die Archivfreigaben der per NexBus registrierten Simulatoren.
@@ -1932,6 +1970,179 @@ function setNodesStatus(text,kind){
$('nodesStatus').textContent=text;
$('nodesDot').className='dot'+(kind?' '+kind:'');
}
// Bounded browser-session trends. They are not persisted to server or storage.
const oglPerfHistory=new Map();
let oglPerfNodeId='';
let oglPerfLastNode=null;
function oglPerfNumber(values,key){
return values&&Object.prototype.hasOwnProperty.call(values,key)&&
Number.isFinite(Number(values[key]))?Number(values[key]):null;
}
function oglRecordPerformance(node){
if(!node?.node_id||node.state!=='online')return;
const t=Date.parse(node.last_seen||'');
if(!Number.isFinite(t))return;
let history=oglPerfHistory.get(node.node_id);
if(!history){history=[];oglPerfHistory.set(node.node_id,history)}
const previous=history.length?history[history.length-1]:null;
const pid=Number(node.process_id||0),uptime=Number(node.uptime_seconds||0);
if(previous&&((pid>0&&previous.pid>0&&pid!==previous.pid)||
(Number.isFinite(uptime)&&uptime<previous.uptime)))history.splice(0);
if(history.length&&history[history.length-1].time===t)return;
const p=node.performance||{};
history.push({
time:t,pid,uptime,
cpu:oglPerfNumber(p,'perf_process_cpu_percent'),
ram:Number(node.working_set_bytes||0)/1073741824,
heap:oglPerfNumber(p,'perf_managed_heap_bytes')===null?null:p.perf_managed_heap_bytes/1073741824,
gc:oglPerfNumber(p,'perf_gc_pause_percent'),
alloc:oglPerfNumber(p,'perf_allocated_bytes_per_second')===null?null:p.perf_allocated_bytes_per_second/1048576
});
if(history.length>120)history.splice(0,history.length-120);
if(oglPerfHistory.size>24)oglPerfHistory.delete(oglPerfHistory.keys().next().value);
}
function oglPlotPerf(id,history,series,minimumMax){
const canvas=$(id),ctx=canvas.getContext('2d');
const width=canvas.width,height=canvas.height,left=39,right=10,top=25,bottom=24;
const w=width-left-right,h=height-top-bottom;
ctx.clearRect(0,0,width,height);
ctx.fillStyle='#142335';ctx.fillRect(0,0,width,height);
const values=[];
for(const point of history)for(const line of series)
if(Number.isFinite(point[line.key]))values.push(point[line.key]);
if(!values.length){
ctx.fillStyle='#a4b4c6';ctx.font='14px sans-serif';
ctx.fillText('Noch keine Messwerte',left+10,top+32);return;
}
const max=Math.max(minimumMax||0,Math.max(...values)*1.15,0.01);
ctx.strokeStyle='rgba(155,174,195,.25)';ctx.lineWidth=1;
ctx.font='11px sans-serif';ctx.fillStyle='#a4b4c6';
for(let i=0;i<=3;i++){
const y=top+h*i/3;ctx.beginPath();ctx.moveTo(left,y);ctx.lineTo(width-right,y);ctx.stroke();
ctx.fillText((max*(3-i)/3).toFixed(max>=10?0:1),3,y+4);
}
const first=history[0].time,last=history[history.length-1].time;
ctx.fillText(new Date(first).toLocaleTimeString('de-DE'),left,height-6);
if(first!==last)ctx.fillText(new Date(last).toLocaleTimeString('de-DE'),width-78,height-6);
series.forEach((line,index)=>{
ctx.strokeStyle=line.color;ctx.fillStyle=line.color;ctx.lineWidth=2;
ctx.font='11px sans-serif';ctx.fillText(line.label,left+index*165,14);
let active=false;
for(const point of history){
const value=point[line.key],valid=Number.isFinite(value);
if(!valid){if(active){ctx.stroke();active=false}continue}
const x=left+((point.time-first)/Math.max(1,last-first))*w;
const y=top+h*(1-Math.min(1,Math.max(0,value/max)));
if(!active){ctx.beginPath();ctx.moveTo(x,y);active=true}
else ctx.lineTo(x,y);
if(history.length===1)ctx.fillRect(x-2,y-2,4,4);
}
if(active)ctx.stroke();
});
}
function oglPerfTextMetric(perf,key,suffix=''){
const value=oglPerfNumber(perf,key);
return value===null?'–':value.toLocaleString('de-DE',{maximumFractionDigits:1})+suffix;
}
function oglShowNodePerformance(node){
oglPerfLastNode=node||null;
if(!node)return;
const p=node.performance||{};
$('oglPerfSelected').textContent='Node '+node.node_id+' · '+(node.hostname||'')+
' · '+node.state+' · letzter Heartbeat '+(node.last_seen||'–');
$('oglPerfCpu').textContent=node.state==='online'?oglPerfTextMetric(p,'perf_process_cpu_percent',' %'):'–';
$('oglPerfRam').textContent=formatBytes(node.working_set_bytes);
$('oglPerfFragmented').textContent=oglPerfNumber(p,'perf_gc_fragmented_bytes')===null?
'–':formatBytes(p.perf_gc_fragmented_bytes);
$('oglPerfGc').textContent=node.state==='online'?oglPerfTextMetric(p,'perf_gc_pause_percent',' %'):'–';
const history=oglPerfHistory.get(node.node_id)||[];
oglPlotPerf('oglPerfChartCpu',history,[{key:'cpu',label:'Prozess-CPU',color:'#4bc6e1'}],5);
oglPlotPerf('oglPerfChartRam',history,[
{key:'ram',label:'Working Set',color:'#4bc6e1'},
{key:'heap',label:'Managed Heap',color:'#f5b969'}],0.2);
oglPlotPerf('oglPerfChartGc',history,[{key:'gc',label:'GC-Pause',color:'#f5b969'}],2);
oglPlotPerf('oglPerfChartAlloc',history,[{key:'alloc',label:'Allokationen',color:'#79d6a1'}],1);
const cores=Array.isArray(node.host_cpu_cores)&&node.state==='online'?
node.host_cpu_cores:[];
$('oglPerfHostInfo').textContent=cores.length?
cores.length+' Linux-Host-Kerne gemessen, '+(oglPerfNumber(p,'perf_host_cpu_cores_omitted')||0)+
' ausgelassen. Systemweite Last pro Kern, nicht CPU-Zeit des OpenSim-Prozesses.':
'Keine Host-Kernmesswerte verfügbar (Linux /proc/stat; erster Messpunkt ist eine Baseline).';
const coreRoot=$('oglPerfHostCores');coreRoot.replaceChildren();
cores.forEach(core=>{
const value=Number(core.usage_percent);
if(!Number.isFinite(value)||value<0||value>100)return;
const box=document.createElement('div');box.className='ogl-perf-core';
const label=document.createElement('div');
label.textContent='CPU '+core.core_id+' · '+value.toFixed(1)+' %';box.append(label);
const bar=document.createElement('div');bar.className='meter';
const fill=document.createElement('div');fill.className='fill'+(value>=85?' hot':'');
fill.style.width=value+'%';bar.append(fill);box.append(bar);coreRoot.append(box);
});
const names=new Map((node.regions||[]).map(r=>[r.region_id,r.name||r.region_id]));
const regions=Array.isArray(node.performance_regions)&&node.state==='online'?
node.performance_regions.slice():[];
regions.sort((a,b)=>(Number(b.work_over_budget_percent)||0)-
(Number(a.work_over_budget_percent)||0));
$('oglPerfRegionInfo').textContent=regions.length?
regions.length+' Region(en) mit Messwerten; '+(oglPerfNumber(p,'perf_region_sample_omitted')||0)+
' weitere ausgelassen. Sortiert nach Arbeitszeit-Budgetüberschreitungen.':
'Noch keine Regionsmesswerte vorhanden; [OGLPerformance] auf dieser Node aktivieren.';
const body=$('oglPerfRegionBody');body.replaceChildren();
if(!regions.length){
const tr=document.createElement('tr'),td=document.createElement('td');
td.colSpan=9;td.textContent='Keine Messwerte';tr.append(td);body.append(tr);
}
for(const item of regions){
const tr=document.createElement('tr');
const vals=[
names.get(item.region_id)||item.region_id,
Number(item.heartbeat_hz).toFixed(1)+' Hz',
Number(item.target_hz).toFixed(1)+' Hz',
item.window_frames,
Number(item.work_p95_ms).toFixed(1)+' ms',
Number(item.frame_p95_ms).toFixed(1)+' ms',
Number(item.frame_p99_ms).toFixed(1)+' ms',
Number(item.work_over_budget_percent).toFixed(1)+' %',
Number(item.frame_over_budget_percent).toFixed(1)+' %'
];
for(const val of vals){const td=document.createElement('td');td.textContent=String(val);tr.append(td)}
body.append(tr);
}
const cacheRoot=$('oglPerfCacheGrid');cacheRoot.replaceChildren();
const assetFields=[
['Gesamtrequests','perf_asset_requests','count'],
['RAM-Cache-Treffer','perf_asset_memory_hits','count'],
['Disk-Cache-Treffer','perf_asset_disk_hits','count'],
['RAM-Cache-Trefferquote','perf_asset_memory_hits','ratio'],
['Disk-Cache-Trefferquote','perf_asset_disk_hits','ratio'],
['Weak-Ref-Trefferquote','perf_asset_weak_hits','ratio'],
['RAM-LRU-Belegung','perf_asset_ram_bytes','bytes'],
['RAM-LRU-Budget','perf_asset_ram_limit_bytes','bytes'],
['Cacheeinträge','perf_asset_ram_entries','count'],
['Disk-Writer (aktiv konfiguriert)','perf_asset_file_writers','count'],
['Adaptive Writer-Ziel','perf_asset_writer_target','count'],
['Aktive adaptive Writer','perf_asset_writer_active','count'],
['Disk-Queue (wartend)','perf_asset_writer_pending_jobs','count'],
['RAM für I/O reserviert','perf_asset_inflight_bytes','bytes'],
['Abgewiesene Cache-Writes','perf_asset_writes_rejected','count'],
['RAM-Pressure Evictions','perf_asset_memory_trims','count']
];
const hasAsset=oglPerfNumber(p,'perf_asset_requests')!==null&&node.state==='online';
$('oglPerfCacheInfo').textContent=hasAsset?
'Kumulative Cache-Zähler seit Simulatorstart und aktuelle Grenzen; ausschließlich Flotsam, kein globales RAM-Limit.':
'Keine Flotsam-Diagnose vorhanden: OGLPerformance/Flotsam ist auf dieser Node nicht verfügbar.';
assetFields.forEach(([label,key,type])=>{
const card=document.createElement('div');card.className='ogl-perf-stat';
const title=document.createElement('span');title.className='small';title.textContent=label;
const value=document.createElement('strong');const n=hasAsset?oglPerfNumber(p,key):null;
const requests=oglPerfNumber(p,'perf_asset_requests');
value.textContent=n===null?'–':type==='bytes'?formatBytes(n):
type==='ratio'?(requests>0?(100*n/requests).toFixed(1)+' %':'–'):
n.toLocaleString('de-DE');
card.append(title,value);cacheRoot.append(card);
});
}
function renderNodes(data){
const nodes=data.nodes||[];
$('nodesCount').textContent=nodes.length;
@@ -1944,6 +2155,7 @@ function renderNodes(data){
const tr=document.createElement('tr');const td=document.createElement('td');td.colSpan=12;td.className='small';td.textContent=data.transport_enabled?'Noch keine NodeAgent-Heartbeats empfangen.':'NexBus-Transport ist deaktiviert; keine Remote-NodeAgents werden empfangen.';tr.append(td);body.append(tr);
}
nodes.forEach(node=>{
oglRecordPerformance(node);
const tr=document.createElement('tr');tr.className='noderow';
const perf=node.performance||{};
const numberMetric=key=>Object.prototype.hasOwnProperty.call(perf,key)&&
@@ -1996,9 +2208,20 @@ function renderNodes(data){
else if(updateActive)updateInfo.classList.add('warn');
if(node.update?.updated_at)updateInfo.title=new Date(node.update.updated_at).toLocaleString('de-DE');
actionCell.append(updateInfo);tr.append(actionCell);
tr.addEventListener('click',()=>{$('nodeDetail').textContent=JSON.stringify(node,null,2)});
tr.addEventListener('click',()=>{
oglPerfNodeId=node.node_id;
$('nodeDetail').textContent=JSON.stringify(node,null,2);
oglShowNodePerformance(node);
});
body.append(tr);
});
if(oglPerfNodeId){
const selected=nodes.find(n=>n.node_id===oglPerfNodeId);
if(selected){
$('nodeDetail').textContent=JSON.stringify(selected,null,2);
oglShowNodePerformance(selected);
}
}
setNodesStatus(nodes.filter(x=>x.state==='online').length+' online · '+nodes.length+' Nodes',data.transport_enabled?'good':'bad');
}
let oglLiveUpdatePoll=null;
+19
View File
@@ -333,6 +333,25 @@ namespace NexVerse.Server.Api
// An empty object means OGLPerformance telemetry is disabled/unavailable.
performance =
node.PerformanceMetrics,
// Signed opt-in resource/region telemetry. Never returned by
// unauthenticated public endpoints; all arrays bounded at ingress.
performance_regions = node.RegionPerformance.Select(region => new
{
region_id = region.RegionId,
heartbeat_hz = region.HeartbeatHz,
target_hz = region.TargetHz,
window_frames = region.WindowFrames,
work_p95_ms = region.WorkP95Ms,
frame_p95_ms = region.FrameP95Ms,
frame_p99_ms = region.FrameP99Ms,
work_over_budget_percent = region.WorkOverBudgetPercent,
frame_over_budget_percent = region.FrameOverBudgetPercent
}).ToArray(),
host_cpu_cores = node.HostCpuCores.Select(core => new
{
core_id = core.CoreId,
usage_percent = core.UsagePercent
}).ToArray(),
disk_free_bytes =
node.DiskFreeBytes,
disk_total_bytes =
+10
View File
@@ -8,6 +8,16 @@ using System.Threading;
namespace OpenSim.Framework
{
/// <summary>
/// Optional, read-only bounded snapshot exposed by an asset-cache module
/// to the NodeAgent. Core framework does not depend on Flotsam internals.
/// Values are cumulative or instantaneous, not authoritative asset state.
/// </summary>
public interface IOglAssetCacheMetricsProvider
{
IReadOnlyDictionary<string, long> CaptureAssetCacheMetrics();
}
public sealed class OglBudgetedLruCache<TKey, TValue> : IDisposable where TKey : notnull
{
private sealed class Entry
@@ -50,7 +50,7 @@ using System.Runtime.InteropServices;
namespace OpenSim.Region.CoreModules.Asset
{
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "FlotsamAssetCache")]
public class FlotsamAssetCache : ISharedRegionModule, IAssetCache, IAssetService
public class FlotsamAssetCache : ISharedRegionModule, IAssetCache, IAssetService, IOglAssetCacheMetricsProvider
{
private struct WriteAssetInfo
{
@@ -1668,6 +1668,39 @@ namespace OpenSim.Region.CoreModules.Asset
return outputLines;
}
// Sampled on the existing signed NodeAgent heartbeat. No new network
// listener, forced GC or cache mutation. Numbers are approximate
// concurrent snapshots of Flotsam's existing counters.
public IReadOnlyDictionary<string, long> CaptureAssetCacheMetrics()
{
if (!m_Enabled)
return new Dictionary<string, long>();
static long SafeCount(ulong value) =>
value > (ulong)long.MaxValue ? long.MaxValue : (long)value;
var lru = m_BudgetedMemoryCache;
var limiter = m_FileWriteByteLimiter;
var gate = m_AdaptiveFileWriteGate;
return new Dictionary<string, long>(StringComparer.Ordinal)
{
["perf_asset_requests"] = SafeCount(m_Requests),
["perf_asset_memory_hits"] = SafeCount(m_MemoryHits),
["perf_asset_disk_hits"] = SafeCount(m_DiskHits),
["perf_asset_weak_hits"] = SafeCount(m_weakRefHits),
["perf_asset_memory_enabled"] = m_MemoryCacheEnabled ? 1 : 0,
["perf_asset_ram_entries"] = lru?.Count ?? 0,
["perf_asset_ram_bytes"] = lru?.EstimatedBytes ?? 0,
["perf_asset_ram_limit_bytes"] = lru == null ? 0 : (long)m_MemoryCacheMaxMiB * 1024 * 1024,
["perf_asset_memory_trims"] = Interlocked.Read(ref m_MemoryPressureTrimmed),
["perf_asset_file_writers"] = m_FileWriteConcurrency,
["perf_asset_writer_target"] = gate?.TargetWorkers ?? m_FileWriteConcurrency,
["perf_asset_writer_active"] = gate?.ActiveWorkers ?? 0,
["perf_asset_writer_pending_jobs"] = m_assetFileWriteWorker?.Count ?? 0,
["perf_asset_writes_rejected"] = Interlocked.Read(ref m_CacheWritesRejected),
["perf_asset_inflight_bytes"] = limiter?.InFlightBytes ?? 0,
["perf_asset_inflight_limit_bytes"] = limiter?.LimitBytes ?? 0
};
}
#region Console Commands
private void HandleConsoleCommand(string module, string[] cmdparams)
{
@@ -4,7 +4,7 @@
## Was bereits implementiert ist
1. **Read-only NodeAgent-Diagnostik:** CPU-Auslastung des Simulatorprozesses relativ zu `Environment.ProcessorCount`, Prozess-Privatspeicher, Managed Heap, GC-Heap/Fragmentierung, GC-Pausenanteil zwischen Samples, Allokationsrate, GC-Collection-Counter, Threadpool-Threads, aktive Worker/Pending Jobs sowie **tatsaechliche** Heartbeat-Hz pro Region. Ein opt-in, allokationsfreies Frame-Histogramm im Scene-Heartbeat liefert je Messfenster Arbeitszeit-/Gesamtdauer-Durchschnitt, P95/P99 sowie den Anteil ueber dem Framebudget. Das Histogramm trennt reine Arbeitszeit von Sleep-/Scheduler-Jitter. Diese Werte werden als `perf_*`-Felder in die bestehende HMAC-authentifizierte `node.heartbeat`-Nachricht geschrieben. Die Zahl der berichteten Regionen ist auf 32 begrenzt. Kein neuer oeffentlicher HTTP-Endpunkt.
1. **Read-only NodeAgent-Diagnostik:** CPU-Auslastung des Simulatorprozesses relativ zu `Environment.ProcessorCount`, Prozess-Privatspeicher, Managed Heap, GC-Heap/Fragmentierung, GC-Pausenanteil zwischen Samples, Allokationsrate, GC-Collection-Counter, Threadpool-Threads, aktive Worker/Pending Jobs sowie **tatsaechliche** Heartbeat-Hz pro Region. Ein opt-in, allokationsfreies Frame-Histogramm im Scene-Heartbeat liefert je Messfenster Arbeitszeit-/Gesamtdauer-Durchschnitt, P95/P99 sowie den Anteil ueber dem Framebudget. Das Histogramm trennt reine Arbeitszeit von Sleep-/Scheduler-Jitter. Diese Werte werden als `perf_*`-Felder in die bestehende HMAC-authentifizierte `node.heartbeat`-Nachricht geschrieben. Die Zahl der berichteten Regionen ist seit OGLPerformance 1.2 auf 64 begrenzt. Kein neuer oeffentlicher HTTP-Endpunkt.
2. **Unabhaengige Disk-Cache-Schreibjobs:** `[AssetCache] FileWriteConcurrency` (1..min(8,CPU-Kerne)) erlaubt mehrere Flotsam-Schreibworker. Ein expliziter Wert `0` aktiviert konservatives CPU-Auto-Sizing (`min(4, max(1, sichtbare_kerne/2))`); Standard bleibt 1. `Environment.ProcessorCount` wird fuer Containerlimits beruecksichtigt. Jede Datei wird durch `m_CurrentlyWriting` vor doppelten Schreibauftraegen geschuetzt.
3. **Schreibwarteschlangen-Backpressure:** `[AssetCache] MaxPendingFileWrites` (>0) begrenzt die Zahl wartender Jobs. Zusaetzlich limitiert `[AssetCache] MaxInFlightFileWriteMiB` (>0) die **geschaetzten Bytes** sowohl wartender als auch bereits laufender Cache-Schreibjobs. Ueberlast und uebergrosse Einzelassets fuehren nur zum Auslassen des *optionalen Disk-Cache-Writes*; das autoritative Asset bleibt unveraendert. Speicherreservierungen werden bei Erfolg, Schreibfehlern, Cancel und Shutdown idempotent freigegeben. Nicht angenommene oder verworfene Jobs entfernen ihre In-Progress-Markierung.
4. **Optionaler Flotsam-RAM-Cache mit LRU:** `MemoryCacheEnabled=true` und `MemoryCacheMaxMiB>0` waehlen einen thread-sicheren, durch geschaetzte Asset-Payloadbytes und `MemoryCacheMaxEntries` begrenzten Cache mit TTL und LRU. Assets ueber dem Budget werden nicht im RAM angeheftet. Ein langsamer Ablauf-Sweep entfernt abgelaufene TTL-Eintraege jede Minute, auch ohne neue Viewer-Anfragen. Beim Entfernen der letzten Region wird der LRU-Inhalt freigegeben; beim finalen Modul-Close wird der Timer entsorgt. Bei `MemoryCacheMaxMiB=0` bleibt der bisherige TTL-Cache unveraendert.
@@ -41,7 +41,7 @@ Die `[AssetCache]`-Einstellungen gehoeren in die **wirklich geladene** Flotsam-K
- `perf_allocated_bytes_per_second`, `perf_gc_pause_percent`, `perf_gc_fragmented_bytes`: Allokation und GC-Druck.
- `perf_threadpool_pending_items`: Groesse der globalen .NET-Threadpool-Warteschlange. Die Flotsam-Queue besitzt eine *eigene* Grenze.
- `fcache status`: Zeigt bei eingeschaltetem LRU-Cache die geschaetzte Asset-RAM-Belegung und das konfigurierte Budget an sowie die aktuelle und maximale Byte-Reservierung der File-Write-Jobs inklusive abgewiesener Schreibanfragen. Wenn der adaptive Scheduler aktiv ist, werden aktuelle/hoechstens erlaubte Worker, aktive I/O-Jobs und abgewiesene adaptive Schreibjobs angezeigt. Alle Budgets begrenzen nur diese Flotsam-Komponenten, nicht den gesamten Prozessspeicher oder fremde Asset-Referenzen.
- `perf_region_sample_omitted`: Anzahl nicht inkludierter Regionen, falls mehr als 32 Regionen auf einem Node laufen.
- `perf_region_sample_omitted`: Anzahl nicht inkludierter Regionen, falls mehr als 64 Regionen auf einem Node laufen.
Die Felder werden als Teil des bestehenden intern signierten NodeAgent-Events gesendet; sie enthalten technische Betriebsinformationen und sollten nur autorisierten Admins zugaenglich sein.
@@ -0,0 +1,94 @@
# OpenGenesisLINK G1 – OGLPerformance 1.2: CPU-, RAM-, Regionen- und Assetcache-Diagnose
**Status:** optionale read-only Observability; keinerlei automatische
Physik-, GC- oder Thread-Affinity-Steuerung.
## Datenweg und Zugriffsberechtigung
Alle Werte stammen aus den bereits bestehenden, signierten
`node.heartbeat`-NexBus-Nachrichten. Der Simulator sendet sie nur mit
`[OGLPerformance] Enabled = true`. ROBUST verarbeitet ausschließlich
zugelassene Felder und gibt sie nur über die bestehenden autorisierten
`GET /api/v1/nodes` und `GET /api/v1/nodes/{nodeId}` mit
`simulators:read` aus. Kein zusätzlicher öffentlicher Endpoint.
Ohne aktualisierten NodeAgent, etwa auf einer noch alten Gummybear-Node,
bleiben die neuen Werte leer.
## Neuer Diagnosebereich im World API Control Center
Unter **Simulator-Nodes** den Node anklicken. Es erscheinen:
1. **CPU-Prozessauslastung** relativ zu `Environment.ProcessorCount`,
**Working Set**, **GC-Fragmentierung** und **GC-Pausen**.
2. Vier Verlaufskurven: CPU, Working-Set/Managed Heap, GC-Pausen,
Allokationsrate. Der Browser behält maximal 120 Messpunkte je Node,
bis zu 24 Nodes. **Kein persistierter Serververlauf**; nach Seiten-Reload
beginnt die Zeitreihe neu.
3. **Linux-Host-Auslastung pro logischem CPU-Kern** aus `/proc/stat`,
in der UI deutlich als *Host*-Last bezeichnet. Diese Zahlen
zeigen **nicht die Auslastung des OpenSim-Prozesses pro Kern** und
keine sichere Zuordnung zu einzelnen Regionen/Threads. Auf Windows
wird diese Zusatzmessung nicht angeboten. Der erste Messzeitpunkt
ist eine Baseline; erst mit dem nächsten Heartbeat entstehen Raten.
4. **Pro Region** tatsächliche Heartbeat-Hz, Ziel-Hz, Framezahl,
Work-P95, Frame-P95/P99 und beide Framebudget-Überschreitungsanteile.
Maximal 64 Regionen je Node/Heartbeat (42 Regionen sind erfasst);
überschüssige Regionen werden als Anzahl separat gemeldet.
Diese Werte entstehen in der bereits integrierten
`OglRegionTimingWindow`, ohne die Simulationsphysik zu ändern.
Sie sind **keine CPU-Zeitmessung pro Region**.
5. **Flotsam-Cache**: RAM-LRU-Belegung/Budget, bisherige Requests,
RAM- und Disk-Hits, Writerzahl, adaptive Ziel-/Aktiv-Worker,
wartende Disk-Writes, Bytes-in-Flight, abgewiesene Cache-Writes
und optional entlastete RAM-LRU-Einträge.
Nur der aktive Flotsam-Cache liefert diese Werte über ein internes
read-only Interface `IOglAssetCacheMetricsProvider`.
Das ist kein globales Asset-, RAM- oder Prozesslimit.
Die API verwirft ungültige, negative, nicht-finite und übergroße
Metriken. Region- und Kern-JSON sind gegen übergroße Arrays und
Eingaben begrenzt. Fehlende Messungen löschen den bisherigen Snapshot.
Ein inaktiver Node zeigt keine neuen Livewerte.
## Konfiguration einer Test-Node
Im tatsächlich geladenen `OpenSim.ini`:
```ini
[OGLPerformance]
Enabled = true
```
Optional im tatsächlich geladenen `[AssetCache]` (nicht in
`FlotsamCache.ini.example` allein), nach Prüfung der vorhandenen Werte:
```ini
[AssetCache]
FileWriteConcurrency = 2
MaxPendingFileWrites = 1024
MaxInFlightFileWriteMiB = 256
AdaptiveFileWrites = true
MemoryCacheEnabled = true
MemoryCacheMaxMiB = 256
MemoryCacheMaxEntries = 8192
MemoryPressureTrimEnabled = false
```
Aktivierung erfordert den regulären Neustart des Simulatorprozesses,
**nicht** einen unkontrollierten ROBUST-Update-Lauf.
## Grenzen und Validierung
`perf_process_cpu_percent` ist ein Durchschnitt über die aus Sicht
des Prozesses verfügbaren logischen Kerne. Ein einzelner überlasteter
Thread kann die Gesamtrate klein erscheinen lassen; hohe
`/proc/stat`-Werte beweisen wiederum nicht, dass OpenSim der
Verursacher ist. Eine tatsächliche Prozess-Thread/Core-Zuordnung
erfordert ein separates Profiling, beispielsweise mit `dotnet-trace`
und systemweitem `perf` auf einer Test-Node.
Für belastbare Optimierungen die gleichen OARs, Mesh-/Textur-Lasten,
Avatarzahlen und Host-Ressourcen verwenden. CPU, GC, Work-P95/P99,
Cache-Hit-Rate und Ladezeiten vor/nach einer isolierten
Konfigurationsänderung vergleichen. Erst nach Regressionstests und
realistischen Benchmarks lohnt sich eine neue Scheduling-Strategie.
@@ -82,6 +82,7 @@ internal static class Program
var fromFile = (AssetBase)getFile.Invoke(cache, new object[] { id })!;
Check(fromFile is not null && fromFile.Data.SequenceEqual(original.Data), "File cache could not read new versioned format");
TestReadOnlyCacheMetrics();
TestConcurrentRealFileCacheWrites(root);
TestDeadWeakReferencePruning();
@@ -94,6 +95,25 @@ internal static class Program
}
}
private static void TestReadOnlyCacheMetrics()
{
// Uninitialized caches must not claim valid live telemetry.
var cache = new FlotsamAssetCache();
IOglAssetCacheMetricsProvider provider = cache;
Check(provider.CaptureAssetCacheMetrics().Count == 0,
"disabled Flotsam must not expose resource counters");
typeof(FlotsamAssetCache).GetField("m_Enabled",
BindingFlags.Instance | BindingFlags.NonPublic)!.SetValue(cache, true);
IReadOnlyDictionary<string, long> sample = provider.CaptureAssetCacheMetrics();
Check(sample["perf_asset_file_writers"] == 1 &&
sample["perf_asset_ram_entries"] == 0 &&
sample["perf_asset_ram_bytes"] == 0 &&
sample.ContainsKey("perf_asset_writer_pending_jobs") &&
sample.ContainsKey("perf_asset_writes_rejected"),
"signed asset-cache telemetry contract mismatch");
}
private static void TestDeadWeakReferencePruning()
{
// Do not force a GC in the test. A weak reference with a null target
@@ -47,6 +47,17 @@ internal static class Program
["perf_managed_heap_bytes"] = "1048576",
["perf_gc_pause_percent"] = "2.50",
["perf_threadpool_pending_items"] = "7",
["perf_host_cpu_cores_json"] =
"[{\"core_id\":0,\"usage_percent\":98.25},{\"core_id\":1,\"usage_percent\":15.5}]",
["perf_region_heartbeats_json"] =
"[{\"region_id\":\"11111111-1111-1111-1111-111111111111\",\"heartbeat_hz\":11.0," +
"\"target_hz\":11.0,\"window_frames\":100,\"work_p95_ms\":8,\"frame_p95_ms\":12," +
"\"frame_p99_ms\":28,\"work_over_budget_percent\":5.0,\"frame_over_budget_percent\":8.0}]",
["perf_asset_requests"] = "200",
["perf_asset_memory_hits"] = "100",
["perf_asset_disk_hits"] = "60",
["perf_asset_ram_bytes"] = "1048576",
["perf_asset_writer_pending_jobs"] = "2",
["region_count"] = "2",
["agent_count"] = "7",
["npc_count"] = "2",
@@ -96,6 +107,20 @@ internal static class Program
first.LunaTextureClassifications["png"] == 3,
"LunaTexture classification projection mismatch");
Require(first.Regions.Count == 2, "heartbeat region list mismatch");
Require(first.HostCpuCores.Count == 2 &&
first.HostCpuCores[0].CoreId == 0 &&
first.HostCpuCores[0].UsagePercent == 98.25,
"host CPU cores must be parsed and ordered");
Require(first.RegionPerformance.Count == 1 &&
first.RegionPerformance[0].RegionId ==
"11111111-1111-1111-1111-111111111111" &&
first.RegionPerformance[0].FrameP99Ms == 28 &&
first.RegionPerformance[0].WorkOverBudgetPercent == 5,
"signed region frame timing projection mismatch");
Require(first.PerformanceMetrics["perf_asset_requests"] == 200 &&
first.PerformanceMetrics["perf_asset_ram_bytes"] == 1048576 &&
first.PerformanceMetrics["perf_asset_writer_pending_jobs"] == 2,
"signed Flotsam cache projection mismatch");
Require(first.PerformanceMetrics["perf_processor_count"] == 8 &&
first.PerformanceMetrics["perf_process_cpu_percent"] == 53.25 &&
first.PerformanceMetrics["perf_managed_heap_bytes"] == 1048576 &&
@@ -118,6 +143,23 @@ internal static class Program
Require(sanitized.PerformanceMetrics.Count == 1 &&
sanitized.PerformanceMetrics["perf_processor_count"] == 16,
"metrics must be finite, bounded and allowlisted");
Require(sanitized.RegionPerformance.Count == 0 &&
sanitized.HostCpuCores.Count == 0,
"missing host/region telemetry must clear previous samples");
bus.Publish(Event("node.heartbeat", new Dictionary<string, string>
{
["node_id"] = "sim-a",
["perf_host_cpu_cores_json"] =
"[{\"core_id\":0,\"usage_percent\":150.0}]",
["perf_region_heartbeats_json"] =
"[{\"region_id\":\"00000000-0000-0000-0000-000000000000\",\"heartbeat_hz\":2," +
"\"target_hz\":2,\"window_frames\":1,\"work_p95_ms\":0,\"frame_p95_ms\":0," +
"\"frame_p99_ms\":0,\"work_over_budget_percent\":0,\"frame_over_budget_percent\":0}]"
}));
Require(registry.Get("sim-a").HostCpuCores.Count == 0 &&
registry.Get("sim-a").RegionPerformance.Count == 0,
"invalid host load and unknown regions must be rejected");
bus.Publish(Event(
"region.online",
@@ -25,6 +25,27 @@ static class Program
"frame counter rollover");
Require(OglPerformanceSampler.CalculateHeartbeatHz(0, 0, 0) == 0, "zero interval");
// /proc/stat is host-wide Linux CPU usage, not per-process scheduling.
// Parser must exclude the aggregate "cpu" line and guest double counts.
var linuxCpu = OglPerformanceSampler.ParseLinuxHostCpu(new[]
{
"cpu 500 0 200 1000 100 0 0 0 20 10",
"cpu0 100 0 50 200 10 0 0 0 3 2",
"cpu1 50 0 20 100 0 0 0 0 0 0",
"cpu2 invalid 0 3 4"
});
Require(linuxCpu.Count == 2 &&
linuxCpu[0].Total == 360 && linuxCpu[0].Idle == 210 &&
linuxCpu[1].Total == 170 && linuxCpu[1].Idle == 100,
"Linux CPU core counters must exclude guest fields and invalid lines");
var boundedCpu = OglPerformanceSampler.ParseLinuxHostCpu(new[]
{
"cpu0 100 0 50 200",
"cpu1 100 0 50 200"
}, maximumCores: 1);
Require(boundedCpu.Count == 1,
"host CPU observation must respect configured core bound");
var sampler = new OglPerformanceSampler();
IReadOnlyDictionary<string, string> first =
sampler.Capture(new[] { new OglRegionFrame("region-test", 100, 0.0909f) });
@@ -43,6 +64,17 @@ static class Program
Require(json.RootElement[0].GetProperty("heartbeat_hz").GetDouble() > 0,
"heartbeat rate must be measured from samples");
sampler.Capture(Array.Empty<OglRegionFrame>());
var manyRegions = Enumerable.Range(0, 42)
.Select(i => new OglRegionFrame("region-" + i, (uint)i, 0.0909f))
.ToArray();
var manySamples = sampler.Capture(manyRegions);
Require(manySamples["perf_region_sample_count"] == "42" &&
manySamples["perf_region_sample_omitted"] == "0",
"42 regions must fit into the bounded 64-region heartbeat");
using (JsonDocument bigRegionJson =
JsonDocument.Parse(manySamples["perf_region_heartbeats_json"]))
Require(bigRegionJson.RootElement.GetArrayLength() == 42,
"64-region telemetry cap unexpectedly truncated 42 regions");
using var firstStarted = new ManualResetEventSlim(false);
using var releaseFirst = new ManualResetEventSlim(false);