diff options
| author | Dan Engelbrecht <[email protected]> | 2024-09-30 09:59:34 +0200 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2024-09-30 09:59:34 +0200 |
| commit | ebec68d49b2c968ecf684973b33f9f3d1d56b702 (patch) | |
| tree | 39de29b8d6b24d071d38254e40b5ee850b7c1299 /src/zenserver | |
| parent | optimize startup time (#175) (diff) | |
| download | zen-ebec68d49b2c968ecf684973b33f9f3d1d56b702.tar.xz zen-ebec68d49b2c968ecf684973b33f9f3d1d56b702.zip | |
gc command attachment options (#176)
* zen command - add options to control meta data cache when triggering gc
Diffstat (limited to 'src/zenserver')
| -rw-r--r-- | src/zenserver/admin/admin.cpp | 10 | ||||
| -rw-r--r-- | src/zenserver/config.cpp | 10 | ||||
| -rw-r--r-- | src/zenserver/config.h | 6 | ||||
| -rw-r--r-- | src/zenserver/projectstore/projectstore.cpp | 16 | ||||
| -rw-r--r-- | src/zenserver/projectstore/projectstore.h | 1 | ||||
| -rw-r--r-- | src/zenserver/zenserver.cpp | 9 |
6 files changed, 27 insertions, 25 deletions
diff --git a/src/zenserver/admin/admin.cpp b/src/zenserver/admin/admin.cpp index 88290171d..eb49bac51 100644 --- a/src/zenserver/admin/admin.cpp +++ b/src/zenserver/admin/admin.cpp @@ -432,6 +432,16 @@ HttpAdminService::HttpAdminService(GcScheduler& Scheduler, GcParams.AttachmentRangeMax = IoHash::FromHexString(Param); } + if (auto Param = Params.GetValue("storecacheattachmentmetadata"); Param.empty() == false) + { + GcParams.StoreCacheAttachmentMetaData = Param == "true"sv; + } + + if (auto Param = Params.GetValue("storeprojectattachmentmetadata"); Param.empty() == false) + { + GcParams.StoreProjectAttachmentMetaData = Param == "true"sv; + } + const bool Started = m_GcScheduler.TriggerGc(GcParams); CbObjectWriter Response; diff --git a/src/zenserver/config.cpp b/src/zenserver/config.cpp index 530f12ed8..7466255a9 100644 --- a/src/zenserver/config.cpp +++ b/src/zenserver/config.cpp @@ -524,11 +524,9 @@ ParseConfigFile(const std::filesystem::path& Path, "gc-compactblock-threshold"sv); LuaOptions.AddOption("gc.verbose"sv, ServerOptions.GcConfig.Verbose, "gc-verbose"sv); LuaOptions.AddOption("gc.single-threaded"sv, ServerOptions.GcConfig.SingleThreaded, "gc-single-threaded"sv); - LuaOptions.AddOption("gc.cache.attachment.store"sv, - ServerOptions.StructuredCacheConfig.StoreAttachmentMetaData, - "gc-cache-attachment-store"); + LuaOptions.AddOption("gc.cache.attachment.store"sv, ServerOptions.GcConfig.StoreCacheAttachmentMetaData, "gc-cache-attachment-store"); LuaOptions.AddOption("gc.projectstore.attachment.store"sv, - ServerOptions.ProjectStoreConfig.StoreAttachmentMetaData, + ServerOptions.GcConfig.StoreProjectAttachmentMetaData, "gc-projectstore-attachment-store"); LuaOptions.AddOption("gc.attachment.passes"sv, ServerOptions.GcConfig.AttachmentPassCount, "gc-attachment-passes"sv); @@ -921,14 +919,14 @@ ParseCliOptions(int argc, char* argv[], ZenServerOptions& ServerOptions) "", "gc-cache-attachment-store", "Enable storing attachments referenced by a cache record in block store meta data.", - cxxopts::value<bool>(ServerOptions.StructuredCacheConfig.StoreAttachmentMetaData)->default_value("false"), + cxxopts::value<bool>(ServerOptions.GcConfig.StoreCacheAttachmentMetaData)->default_value("false"), ""); options.add_option("gc", "", "gc-projectstore-attachment-store", "Enable storing attachments referenced by project oplogs in meta data.", - cxxopts::value<bool>(ServerOptions.ProjectStoreConfig.StoreAttachmentMetaData)->default_value("false"), + cxxopts::value<bool>(ServerOptions.GcConfig.StoreProjectAttachmentMetaData)->default_value("false"), ""); options.add_option("gc", diff --git a/src/zenserver/config.h b/src/zenserver/config.h index e7b734001..58a31bbb0 100644 --- a/src/zenserver/config.h +++ b/src/zenserver/config.h @@ -78,6 +78,8 @@ struct ZenGcConfig bool SingleThreaded = false; static constexpr uint16_t GcMaxAttachmentPassCount = 256; uint16_t AttachmentPassCount = 1; + bool StoreCacheAttachmentMetaData = false; + bool StoreProjectAttachmentMetaData = false; }; struct ZenOpenIdProviderConfig @@ -119,12 +121,12 @@ struct ZenStructuredCacheConfig uint64_t MemTargetFootprintBytes = 512 * 1024 * 1024; uint64_t MemTrimIntervalSeconds = 60; uint64_t MemMaxAgeSeconds = gsl::narrow<uint64_t>(std::chrono::seconds(std::chrono::days(1)).count()); - bool StoreAttachmentMetaData = false; }; struct ZenProjectStoreConfig { - bool StoreAttachmentMetaData = false; + bool StoreCacheAttachmentMetaData = false; + bool StoreProjectAttachmentMetaData = false; }; struct ZenWorkspacesConfig diff --git a/src/zenserver/projectstore/projectstore.cpp b/src/zenserver/projectstore/projectstore.cpp index 903c31ecd..4a943a565 100644 --- a/src/zenserver/projectstore/projectstore.cpp +++ b/src/zenserver/projectstore/projectstore.cpp @@ -5408,7 +5408,7 @@ public: Oplog->OplogId()); }); - Oplog->GetAttachmentsLocked(m_References, m_ProjectStore.m_Config.StoreAttachmentMetaData); + Oplog->GetAttachmentsLocked(m_References, Ctx.Settings.StoreProjectAttachmentMetaData); } FilterReferences(Ctx, fmt::format("projectstore [LOCKSTATE] '{}'", "projectstore"), m_References); } @@ -5542,7 +5542,7 @@ public: } } - Oplog->GetAttachmentsLocked(m_References, m_ProjectStore.m_Config.StoreAttachmentMetaData); + Oplog->GetAttachmentsLocked(m_References, Ctx.Settings.StoreProjectAttachmentMetaData); m_OplogAccessTime = m_Project->LastOplogAccessTime(m_OplogId); FilterReferences(Ctx, fmt::format("projectstore [PRECACHE] '{}'", m_OplogBasePath), m_References); } @@ -5588,7 +5588,7 @@ public: } }); Oplog->Read(); - Oplog->GetAttachmentsLocked(m_AddedReferences, m_ProjectStore.m_Config.StoreAttachmentMetaData); + Oplog->GetAttachmentsLocked(m_AddedReferences, Ctx.Settings.StoreProjectAttachmentMetaData); } FilterReferences(Ctx, fmt::format("projectstore [LOCKSTATE] '{}'", m_OplogBasePath), m_AddedReferences); } @@ -5804,7 +5804,7 @@ TEST_CASE("project.store.create") std::string_view ProjectName("proj1"sv); std::filesystem::path BasePath = TempDir.Path() / "projectstore"; - ProjectStore ProjectStore(CidStore, BasePath, Gc, *JobQueue, ProjectStore::Configuration{.StoreAttachmentMetaData = true}); + ProjectStore ProjectStore(CidStore, BasePath, Gc, *JobQueue, ProjectStore::Configuration{}); std::filesystem::path RootDir = TempDir.Path() / "root"; std::filesystem::path EngineRootDir = TempDir.Path() / "engine"; std::filesystem::path ProjectRootDir = TempDir.Path() / "game"; @@ -5833,7 +5833,7 @@ TEST_CASE("project.store.lifetimes") CidStore.Initialize(CidConfig); std::filesystem::path BasePath = TempDir.Path() / "projectstore"; - ProjectStore ProjectStore(CidStore, BasePath, Gc, *JobQueue, ProjectStore::Configuration{.StoreAttachmentMetaData = true}); + ProjectStore ProjectStore(CidStore, BasePath, Gc, *JobQueue, ProjectStore::Configuration{}); std::filesystem::path RootDir = TempDir.Path() / "root"; std::filesystem::path EngineRootDir = TempDir.Path() / "engine"; std::filesystem::path ProjectRootDir = TempDir.Path() / "game"; @@ -5895,7 +5895,7 @@ TEST_CASE_TEMPLATE("project.store.export", CidStore.Initialize(CidConfig); std::filesystem::path BasePath = TempDir.Path() / "projectstore"; - ProjectStore ProjectStore(CidStore, BasePath, Gc, *JobQueue, ProjectStore::Configuration{.StoreAttachmentMetaData = true}); + ProjectStore ProjectStore(CidStore, BasePath, Gc, *JobQueue, ProjectStore::Configuration{}); std::filesystem::path RootDir = TempDir.Path() / "root"; std::filesystem::path EngineRootDir = TempDir.Path() / "engine"; std::filesystem::path ProjectRootDir = TempDir.Path() / "game"; @@ -5996,7 +5996,7 @@ TEST_CASE("project.store.gc") CidStore.Initialize(CidConfig); std::filesystem::path BasePath = TempDir.Path() / "projectstore"; - ProjectStore ProjectStore(CidStore, BasePath, Gc, *JobQueue, ProjectStore::Configuration{.StoreAttachmentMetaData = true}); + ProjectStore ProjectStore(CidStore, BasePath, Gc, *JobQueue, ProjectStore::Configuration{}); std::filesystem::path RootDir = TempDir.Path() / "root"; std::filesystem::path EngineRootDir = TempDir.Path() / "engine"; @@ -6280,7 +6280,7 @@ TEST_CASE("project.store.partial.read") CidStore.Initialize(CidConfig); std::filesystem::path BasePath = TempDir.Path() / "projectstore"sv; - ProjectStore ProjectStore(CidStore, BasePath, Gc, *JobQueue, ProjectStore::Configuration{.StoreAttachmentMetaData = true}); + ProjectStore ProjectStore(CidStore, BasePath, Gc, *JobQueue, ProjectStore::Configuration{}); std::filesystem::path RootDir = TempDir.Path() / "root"sv; std::filesystem::path EngineRootDir = TempDir.Path() / "engine"sv; diff --git a/src/zenserver/projectstore/projectstore.h b/src/zenserver/projectstore/projectstore.h index 273a6d5c4..2552f657f 100644 --- a/src/zenserver/projectstore/projectstore.h +++ b/src/zenserver/projectstore/projectstore.h @@ -65,7 +65,6 @@ class ProjectStore : public RefCounted, public GcStorage, public GcContributor, public: struct Configuration { - bool StoreAttachmentMetaData = false; }; ProjectStore(CidStore& Store, std::filesystem::path BasePath, GcManager& Gc, JobQueue& JobQueue, const Configuration& Config); diff --git a/src/zenserver/zenserver.cpp b/src/zenserver/zenserver.cpp index 3c5d46a33..8d8da29b5 100644 --- a/src/zenserver/zenserver.cpp +++ b/src/zenserver/zenserver.cpp @@ -232,12 +232,7 @@ ZenServer::Initialize(const ZenServerOptions& ServerOptions, ZenServerState::Zen ZEN_INFO("instantiating project service"); - m_ProjectStore = - new ProjectStore(*m_CidStore, - m_DataRoot / "projects", - m_GcManager, - *m_JobQueue, - ProjectStore::Configuration{.StoreAttachmentMetaData = ServerOptions.ProjectStoreConfig.StoreAttachmentMetaData}); + m_ProjectStore = new ProjectStore(*m_CidStore, m_DataRoot / "projects", m_GcManager, *m_JobQueue, ProjectStore::Configuration{}); m_HttpProjectService.reset(new HttpProjectService{*m_CidStore, m_ProjectStore, m_StatsService, *m_AuthMgr}); if (ServerOptions.WorksSpacesConfig.Enabled) @@ -519,8 +514,6 @@ ZenServer::InitializeStructuredCache(const ZenServerOptions& ServerOptions) Config.NamespaceConfig.DiskLayerConfig.MemCacheTargetFootprintBytes = ServerOptions.StructuredCacheConfig.MemTargetFootprintBytes; Config.NamespaceConfig.DiskLayerConfig.MemCacheTrimIntervalSeconds = ServerOptions.StructuredCacheConfig.MemTrimIntervalSeconds; Config.NamespaceConfig.DiskLayerConfig.MemCacheMaxAgeSeconds = ServerOptions.StructuredCacheConfig.MemMaxAgeSeconds; - Config.NamespaceConfig.DiskLayerConfig.BucketConfig.StoreAttachmentMetaData = - ServerOptions.StructuredCacheConfig.StoreAttachmentMetaData; if (ServerOptions.IsDedicated) { |