feat: Upgrades serialization v4 (Threaded Heap Serialization) (#1947)

### Summary

- `GenericEntityPersistence` is now a type of `GenericPersistence`. This allows developers to serialize both entities and non-entities in the same system. 🎉
- Each `SerializationThreadWorker` now allocates 1MB of heap for serialization _permanently_. If more memory is needed, that thread will double it's memory, not to exceed increments of 64MB.
- Several bugs with serialization introduced with the pure MMF implementation have been fixed.
- `BinaryFileReader` has been added back. 🎉
- Adds `world.useMultithreadedSaves` to allow disabling threaded saves.

> [!IMPORTANT]
> **Developer Note**
> The split file serialization has been deprecated and is no longer used. We have effectively gone back to the same file writing we had before the pure MMF implementation.
This commit is contained in:
Kamron Batman 2024-09-14 09:57:43 -07:00 committed by GitHub
parent aaac0c596c
commit 465d3c8187
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 564 additions and 373 deletions

View file

@ -284,6 +284,10 @@ public partial class Account : IAccount, IComparable<Account>
public Serial Serial { get; set; }
public byte SerializedThread { get; set; }
public int SerializedPosition { get; set; }
public int SerializedLength { get; set; }
[AfterDeserialization(false)]
private void AfterDeserialization()
{

View file

@ -26,6 +26,10 @@ public abstract partial class BaseBOBEntry : IBOBEntry
public Serial Serial { get; }
public byte SerializedThread { get; set; }
public int SerializedPosition { get; set; }
public int SerializedLength { get; set; }
public bool Deleted { get; private set; }
public BaseBOBEntry()

View file

@ -16,6 +16,10 @@ public partial class EthicsEntity : ISerializable
public Serial Serial { get; }
public byte SerializedThread { get; set; }
public int SerializedPosition { get; set; }
public int SerializedLength { get; set; }
public bool Deleted { get; private set; }
public void Delete()

View file

@ -3968,7 +3968,14 @@ namespace Server.Gumps
InvokeCommand("Save");
}
Core.Kill(restart);
// Kill the server on a different thread otherwise we will dead lock
ThreadPool.QueueUserWorkItem(
_ =>
{
World.WaitForWriteCompletion();
Core.Kill(restart);
}
);
}
private void InvokeCommand(string c)