diff options
| author | Stefan Boberg <[email protected]> | 2025-06-27 15:36:23 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2025-06-27 15:36:23 +0200 |
| commit | b9ee86fb373b11e30806adb6027570eeabd428ee (patch) | |
| tree | 2880f811c45ab8a57de129e2586080df6044a8ce /src | |
| parent | fleshed out RPC recording analysis command, now parses every request (diff) | |
| download | zen-b9ee86fb373b11e30806adb6027570eeabd428ee.tar.xz zen-b9ee86fb373b11e30806adb6027570eeabd428ee.zip | |
added initial tracking of namespaces, buckets, keys
Diffstat (limited to 'src')
| -rw-r--r-- | src/zen/cmds/rpcreplay_cmd.cpp | 170 |
1 files changed, 137 insertions, 33 deletions
diff --git a/src/zen/cmds/rpcreplay_cmd.cpp b/src/zen/cmds/rpcreplay_cmd.cpp index b45f3f50a..231244450 100644 --- a/src/zen/cmds/rpcreplay_cmd.cpp +++ b/src/zen/cmds/rpcreplay_cmd.cpp @@ -520,6 +520,130 @@ RpcReplayAnalyzeCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char* ZEN_CONSOLE("Recording entry count = {}", EntryCount); + ///////////////////////////////////////////////////////////////////////// + // + // output schema sketch: + + // namespaces + // + // <namespace_id>,<namespace> + + struct Namespaces + { + // NOTE: *NOT* thread safe at this time + + struct NamespaceInfo + { + int Id; + uint32_t Hash; + std::string Name; + }; + + std::vector<NamespaceInfo> Namespaces; + + int NamespaceToId(const std::string_view Namespace) + { + const uint32_t NamespaceHash = HashStringDjb2(Namespace); + + for (const auto& Ns : Namespaces) + { + if (NamespaceHash == Ns.Hash) + { + return Ns.Id; + } + } + + int Id = (int)Namespaces.size(); + + Namespaces.push_back(NamespaceInfo{.Id = Id, .Hash = NamespaceHash, .Name = std::string(Namespace)}); + + return Id; + }; + }; + + Namespaces Ns; + + // buckets + // + // <bucket_id>,<bucket> + + struct Buckets + { + // NOTE: *NOT* thread safe at this time + + struct BucketInfo + { + int Id; + uint32_t Hash; + std::string Name; + }; + + std::vector<BucketInfo> Buckets; + + int BucketToId(const std::string_view Bucket) + { + const uint32_t BucketHash = HashStringDjb2(Bucket); + + for (const auto& Ns : Buckets) + { + if (BucketHash == Ns.Hash) + { + return Ns.Id; + } + } + + int Id = (int)Buckets.size(); + + Buckets.push_back(BucketInfo{.Id = Id, .Hash = BucketHash, .Name = std::string(Bucket)}); + + return Id; + }; + }; + + Buckets Bs; + + // keys + // + // <key_id>,<bucket_id>,<key> + + struct Keys + { + // NOTE: *NOT* thread safe at this time + + struct KeyInfo + { + uint32_t Id; + uint32_t BucketId; + IoHash Hash; + }; + + std::vector<KeyInfo> Keys; + + int KeyToId(uint32_t BucketId, const IoHash& Hash) + { + ZEN_UNUSED(BucketId, Hash); + return 0; + }; + }; + + Keys Ks; + + // sessions + // + // <session_id>,<session> + + // rpc_requests - one entry per recorded RPC request + // + // <rpc_id>,<session_id>,<namespace_id>,<method>,<request_size>,<attachment_count> + + // payloads - one entry per package attachment, one entry per unstructured value + // + // <rpc_id>,<payload_index>,<payload_hash>,<payload_size> + + // requests + // + // <request_id>,<rpc_id>,<key_id>,<payload_hash> + const uint64_t RangeStart = m_Offset; const uint64_t RangeEnd = m_Limit ? (m_Offset + m_Limit) : EntryCount; @@ -581,11 +705,23 @@ RpcReplayAnalyzeCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char* return; } + const int NsId = Ns.NamespaceToId(Gcv.Namespace); + const auto BatchSize = Gcv.Requests.size(); for (const auto& Req : Gcv.Requests) { - ZEN_CONSOLE("[{}] GCV {}/{}", BatchSize, Req.Key.Bucket, Req.Key.Hash); + const int BsId = Bs.BucketToId(Req.Key.Bucket); + const int KId = Ks.KeyToId(BsId, Req.Key.Hash); + + ZEN_CONSOLE("[{}] GCV ({}){}/({}){}/({}){}", + BatchSize, + NsId, + Gcv.Namespace, + BsId, + Req.Key.Bucket, + KId, + Req.Key.Hash); } } break; @@ -675,38 +811,6 @@ RpcReplayAnalyzeCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char* } }); - ///////////////////////////////////////////////////////////////////////// - // - // output schema sketch: - - // namespaces - // - // <namespace_id>,<namespace> - - // buckets - // - // <bucket_id>,<bucket> - - // keys - // - // <key_id>,<bucket_id>,<key> - - // sessions - // - // <session_id>,<session> - - // rpc_requests - one entry per recorded RPC request - // - // <rpc_id>,<session_id>,<namespace_id>,<method>,<request_size>,<attachment_count> - - // payloads - one entry per package attachment, one entry per unstructured value - // - // <rpc_id>,<payload_index>,<payload_hash>,<payload_size> - - // requests - // - // <request_id>,<rpc_id>,<key_id>,<payload_hash> - return 0; } |