perf(fastrez): faster avatar wearables and nearby scene load (#281)

Small opt-in NexVerse FastRez: 1s wearables reply and near-first initial object enqueue. Legacy defaults, CI guard, unit tests and rollback documented.
This commit is contained in:
OpenGenesis (MPL 2.0) authored and GitHub committed 2026-10-23 01:39:17 +02:00
1 parent de4ca09aa3
commit f2656ae153
9 files changed
+176 -3

No files matched your search

@@ -58,6 +58,8 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
private int m_savetime = 5; // seconds to wait before saving changed appearance
private int m_sendtime = 2; // seconds to wait before sending changed appearance
private bool m_reusetextures = false;
// Legacy delay remains the default; NexVerse can opt in to faster wearables replies.
private int m_wearablesRequestDelayMs = 4000;
private int m_checkTime = 500; // milliseconds to wait between checks for appearance updates
private System.Timers.Timer m_updateTimer = new System.Timers.Timer();
@@ -80,6 +82,12 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
m_sendtime = Convert.ToInt32(appearanceConfig.GetString("DelayBeforeAppearanceSend",Convert.ToString(m_sendtime)));
m_reusetextures = appearanceConfig.GetBoolean("ReuseTextures",m_reusetextures);
int requestedDelay = appearanceConfig.GetInt("WearablesRequestDelayMs", m_wearablesRequestDelayMs);
if (requestedDelay >= 500 && requestedDelay <= 4000)
m_wearablesRequestDelayMs = requestedDelay;
else
m_log.WarnFormat("[AVFACTORY]: WearablesRequestDelayMs={0} is outside 500..4000 ms; retaining {1} ms", requestedDelay, m_wearablesRequestDelayMs);
// m_log.InfoFormat("[AVFACTORY] configured for {0} save and {1} send",m_savetime,m_sendtime);
}
@@ -1167,9 +1175,10 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
/// <param name="client"></param>
private void Client_OnRequestWearables(IClientAPI client)
{
int replyDelayMs = m_wearablesRequestDelayMs;
Util.FireAndForget(delegate(object x)
{
Thread.Sleep(4000);
Thread.Sleep(replyDelayMs);
// m_log.DebugFormat("[AVFACTORY]: Client_OnRequestWearables called for {0} ({1})", client.Name, client.AgentId);
ScenePresence sp = m_scene.GetScenePresence(client.AgentId);
@@ -27,6 +27,7 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using Nini.Config;
using NUnit.Framework;
using OpenMetaverse;
@@ -193,5 +194,36 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
Assert.That(eyesBake.Temporary, Is.False);
Assert.That(eyesBake.Local, Is.False);
}
[TestCase(500, 500)]
[TestCase(1000, 1000)]
[TestCase(4000, 4000)]
[TestCase(100, 4000)]
[TestCase(4001, 4000)]
public void TestWearablesRequestDelayBounds(int configuredDelay, int expectedDelay)
{
IniConfigSource config = new IniConfigSource();
config.AddConfig("Appearance").Set("WearablesRequestDelayMs", configuredDelay);
AvatarFactoryModule module = new AvatarFactoryModule();
module.Initialise(config);
FieldInfo delayField = typeof(AvatarFactoryModule).GetField(
"m_wearablesRequestDelayMs", BindingFlags.Instance | BindingFlags.NonPublic);
Assert.That(delayField, Is.Not.Null);
Assert.That((int)delayField.GetValue(module), Is.EqualTo(expectedDelay));
}
[Test]
public void TestWearablesRequestDelayLegacyDefault()
{
AvatarFactoryModule module = new AvatarFactoryModule();
module.Initialise(new IniConfigSource());
FieldInfo delayField = typeof(AvatarFactoryModule).GetField(
"m_wearablesRequestDelayMs", BindingFlags.Instance | BindingFlags.NonPublic);
Assert.That(delayField, Is.Not.Null);
Assert.That((int)delayField.GetValue(module), Is.EqualTo(4000));
}
}
}
+3
View File
@@ -741,6 +741,8 @@ namespace OpenSim.Region.Framework.Scenes
public float ReprioritizationDistance { get; set; }
private readonly float m_minReprioritizationDistance = 32f;
public bool ObjectsCullingByDistance = false;
// Opt-in: queue objects near a joining avatar ahead of distant objects.
public bool FastRezNearbyFirst = false;
private readonly ExpiringCacheOS<UUID, UUID> TeleportTargetsCoolDown = new();
@@ -1129,6 +1131,7 @@ namespace OpenSim.Region.Framework.Scenes
ObjectsCullingByDistance
= interestConfig.GetBoolean("ObjectsCullingByDistance", ObjectsCullingByDistance);
FastRezNearbyFirst = interestConfig.GetBoolean("FastRezNearbyFirst", FastRezNearbyFirst);
}
@@ -4090,7 +4090,39 @@ namespace OpenSim.Region.Framework.Scenes
bool cacheEmpty = (flags & 2) != 0;
EntityBase[] entities = Scene.Entities.GetEntities();
if(cacheEmpty)
// FastRez only changes the initial enqueue order. Existing
// update prioritization, viewer cache probes and object data
// remain unchanged. Collect once so moving objects cannot
// be skipped between the near/far passes.
if (m_scene.FastRezNearbyFirst)
{
List<SceneObjectGroup> nearby = new List<SceneObjectGroup>();
List<SceneObjectGroup> distant = new List<SceneObjectGroup>();
Vector3 origin = AbsolutePosition;
const float nearDistanceSquared = 64f * 64f;
foreach (EntityBase e in entities)
{
if (e is SceneObjectGroup grp && !grp.IsAttachment)
{
if (Vector3.DistanceSquared(origin, grp.AbsolutePosition) <= nearDistanceSquared)
nearby.Add(grp);
else
distant.Add(grp);
}
}
nearby.AddRange(distant);
foreach (SceneObjectGroup grp in nearby)
{
if (cacheEmpty || !grp.IsViewerCachable)
grp.SendFullAnimUpdateToClient(ControllingClient);
else
grp.SendUpdateProbes(ControllingClient);
}
}
else if(cacheEmpty)
{
foreach (EntityBase e in entities)
{
+3
View File
@@ -219,6 +219,7 @@
MessageOnlineUsersOnly = true
[InterestManagement]
FastRezNearbyFirst = true
[MediaOnAPrim]
@@ -239,6 +240,8 @@
ReuseTextures = true
DelayBeforeAppearanceSend = 1
DelayBeforeAppearanceSave = 3
; OGL FastRez pilot: revert to 4000 on viewer/HG login regressions.
WearablesRequestDelayMs = 1000
ResendAppearanceUpdates = false
[XBakes]
+3
View File
@@ -216,6 +216,7 @@
MessageOnlineUsersOnly = true
[InterestManagement]
FastRezNearbyFirst = true
[MediaOnAPrim]
@@ -236,6 +237,8 @@
ReuseTextures = true
DelayBeforeAppearanceSend = 1
DelayBeforeAppearanceSave = 3
; OGL FastRez pilot: revert to 4000 on viewer/HG login regressions.
WearablesRequestDelayMs = 1000
ResendAppearanceUpdates = false
[XBakes]
+5
View File
@@ -1032,6 +1032,11 @@
DelayBeforeAppearanceSave = 5
DelayBeforeAppearanceSend = 2
; Delay before responding to viewer RequestWearables. Legacy 4000ms is retained
; by default to protect login/teleport compatibility. NexVerse profiles can
; pilot 1000ms; valid range is 500..4000ms.
WearablesRequestDelayMs = 4000
; If true, avatar appearance information is resent to other avatars in the simulator every 60 seconds.
; This may help with some situations where avatars are persistently grey, though it will not help
; in other situations (e.g. appearance baking failures where the avatar only appears as a cloud to others).
+56
View File
@@ -0,0 +1,56 @@
# OpenGenesisLINK 0.9.3.13 – OGL FastRez (kleines Performance-Paket)
Stand: 23.10.2026 | PR #281 | separater Simulator-Patch, **nicht** Teil von PR #237
## Genau zwei Änderungen
1. **Avatar-Wearables:** Die feste Wartezeit vor der Antwort auf
`RequestWearables` beträgt im NexVerse-Profil jetzt 1.000 statt
4.000 ms. `[Appearance] WearablesRequestDelayMs = 1000`.
Gültige Werte: 500–4000 ms; bei ungültigen Werten fällt die
Implementierung auf den sicheren Standard von 4000 ms zurück.
Das reduziert die feste Serverwartezeit dieses Request-Pfads um 3 Sekunden,
**nicht zwingend** die Zeit bis zum vollständig gerenderten Avatar.
2. **Weltaufbau:** `[InterestManagement] FastRezNearbyFirst = true`
reiht beim initialen Regionseintritt Objekte innerhalb 64 m um die
Avatarposition zuerst ein; danach kommen die übrigen Objekte.
Die vorhandene Distanz-Priorisierung, der Viewer-Objektcache,
das Updateformat und die Zugriffsregeln bleiben unverändert.
Dies gilt für den bestehenden vollständigen Objekt-Synchronisationspfad,
nicht für den gesonderten Distanz-Culling-Pfad.
Der OpenSim-Standard bleibt `false`.
Kein neuer Dienst, keine Datenbank, keine Assets-Migration, kein Redis,
keine Änderungen an Hypergrid-Autorisierung oder Avatar-Bake-Daten.
Der noch offene OGL AssetService PR #237 ist unabhängig und unverändert.
## Einmaliger Test und Abschluss
* CI: `python3 tools/ci/verify_avatar_appearance_config.py`
und NexVerse-Build müssen erfolgreich sein.
* Im **Staging** je drei Loginläufe mit Firestorm in derselben Region:
einmal beide FastRez-Einstellungen aktiv und einmal deaktiviert
(WearablesRequestDelayMs=4000; FastRezNearbyFirst=false).
Vergleichbar sind nur Läufe mit identischem Viewer-Cache, Outfit,
Region und Netzwerk.
* Zwei Zeiten notieren: **bis eigener Avatar sichtbar** und
**bis erste Gebäude um den Loginpunkt sichtbar**.
Zusätzlich einen zweiten Avatar und einen HG-Gast kontrollieren,
insbesondere Outfit-Wechsel und Teleport.
* **Freigabe nur bei sichtbarem Vorteil ohne Fehler.** Keine versprochenen
Prozentwerte oder fixen Sekunden für den gesamten Bildaufbau.
Bei fehlenden Assets, dauerhaft roter Wolke, fehlerhaftem Outfit
oder Objektauslassungen nicht freigeben.
* **Rollback:** Beide Werte in der Simulator-Konfiguration auf
`WearablesRequestDelayMs=4000` und `FastRezNearbyFirst=false`
zurückstellen und Simulator kontrolliert neu starten.
## Grenzen
Eine hartnäckige rote Wolke durch fehlende oder ungültige Bake-Assets,
fehlerhafte Wearables oder gescheiterte Texture-CAPS wird von FastRez
nicht repariert. Solche Fälle separat als Fehler untersuchen.
**Fertig-Definition:** CI grün + kurzer Stagingvergleich + keine
Darstellungsregressionen. Kein weiteres FastRez-Teilprojekt vorgesehen.
+31 -1
View File
@@ -7,6 +7,7 @@ EXPECTED = {
"DelayBeforeAppearanceSend": "1",
"DelayBeforeAppearanceSave": "3",
"ResendAppearanceUpdates": "false",
"WearablesRequestDelayMs": "1000",
}
for path in ("bin/OpenSim.ini", "bin/OpenSim.ini.example"):
@@ -23,4 +24,33 @@ for path in ("bin/OpenSim.ini", "bin/OpenSim.ini.example"):
appearance_index = content.index("\n[Appearance]\n")
assert appearance_index < xbakes_index, f"{path}: [Appearance] should be declared before [XBakes]"
print("OpenGenesisLINK avatar appearance cache configuration: OK")
# Guard the simulator baseline and the runtime wiring, not only profile text.
defaults = Path("bin/OpenSimDefaults.ini").read_text(encoding="utf-8")
assert "WearablesRequestDelayMs = 4000" in defaults, "legacy default must stay at 4000 ms"
factory = Path("OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs").read_text(encoding="utf-8")
for token in (
'm_wearablesRequestDelayMs = 4000',
'appearanceConfig.GetInt("WearablesRequestDelayMs", m_wearablesRequestDelayMs)',
'requestedDelay >= 500 && requestedDelay <= 4000',
'Thread.Sleep(replyDelayMs);',
):
assert token in factory, f"missing FastRez runtime guard: {token}"
assert 'Thread.Sleep(4000);' not in factory, "legacy hard-coded 4000ms sleep remains"
for path in ("bin/OpenSim.ini", "bin/OpenSim.ini.example"):
content = Path(path).read_text(encoding="utf-8")
assert "\n[InterestManagement]\n" in content, f"{path}: missing interest-management section"
section = content.split("\n[InterestManagement]\n", 1)[1].split("\n[", 1)[0]
assert "FastRezNearbyFirst = true" in section, f"{path}: FastRez world-rez opt-in missing"
scene = Path("OpenSim/Region/Framework/Scenes/Scene.cs").read_text(encoding="utf-8")
presence = Path("OpenSim/Region/Framework/Scenes/ScenePresence.cs").read_text(encoding="utf-8")
assert "public bool FastRezNearbyFirst = false;" in scene, "fast-rez opt-in default must remain off"
assert 'interestConfig.GetBoolean("FastRezNearbyFirst", FastRezNearbyFirst)' in scene
assert "if (m_scene.FastRezNearbyFirst)" in presence
assert "Vector3.DistanceSquared(origin, grp.AbsolutePosition)" in presence
assert "nearby.AddRange(distant);" in presence
assert "if (cacheEmpty || !grp.IsViewerCachable)" in presence, "viewer-cache probe handling must survive"
print("OpenGenesisLINK FastRez (avatar and near-world) configuration: OK")