perf(autotell): replace lock-protected count with Interlocked counter

F2.1: ActiveTempTabCount was doing a LINQ Count under _tempTabsLock on
every read, including the hot-path HandleTell guard. Replace with an
Interlocked counter kept in sync with Config.Tabs from inside the
existing mutation paths (SpawnTempTab, DropOldestTempTab, OnLogout).
Initialize from the persisted Tabs list on Initialize() to handle
configs that already contain TempTabs from a prior session.

Plugin.cs SaveConfig snapshot-restore mutates Config.Tabs outside of
AutoTellTabsService; expose ResyncTempTabCounter() and call it after
AddRange so the counter stays consistent. Plugin.cs:168 crash-recovery
RemoveAll runs before Initialize() and is covered by the init snapshot.
This commit is contained in:
2026-05-12 09:06:20 +02:00
parent 5c550e8587
commit 11ad5db127
2 changed files with 39 additions and 11 deletions
+5
View File
@@ -641,6 +641,11 @@ public sealed class Plugin : IAsyncDalamudPlugin
Config.Tabs.Clear();
Config.Tabs.AddRange(snapshot);
// F2.1: snapshot-restore preserves IsTempTab tabs but the mid-step
// RemoveAll bypasses AutoTellTabsService, so re-peg the counter.
// Null-conditional because SaveConfig can fire before Phase-2 init.
AutoTellTabsService?.ResyncTempTabCounter();
}
internal void LanguageChanged(string langCode)