aboutsummaryrefslogtreecommitdiff
path: root/src/zenserver/main.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2023-11-16 17:20:52 +0100
committerGitHub <[email protected]>2023-11-16 17:20:52 +0100
commit372d3a8a1ff65e53d139a7ee1db022d8cfa55982 (patch)
treedf88c47001bf16c15d12dcfba8cf8850d7e85cbd /src/zenserver/main.cpp
parentchanged posix event implementation to use std::atomic instead of volatile (#547) (diff)
downloadzen-372d3a8a1ff65e53d139a7ee1db022d8cfa55982.tar.xz
zen-372d3a8a1ff65e53d139a7ee1db022d8cfa55982.zip
add zenserver state snapshot support (#543)
this introduces a --snapshot-dir command line option to zenserver which specifies a directory which will be propagated to the persistence root directory on start-up. This is most powerful with file systems which support block cloning, such as ReFS on Windows. This allows even very large state snapshots to be used repeatedly without having to worry about mutating the original dataset on disk. When using ReFS the state copy for even large state directories can be very fast since the duration is primarily proportional to the number of files in the tree rather than the size of the files being cloned. The storage requirements are also minimal as all data will be handled in a copy-on-write manner.
Diffstat (limited to 'src/zenserver/main.cpp')
-rw-r--r--src/zenserver/main.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/zenserver/main.cpp b/src/zenserver/main.cpp
index 44330d4c8..1aa0aa4df 100644
--- a/src/zenserver/main.cpp
+++ b/src/zenserver/main.cpp
@@ -336,7 +336,7 @@ main(int argc, char* argv[])
ZenServerOptions ServerOptions;
ParseCliOptions(argc, argv, ServerOptions);
- if (ServerOptions.IsCleanStart)
+ if (ServerOptions.IsCleanStart || !ServerOptions.BaseSnapshotDir.empty())
{
DeleteDirectories(ServerOptions.DataDir);
}
@@ -347,6 +347,11 @@ main(int argc, char* argv[])
std::filesystem::create_directories(ServerOptions.DataDir);
}
+ if (!ServerOptions.BaseSnapshotDir.empty())
+ {
+ CopyTree(ServerOptions.BaseSnapshotDir, ServerOptions.DataDir, {.EnableClone = true});
+ }
+
#if ZEN_WITH_TRACE
if (ServerOptions.TraceHost.size())
{