feat: Updates serialization to use MMF (considerable memory savings) (#1841)
### Summary Updates the serialization strategy to use `MemoryMappedFile` instead of thick buffers. This has the benefit of being on-par with the current implementation (based on hardware/OS), however won't incur the double-memory issue. > [!Important] > **Developer Note** > The `BinaryFileWriter` and `BinaryFileReader` has been removed in favor of `MemoryMapFileWriter` and `UnmanagedDataReader`
This commit is contained in:
parent
3b84c8052c
commit
8ec203f387
27 changed files with 1271 additions and 941 deletions
|
|
@ -1,6 +1,6 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright 2019-2023 - ModernUO Development Team *
|
||||
* Copyright 2019-2024 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: Main.cs *
|
||||
* *
|
||||
|
|
@ -40,6 +40,7 @@ public static class Core
|
|||
private static bool _performProcessKill;
|
||||
private static bool _restartOnKill;
|
||||
private static bool _performSnapshot;
|
||||
private static string _snapshotPath;
|
||||
private static bool _crashed;
|
||||
private static string _baseDirectory;
|
||||
|
||||
|
|
@ -411,7 +412,6 @@ public static class Core
|
|||
logger.Information("Shutting down");
|
||||
|
||||
World.WaitForWriteCompletion();
|
||||
|
||||
World.ExitSerializationThreads();
|
||||
|
||||
if (!_crashed)
|
||||
|
|
@ -553,12 +553,13 @@ public static class Core
|
|||
if (_performSnapshot)
|
||||
{
|
||||
// Return value is the offset that can be used to fix timers that should drift
|
||||
World.Snapshot();
|
||||
World.Snapshot(_snapshotPath);
|
||||
_performSnapshot = false;
|
||||
}
|
||||
|
||||
if (_performProcessKill)
|
||||
{
|
||||
World.WaitForWriteCompletion();
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -594,7 +595,11 @@ public static class Core
|
|||
DoKill(_restartOnKill);
|
||||
}
|
||||
|
||||
internal static void RequestSnapshot() => _performSnapshot = true;
|
||||
internal static void RequestSnapshot(string snapshotPath)
|
||||
{
|
||||
_performSnapshot = true;
|
||||
_snapshotPath = snapshotPath;
|
||||
}
|
||||
|
||||
public static void VerifySerialization()
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue