-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optionally collect metrics from rpc requests and responses (#982)
This commit adds two flags to both typed and untyped RPC TL query builtins. 'requests_extra_info' parameter collects extra info about sent RPC requests: 'request_size'. 'need_responses_extra_info' tells the runtime to collect extra info about RPC response associated with the RPC request. This info may later be extracted with new 'extract_kphp_rpc_response_extra_info' builtin.
- Loading branch information
Showing
26 changed files
with
1,072 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Compiler for PHP (aka KPHP) | ||
// Copyright (c) 2024 LLC «V Kontakte» | ||
// Distributed under the GPL v3 License, see LICENSE.notice.txt | ||
|
||
#include "runtime/rpc_extra_info.h" | ||
|
||
|
||
array<std::pair<rpc_response_extra_info_status_t, rpc_response_extra_info_t>> rpc_responses_extra_info_map; | ||
|
||
array<rpc_request_extra_info_t> f$KphpRpcRequestsExtraInfo$$get(class_instance<C$KphpRpcRequestsExtraInfo> v$this) { | ||
return v$this->extra_info_arr_; | ||
} | ||
|
||
Optional<rpc_response_extra_info_t> f$extract_kphp_rpc_response_extra_info(std::int64_t resumable_id) { | ||
const auto *resp_extra_info_ptr = rpc_responses_extra_info_map.find_value(resumable_id); | ||
|
||
if (resp_extra_info_ptr == nullptr || resp_extra_info_ptr->first == rpc_response_extra_info_status_t::NOT_READY) { | ||
return {}; | ||
} | ||
|
||
const auto res = resp_extra_info_ptr->second; | ||
rpc_responses_extra_info_map.unset(resumable_id); | ||
return res; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Compiler for PHP (aka KPHP) | ||
// Copyright (c) 2024 LLC «V Kontakte» | ||
// Distributed under the GPL v3 License, see LICENSE.notice.txt | ||
|
||
#pragma once | ||
|
||
#include <tuple> | ||
#include <cstdint> | ||
|
||
#include "runtime/kphp_core.h" | ||
#include "runtime/dummy-visitor-methods.h" | ||
#include "runtime/refcountable_php_classes.h" | ||
#include "common/algorithms/hashes.h" | ||
#include "common/wrappers/string_view.h" | ||
|
||
|
||
using rpc_request_extra_info_t = std::tuple<std::int64_t>; // tuple(request_size) | ||
using rpc_response_extra_info_t = std::tuple<std::int64_t, double>; // tuple(response_size, response_time) | ||
enum class rpc_response_extra_info_status_t : std::uint8_t { NOT_READY, READY }; | ||
|
||
extern array<std::pair<rpc_response_extra_info_status_t, rpc_response_extra_info_t>> rpc_responses_extra_info_map; | ||
|
||
struct C$KphpRpcRequestsExtraInfo final : public refcountable_php_classes<C$KphpRpcRequestsExtraInfo>, private DummyVisitorMethods { | ||
using DummyVisitorMethods::accept; | ||
|
||
array<rpc_request_extra_info_t> extra_info_arr_; | ||
|
||
C$KphpRpcRequestsExtraInfo() = default; | ||
|
||
const char *get_class() const noexcept { | ||
return R"(KphpRpcRequestsExtraInfo)"; | ||
} | ||
|
||
int get_hash() const noexcept { | ||
return static_cast<std::int32_t>(vk::std_hash(vk::string_view(C$KphpRpcRequestsExtraInfo::get_class()))); | ||
} | ||
}; | ||
|
||
array<rpc_request_extra_info_t> f$KphpRpcRequestsExtraInfo$$get(class_instance<C$KphpRpcRequestsExtraInfo> v$this); | ||
|
||
Optional<rpc_response_extra_info_t> f$extract_kphp_rpc_response_extra_info(std::int64_t resumable_id); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.