|
6 | 6 |
|
7 | 7 | #include <algorithm> |
8 | 8 | #include <cstddef> |
| 9 | +#include <memory> |
9 | 10 | #include <span> |
10 | 11 | #include <string_view> |
11 | 12 | #include <utility> |
12 | 13 |
|
| 14 | +#include "common/containers/final_action.h" |
13 | 15 | #include "runtime-common/core/allocator/script-allocator.h" |
14 | 16 | #include "runtime-common/core/runtime-core.h" |
15 | 17 | #include "runtime-common/core/std/containers.h" |
@@ -52,11 +54,20 @@ kphp::coro::task<mixed> f$confdata_get_value(string key) noexcept { |
52 | 54 | co_return mixed{}; |
53 | 55 | } |
54 | 56 |
|
55 | | - auto& confdata_key_cache{ConfdataInstanceState::get().key_cache()}; |
| 57 | + auto& confdata_instance_st{ConfdataInstanceState::get()}; |
| 58 | + auto& confdata_key_cache{confdata_instance_st.key_cache()}; |
56 | 59 | if (auto it{confdata_key_cache.find(key)}; it != confdata_key_cache.end()) { |
57 | 60 | co_return it->second; |
58 | 61 | } |
59 | 62 |
|
| 63 | + k2::SystemTime start_time{}; |
| 64 | + k2::system_time(std::addressof(start_time)); |
| 65 | + const auto finalizer{vk::finally([&start_time, &confdata_instance_st] noexcept { |
| 66 | + k2::SystemTime end_time{}; |
| 67 | + k2::system_time(std::addressof(end_time)); |
| 68 | + confdata_instance_st.time_ns += (end_time.since_epoch_ns - start_time.since_epoch_ns); |
| 69 | + })}; |
| 70 | + |
60 | 71 | tl::ConfdataGet confdata_get{.key = {.value = {key.c_str(), key.size()}}}; |
61 | 72 | tl::storer tls{confdata_get.footprint()}; |
62 | 73 | confdata_get.store(tls); |
@@ -93,11 +104,20 @@ kphp::coro::task<array<mixed>> f$confdata_get_values_by_any_wildcard(string wild |
93 | 104 | co_return array<mixed>{}; |
94 | 105 | } |
95 | 106 |
|
96 | | - auto& confdata_wildcard_cache{ConfdataInstanceState::get().wildcard_cache()}; |
| 107 | + auto& confdata_instance_st{ConfdataInstanceState::get()}; |
| 108 | + auto& confdata_wildcard_cache{confdata_instance_st.wildcard_cache()}; |
97 | 109 | if (auto it{confdata_wildcard_cache.find(wildcard)}; it != confdata_wildcard_cache.end()) { |
98 | 110 | co_return it->second; |
99 | 111 | } |
100 | 112 |
|
| 113 | + k2::SystemTime start_time{}; |
| 114 | + k2::system_time(std::addressof(start_time)); |
| 115 | + const auto finalizer{vk::finally([&start_time, &confdata_instance_st] noexcept { |
| 116 | + k2::SystemTime end_time{}; |
| 117 | + k2::system_time(std::addressof(end_time)); |
| 118 | + confdata_instance_st.time_ns += (end_time.since_epoch_ns - start_time.since_epoch_ns); |
| 119 | + })}; |
| 120 | + |
101 | 121 | const std::string_view wildcard_view{wildcard.c_str(), wildcard.size()}; |
102 | 122 |
|
103 | 123 | const tl::ConfdataGetWildcard confdata_get_wildcard{.wildcard = {.value = wildcard_view}}; |
|
0 commit comments