Repository navigation
perf: reuse unchanged live character snapshots in identity lookups - #153
Conversation
CharacterIdentityService.info overlays every loaded account holding the character before each lookup, and that rebuilt a fresh CharacterInfo for each of the account's characters every time (colour stripping, trait sets, record copies). On Main it cost about 5 s an hour on the main thread, mostly from CompanionPets and SimpleFactions lookups through TLibs Characters.info. The directory now keeps each live character's last snapshot together with every value it was built from (owner, id, name, status, race id, trait ids, playtime, last played) and reuses it while all of them are unchanged. The check reads the live character on every lookup, so any edit, however it is made, is seen at once; no invalidation hooks are needed. Directory updates, quarantine and duplicate handling run exactly as before. The per-lookup scans of loaded accounts use plain loops instead of stream pipelines. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ner edits Review fixes: a failing read while checking a reused snapshot now just rebuilds it (so the rebuild reports the failure as before), failing to record a fresh snapshot only skips reuse, and the owner scan no longer skips reading other accounts' ids when the owner holds none. Tests now check the exact quarantine warnings, id case and owner changes against a directory fed fresh snapshots only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t edits Review round 2: the values a reused snapshot is checked against are now read before the snapshot is built, so an edit landing between the two reads can only cost a rebuild, never a stale reuse. Tests add a same-size trait list edit, compare quarantine warnings with a directory fed fresh snapshots only, and show that a character whose values cannot be recorded is rebuilt each time with the same result. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. Summary
Merge Risk:
|
|
@coderabbitai full review |
Action performed
|
Summary
CharacterIdentityService.info(through TLibsCharacters.info, called very often by CompanionPets and SimpleFactions) cost about 5 s an hour on Main's main thread. Every call scanned all online accounts with stream pipelines and rebuilt a freshCharacterInfofor every character of each matching account.LiveSnapshot: a live character's last snapshot together with every value it was built from (owner, id, name, status, race id, trait ids, playtime, last played).CharacterDirectorykeeps these per character (weak keys) and reuses one only while every value still matches. Otherwise it rebuilds with the unchangedsnapshot(), so quarantine, duplicate claims and warning text are the same as before.CharacterIdentityServiceuse plain loops instead of stream pipelines; the matching logic is unchanged.Local micro-benchmark (30 players × 3 characters): about 11 µs → 3 µs per
info().Tests
CharacterIdentityServiceTestcases: reuse until any value changes, compared with a fresh snapshot after each of 16 edits; same quarantine warnings when a character breaks after being cached; failing getters; id case and owner changes compared with a directory fed fresh snapshots only; a duplicate id differing only in case.main(directory fsync); CI is authoritative.No gameplay change.
Dev test
Dev (TFMCDev01, 11-05):
/players, placeholders and faction menu show the right character; a rename via/rpcharacter editand back shows at once everywhere; hide/unhide updates/playersand TAB; character switching followed at once. No new "Character directory unavailable" lines.🤖 Generated with Claude Code