ModernUO/Projects/UOContent/Gumps
Kamron Batman 0628902644
fix: harden idle-sleep scheduling against bad config and misattributed saves (#2567)
Follow-ups to #2559, from a review of the ported idle-sleep/scheduler-health changes.

### Fixes

- **`NetState.IsIdle` omitted `_pendingDisconnects`** — `Slice()` drains five queues; the property checked four. The other deferred work (`_connectingQueue`, alive checks, movement throttle) is time-gated and correctly excluded; the disconnect queue was the only ready-work omission. Impact was bounded (≤ one idle wait of delay), but the property's contract is "sleeping cannot strand pending work".
- **Neither new setting was clamped** (`Main.cs`):
  - `server.lateWakeThreshold: -1` made `late <= threshold` false for every sample even at zero late wakes, so from the second sample on, sleeping was re-suspended every second, forever — a permanent full-core spin whose only trace was a nonsense warning ("… at least 8ms late 0 time(s)").
  - `server.eventLoopIdleWaitMs: -1` disabled sleeping while the admin gump reported **Healthy** (it tested `== 0`).
  - Both now clamp to `>= 0` and log a warning naming the configured value. `-1` is a natural thing to reach for given the sibling key's doc says "set very high to disable".
- **World snapshots were misattributed to `StolenMs`** — `World.Snapshot` ran outside all five profiler phases, so a 3-second save inside a sample read as ~75% stolen, and `debugging-event-loop.md` teaches stolen = "the host ran something else". The diagnostic pointed operators at buying dedicated CPU for their own largest loop-thread stall. Saves now land in a new `WorldSnapshot` phase; `[LoopStats` iterates `PhaseCount` generically, so the report and CSV pick it up with no changes.
- **Admin gump conflated host-forced spin with configured spin** — when the startup probe finds no high-resolution wait support it zeroes the idle wait, after which the gump said "Spinning (configured)" and the operator's config said 2. New `Core.IdleSleepUnsupported` property; the gump now shows "Spinning - host cannot honor short waits" as a distinct fourth verdict. A genuinely configured 0 still reads "configured" (the probe only runs when the configured value was > 0).
- **The backoff-ceiling `Error` logged once per process lifetime** — `_loggedBackoffCeiling` never reset, and at the ceiling the method returns before the `Warning`, so a host that recovered (>60s clean streak) and later degraded back to the ceiling never re-logged the one operator-actionable message. The flag now resets with the clean-streak escalation reset.
- **Removed the unreachable "already suspended, extend" branch** — no sleeps occur while suspended, so `_lateWakes` stays 0 and every suspended sample early-returns before reaching it; with the threshold clamped it can never fire. If sleep gating ever changes, the normal path handles the case by counting a fresh episode.

`dev-docs/debugging-event-loop.md` updated to match (phase list + gump verdict table).

### Verification

- `dotnet build` clean (0 warnings) both normally and with `-p:EventLoopProfiling=true` (the snapshot phase only becomes live IL under the profiling flag).
2026-08-09 22:05:18 -07:00
..
Base fix: Warn when sending empty gumps (#2563) 2026-08-08 00:55:12 -07:00
Go perf: Migrate Travel/Moongate gumps to DynamicGump (#2412) 2026-04-25 17:03:24 -07:00
Guilds perf: Migrates New Guild System gumps from legacy Gump. (#2422) 2026-05-03 00:09:22 -07:00
Houses perf: Migrate HouseGumpAOS to DynamicGump (#2429) 2026-05-03 09:52:17 -07:00
Props feat: Consolidates staff gump layouts (#2404) 2026-04-08 11:42:46 -06:00
AddDoorGump.cs fix: Rewrites AddDoor command, fixes gump and returning to correct page. (#2056) 2025-01-08 10:32:37 -08:00
AdminGump.cs fix: harden idle-sleep scheduling against bad config and misattributed saves (#2567) 2026-08-09 22:05:18 -07:00
BanDurationGump.cs chore: Removes dead gump code (#2403) 2026-04-08 08:39:23 -06:00
BaseConfirmGump.cs fix: Fixes issue with cached static gump strings. Fixes bad gump colors (#1771) 2024-05-10 22:44:16 -07:00
BaseGridGump.cs fix: Consolidates Color/Center html (#1762) 2024-05-07 23:56:32 -07:00
BaseImageTileButtonsGump.cs fix: Optimizes gump relay info (Prep for Static Gumps) (#1698) 2024-03-07 20:54:53 -08:00
ClientGump.cs feat: Adds size/style support to gump builders, optimizes EscapeHtml (#2257) 2025-11-23 11:35:31 -08:00
CommentsGump.cs perf: Migrate NPC and Skill UI gumps to DynamicGump/StaticGump (#2414) 2026-04-25 19:51:42 -07:00
ConfirmBreakCrystalGump.cs Fixes brace style (#248) 2020-09-13 21:49:46 -07:00
ConfirmHeritageGump.cs perf: Migrate Item Interaction gumps to DynamicGump/StaticGump (#2421) 2026-04-26 11:31:49 -07:00
ConfirmReleaseGump.cs feat: Moves gumps out of the core (#1916) 2024-08-09 19:07:32 -07:00
HeritageTokenGump.cs perf: Migrate Item Interaction gumps to DynamicGump/StaticGump (#2421) 2026-04-26 11:31:49 -07:00
NoticeGump.cs fix: Adds static warning/notice gumps. (#1741) 2024-04-26 17:19:16 -07:00
PetResurrectGump.cs feat: Adds size/style support to gump builders, optimizes EscapeHtml (#2257) 2025-11-23 11:35:31 -08:00
PlayerVendorGumps.cs perf: Migrate PlayerVendor gumps to DynamicGump/StaticGump (#2430) 2026-05-03 10:04:12 -07:00
PolymorphGump.cs chore: Removes dead gump code (#2403) 2026-04-08 08:39:23 -06:00
ReclaimVendorGump.cs perf: Migrate vendor management gumps to DynamicGump/StaticGump (#2431) 2026-05-03 10:19:12 -07:00
ResurrectGump.cs fix: Fixes priced healer resurrection when not choosing the correct option (#2276) 2025-11-23 09:58:33 -08:00
RewardGump.cs perf: Migrate RewardGump to DynamicGump (#2432) 2026-05-03 10:22:52 -07:00
RunebookGump.cs fix: Actions on gump crash when Runebook has no entries (#1964) 2024-09-27 10:17:22 -07:00
SelectAddonDirectionGump.cs feat: Standardizes South/East selection gumps (#1839) 2025-02-14 00:15:14 -08:00
SkillsGump.cs feat: Consolidates staff gump layouts (#2404) 2026-04-08 11:42:46 -06:00
StaticNoticeGump.cs fix: Adds static warning/notice gumps. (#1741) 2024-04-26 17:19:16 -07:00
StaticWarningGump.cs feat: Adds size/style support to gump builders, optimizes EscapeHtml (#2257) 2025-11-23 11:35:31 -08:00
TithingGump.cs fix: Adds missing string interpolation handler for SetStringSlot (#2123) 2025-02-13 19:30:47 -08:00
ToTAdminGump.cs chore: Removes dead gump code (#2403) 2026-04-08 08:39:23 -06:00
VendorInventoryGump.cs feat: Pre-Publish 14 Crafting (supersedes #2181, #2381) (#2476) 2026-06-07 20:27:22 -07:00
VendorRentalGumps.cs perf: Migrate vendor management gumps to DynamicGump/StaticGump (#2431) 2026-05-03 10:19:12 -07:00
ViewHousesGump.cs feat: Adds size/style support to gump builders, optimizes EscapeHtml (#2257) 2025-11-23 11:35:31 -08:00
VirtualCheckGump.cs fix: Bumps deps. Updates copyrights (#2353) 2026-03-05 19:36:54 -08:00
WarningGump.cs fix: Fixes issue with cached static gump strings. Fixes bad gump colors (#1771) 2024-05-10 22:44:16 -07:00
WhoGump.cs feat: Consolidates staff gump layouts (#2404) 2026-04-08 11:42:46 -06:00
YoungGumps.cs feat: Restyle young player gumps (#1917) 2024-08-10 11:06:18 -07:00