Skip to content

perf: hourly death reconcile off the map's hour, character IDs without exceptions - #226

Draft
XxFran10xX wants to merge 1 commit into
mainfrom
perf/hourly-spread
Draft

XxFran10xX wants to merge 1 commit into
mainfrom
perf/hourly-spread

Conversation

@XxFran10xX

@XxFran10xX XxFran10xX commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Why

Main spark profiles (11-04) show one ~0.45 s tick every hour at restart + 1 h:

  • CharacterDeaths.reconcile (224 ms), mostly FactionDeaths.collectKeys → Members.characterId, which threw and filled a stack trace for every non-ID string in every realm snapshot (~70 ms in fillInStackTrace alone).
  • MapSystem.queueAllNations → updateMap (231 ms: faction saves and exports), plus the hourly vehicle decay and the 1- and 5-minute timers, all on the same tick.

Changes

  • Members.characterId returns null for any key that is not 36 characters with dashes at 8/13/18/23 before parsing. Only that shape can equal a UUID's own string, so results are identical. A new test checks the dash fact over every UTF-16 character, every length 0–72, and the lenient forms UUID.fromString accepts, against the old logic.
  • The hourly task (death reconcile, leaderless and held realm expiries) keeps its 1 h period. Its first run is now 30 min 30 s + 11 ticks after start, off every startup timer (1 s, 1 min, 5 min, hourly, map full update). The startup reconcile is unchanged. Every run checks the current state against the wall clock, so the only effect is that the first expiry check after a restart can come up to 29.5 min sooner, as any run in the hour already could.
  • Vehicle decay keeps its schedule: it adds damage on each run, so moving its first run would change decay per restart.

Not changed

The daily settlement (1.3 s on Main) was investigated and left alone. The province recalculation must run after the day preparation, inactivity arming and route reset on the same tick to give an identical result, and the durable writes are an ordered chain that is already parallel within each batch.

Testing

  • mvn verify on Windows: the same 28 Windows-only failures as unmodified main (directory fsync); no new failures. Linux CI is authoritative.
  • Dev: spark profile over the first 65 min after restart, the reconcile at ~+30.5 min and the map full update at ~+60 min in different minutes; death flow (journal, succession) unchanged.

Dev test

Dev (TFMCDev01, 11-05, spark 16:13–17:14): CharacterDeaths.reconcile at 16:43 (start + 30.5 min, 4 ms, no fillInStackTrace under it); MapSystem.queueAllNations and vehicle decay at 17:12–17:13 (nation.json rewritten 17:13:26). Member lists and faction menu normal; no new SF warnings.

🤖 Generated with Claude Code

…t exceptions

The hourly death reconcile ran on the same tick as the hourly vehicle decay,
the minute timers and (around then) MapSystem's full map update: 0.45 s on
one Main tick each hour. Its first run is now 30 min 30 s and 11 ticks after
start (same hourly period), off every other startup timer.

Members.characterId rejects keys that are not 36 characters with dashes at
8/13/18/23 before parsing. Only such keys can equal a UUID's own string, so
results are identical, but the reconcile's walk over every realm string no
longer throws and fills a stack trace per non-ID string (0.2 s on Main).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 5, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@github-actions github-actions Bot added the size:S 10-29 effective changed lines (tests excluded in mixed PRs). label Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 effective changed lines (tests excluded in mixed PRs).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant