perf(settings): write config on release instead of every slider frame

ImGui sliders report a change in every frame the value moves, so dragging one
rewrote the full 31 KB config to disk per frame -- serialize, fsync and rename,
synchronously on the draw thread. Measured on Linux/Wine that showed up as a
114 ms frame while the plugin itself only drew for 2.9 ms; the rest was waiting
on the write.

The five shared slider helpers now defer SaveConfig to IsItemDeactivatedAfterEdit,
matching what ChatColourPicker already did for the colour wheel.

Renaming a tab needed its own path: the input lives inside a popup, and ImGui
never re-submits it when the popup is dismissed by clicking outside, so
IsItemDeactivatedAfterEdit would not fire and the new name would be lost. A
pending-rename marker scoped to the owning tab flushes it when the popup is
gone -- scoped, because every other tab's Draw reaches that branch too.

DeferredSaveFrames is removed: the debounce was fully wired but never armed,
and this approach makes it redundant.
This commit is contained in:
2026-08-17 06:49:53 +02:00
parent 99dca8cb31
commit d2da51a4f7
6 changed files with 54 additions and 31 deletions
-20
View File
@@ -175,8 +175,6 @@ public sealed class Plugin : IAsyncDalamudPlugin
// PerformanceBaselineStep so the hot path stays allocation-free.
internal double LastDrawMs;
internal int DeferredSaveFrames = -1;
// Cancels the v1.4.8 FTS5 bulk-insert worker on plugin teardown. The
// worker runs off the framework thread on its own SqliteConnection, so a
// Dispose mid-rebuild must signal cancellation before MessageManager
@@ -277,8 +275,6 @@ public sealed class Plugin : IAsyncDalamudPlugin
ImGuiUtil.Initialize(this);
DeferredSaveFrames = -1;
// Custom themes dir + seed run before the container builds so the
// ThemeRegistry factory lambda finds the directory ready.
var customThemesDir = Path.Combine(Interface.ConfigDirectory.FullName, "themes");
@@ -641,19 +637,6 @@ public sealed class Plugin : IAsyncDalamudPlugin
}
);
// Flush a pending DeferredSave — FrameworkUpdate won't fire it anymore.
failure = CaptureFailure(
failure,
() =>
{
if (DeferredSaveFrames >= 0)
{
SaveConfig();
DeferredSaveFrames = -1;
}
}
);
// Framework-thread cleanup the container does not reach.
try
{
@@ -1134,9 +1117,6 @@ public sealed class Plugin : IAsyncDalamudPlugin
private void FrameworkUpdate(IFramework framework)
{
if (DeferredSaveFrames >= 0 && DeferredSaveFrames-- == 0)
SaveConfig();
if (!Config.HideChat)
return;