diff options
| author | Stefan Boberg <[email protected]> | 2023-12-19 23:10:10 +0100 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2023-12-19 23:10:10 +0100 |
| commit | 1d8630c61942ece7ae86d53cb289874bb6eb7918 (patch) | |
| tree | 30b36a5489cb814737dabc284e9b673245a049b9 | |
| parent | added _djb2 and _djb2lower string literals (diff) | |
| download | zen-1d8630c61942ece7ae86d53cb289874bb6eb7918.tar.xz zen-1d8630c61942ece7ae86d53cb289874bb6eb7918.zip | |
added rpc analyze --output and skeleton for analysis
| -rw-r--r-- | src/zen/cmds/rpcreplay_cmd.cpp | 46 |
1 files changed, 33 insertions, 13 deletions
diff --git a/src/zen/cmds/rpcreplay_cmd.cpp b/src/zen/cmds/rpcreplay_cmd.cpp index 4a68803ae..0b6236cb5 100644 --- a/src/zen/cmds/rpcreplay_cmd.cpp +++ b/src/zen/cmds/rpcreplay_cmd.cpp @@ -17,6 +17,9 @@ #include <zenhttp/httpshared.h> #include <zenutil/cache/rpcrecording.h> +#include <zencore/jobqueue.h> +#include <zenstore/structuredcachestore.h> + ZEN_THIRD_PARTY_INCLUDES_START #include <cpr/cpr.h> #include <fmt/format.h> @@ -506,7 +509,12 @@ RpcAnalyzeCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv if (m_RecordingPath.empty()) { - throw zen::OptionParseException("Rpc replay command requires a path"); + throw zen::OptionParseException("Rpc analyze command requires a recording path"); + } + + if (m_ReportPath.empty()) + { + throw zen::OptionParseException("Rpc analyze command requires an output path"); } if (!std::filesystem::exists(m_RecordingPath) || !std::filesystem::is_directory(m_RecordingPath)) @@ -514,6 +522,15 @@ RpcAnalyzeCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv throw std::runtime_error(fmt::format("could not find recording at '{}'", m_RecordingPath)); } + std::filesystem::path TargetPath = m_ReportPath; + + ZenCacheStore::Configuration Config; + Config.AllowAutomaticCreationOfNamespaces = true; + + GcManager Gc; + std::unique_ptr<JobQueue> Jq = MakeJobQueue(2, "cache_jobs"); + Ref<ZenCacheStore> Store(new ZenCacheStore(Gc, *Jq, TargetPath, Config, nullptr)); + std::unique_ptr<cache::IRpcRequestReplayer> Replayer = cache::MakeDiskRequestReplayer(m_RecordingPath, true); const uint64_t EntryCount = Replayer->GetRequestCount(); @@ -557,14 +574,8 @@ RpcAnalyzeCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv continue; } - static constexpr uint32_t kGetCacheValues = HashStringAsLowerDjb2("GetCacheValues"sv); - static constexpr uint32_t kGetCacheRecords = HashStringAsLowerDjb2("GetCacheRecords"sv); - static constexpr uint32_t kPutCacheValues = HashStringAsLowerDjb2("PutCacheValues"sv); - static constexpr uint32_t kPutCacheRecords = HashStringAsLowerDjb2("PutCacheRecords"sv); - static constexpr uint32_t kGetCacheChunks = HashStringAsLowerDjb2("GetCacheChunks"sv); - std::string_view MethodString = Request["Method"sv].AsString(); - const uint32_t MethodHash = HashStringAsLowerDjb2(MethodString); + const uint32_t MethodHash = HashStringDjb2(MethodString); if (auto It = RequestMethods.find(MethodHash); It == RequestMethods.end()) { @@ -596,18 +607,25 @@ RpcAnalyzeCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv switch (MethodHash) { - case HashStringAsLowerDjb2("GetCacheValues"sv): + case "GetCacheValues"_djb2: break; - case HashStringAsLowerDjb2("GetCacheRecords"sv): + case "GetCacheRecords"_djb2: break; - case HashStringAsLowerDjb2("PutCacheValues"sv): + case "PutCacheValues"_djb2: break; - case HashStringAsLowerDjb2("PutCacheRecords"sv): + case "PutCacheRecords"_djb2: break; - case HashStringAsLowerDjb2("GetCacheChunks"sv): + case "GetCacheChunks"_djb2: break; } +#if 0 + static constexpr uint32_t kGetCacheValues = HashStringAsLowerDjb2("GetCacheValues"sv); + static constexpr uint32_t kGetCacheRecords = HashStringAsLowerDjb2("GetCacheRecords"sv); + static constexpr uint32_t kPutCacheValues = HashStringAsLowerDjb2("PutCacheValues"sv); + static constexpr uint32_t kPutCacheRecords = HashStringAsLowerDjb2("PutCacheRecords"sv); + static constexpr uint32_t kGetCacheChunks = HashStringAsLowerDjb2("GetCacheChunks"sv); + if (MethodHash == kGetCacheValues) { /* @@ -749,6 +767,8 @@ RpcAnalyzeCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv */ } +#endif + // ZEN_CONSOLE("key: {}/{}", Bucket, Hash); } |