ModernUO/Projects/Server/Serialization
Kamron Batman 3b75b96008
perf(saves): drop the 9-byte per-entity placement state; write snapshots from worker segment logs
Every ISerializable carried SerializedThread/SerializedPosition/SerializedLength
so WriteSnapshot could gather each entity's bytes from the worker heaps in
dictionary order. The idx records absolute positions, so bin order is free -
the snapshot can be written in worker-heap order instead, and the join inverts:

- Chunks are persistence-homogeneous: SerializeAll declares the owner at each
  boundary, publishing the partial chunk on change.
- Workers log segments (owner, slot range, heap start) plus one length per
  record as they serialize. Positions are implicit because a worker's writes
  are contiguous; identity comes from re-walking the same snapshot slots in
  the same order (guaranteed stable - mutations divert to the pending queues
  until PostWorldSave), or from an entities log on the fallback path.
- WriteSnapshot routes segments by owner, emits idx entries during the
  re-walk, and writes each segment's heap bytes as a single span instead of
  one copy per entity, which also speeds up the background write phase.
- Persistence self-payloads keep placement as three private fields on the
  ~dozens of persistence instances; PushSingle is now typed accordingly.

Net effect: 9 bytes (plus padding) of resident state removed from every item,
mobile, guild, and account on every shard; three interface-property stores
per entity leave the drain hot path (stamping dirtied one cache line per
entity mid-freeze - the lengths log is a single sequential stream); and the
vestigial loader-side length stamp is gone. The transient cost is ~4 bytes
per entity in pooled per-worker logs that are released after each write.

The save format is unchanged (idx v3, same loader); only the write-side
mechanics moved. Adds an end-to-end round-trip test that drives real workers
through the chunk source, snapshots from the segment logs, and reloads.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-16 22:38:47 -07:00
..
Attributes fix: Bumps deps. Updates copyrights (#2353) 2026-03-05 19:36:54 -08:00
AdhocPersistence.cs fix: Bumps deps. Updates copyrights (#2353) 2026-03-05 19:36:54 -08:00
BinaryFileReader.cs fix: Bumps deps. Updates copyrights (#2353) 2026-03-05 19:36:54 -08:00
BufferReader.cs fix: Bumps deps. Updates copyrights (#2353) 2026-03-05 19:36:54 -08:00
BufferWriter.cs perf(saves): 2.2x faster BufferWriter write path, single-pass short strings 2026-07-16 22:38:46 -07:00
GenericEntityPersistence.cs perf(saves): drop the 9-byte per-entity placement state; write snapshots from worker segment logs 2026-07-16 22:38:47 -07:00
GenericPersistence.cs perf(saves): drop the 9-byte per-entity placement state; write snapshots from worker segment logs 2026-07-16 22:38:47 -07:00
IGenericReader.cs fix: Bumps deps. Updates copyrights (#2353) 2026-03-05 19:36:54 -08:00
IGenericSerializable.cs perf(saves): drop the 9-byte per-entity placement state; write snapshots from worker segment logs 2026-07-16 22:38:47 -07:00
IGenericWriter.cs fix: Bumps deps. Updates copyrights (#2353) 2026-03-05 19:36:54 -08:00
ISerializable.cs fix: Bumps deps. Updates copyrights (#2353) 2026-03-05 19:36:54 -08:00
ISerializableExtensions.cs fix: Bumps deps. Updates copyrights (#2353) 2026-03-05 19:36:54 -08:00
MemoryMapFileWriter.cs fix: Bumps deps. Updates copyrights (#2353) 2026-03-05 19:36:54 -08:00
Persistence.cs perf(saves): drop the 9-byte per-entity placement state; write snapshots from worker segment logs 2026-07-16 22:38:47 -07:00
SerializationChunkSource.cs perf(saves): drop the 9-byte per-entity placement state; write snapshots from worker segment logs 2026-07-16 22:38:47 -07:00
SerializationExtensions.cs feat: Refactor Poison system, implement Darkglow & Parasitic effects (#2385) 2026-03-21 21:27:22 -07:00
SerializationThreadWorker.cs perf(saves): drop the 9-byte per-entity placement state; write snapshots from worker segment logs 2026-07-16 22:38:47 -07:00
ShadowDictionaryEntries.cs perf(saves): workers iterate entity dictionaries directly; main thread joins the drain 2026-07-16 22:38:46 -07:00
UnmanagedDataReader.cs fix: Bumps deps. Updates copyrights (#2353) 2026-03-05 19:36:54 -08:00