Skip to content

Commit f9f2f56

Browse files
committed
Fix code style
Signed-off-by: Petr Shumilov <p.shumilov@vkteam.ru>
1 parent 0d42799 commit f9f2f56

4 files changed

Lines changed: 13 additions & 15 deletions

File tree

runtime-light/allocator/allocator-state.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include "runtime-common/core/allocator/runtime-allocator.h"
1212
#include "runtime-light/stdlib/diagnostics/logs.h"
1313

14-
constexpr auto MIN_EXTRA_MEMORY_POOL_SIZE{static_cast<size_t>(64 * 1024U * 1024U)};
14+
inline constexpr auto DEFAULT_MIN_EXTRA_MEMORY_POOL_SIZE{static_cast<size_t>(64 * 1024U * 1024U)};
1515

1616
class AllocatorState final : private vk::not_copyable {
1717
uint32_t m_libc_alloc_allowed{};

runtime-light/state/component-state.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <string_view>
1616
#include <sys/mman.h>
1717
#include <sys/stat.h>
18+
#include <system_error>
1819
#include <utility>
1920

2021
#include "runtime-common/core/runtime-core.h"
@@ -31,12 +32,9 @@ std::optional<uint64_t> parse_uint64(std::string_view value_view) noexcept {
3132
return std::nullopt;
3233
}
3334

34-
const auto* begin{value_view.data()};
35-
const auto* end{std::next(value_view.data(), value_view.size())};
36-
3735
uint64_t res{};
38-
const auto [ptr, err_code]{std::from_chars(begin, end, /* out paremeter */ res)};
39-
if (err_code != std::errc{} || ptr != end) {
36+
if (const auto [ptr, err_code]{std::from_chars(value_view.begin(), value_view.end(), /* out paremeter */ res)};
37+
err_code != std::errc{} || ptr != value_view.end()) {
4038
return std::nullopt;
4139
}
4240
return res;
@@ -121,7 +119,7 @@ void ComponentState::parse_initial_instance_memory_size(std::string_view value_v
121119
if (!parsed) {
122120
kphp::log::error("couldn't parse initial instance memory size, got {}", value_view);
123121
}
124-
initial_instance_memory_size = parsed.value();
122+
initial_instance_memory_size = *parsed;
125123
kphp::log::info("set initial instance memory size to {} bytes", initial_instance_memory_size);
126124
}
127125

@@ -130,7 +128,7 @@ void ComponentState::parse_min_instance_extra_memory_size(std::string_view value
130128
if (!parsed) {
131129
kphp::log::error("couldn't parse min instance extra memory size, got {}", value_view);
132130
}
133-
min_instance_extra_memory_size = parsed.value();
131+
min_instance_extra_memory_size = *parsed;
134132
kphp::log::info("set min instance extra memory size to {} bytes", min_instance_extra_memory_size);
135133
}
136134

@@ -150,9 +148,9 @@ void ComponentState::parse_args() noexcept {
150148
parse_cluster_name_arg(value_view);
151149
} else if (key_view == EXIT_AFTER_RESPONSE_ARG) {
152150
parse_exit_after_response_arg(value_view);
153-
} else if (key_view == INITIAL_INSTANCE_MEMORY_SIZE) {
151+
} else if (key_view == INITIAL_INSTANCE_MEMORY_SIZE_ARG) {
154152
parse_initial_instance_memory_size(value_view);
155-
} else if (key_view == MIN_INSTANCE_EXTRA_MEMORY_SIZE) {
153+
} else if (key_view == MIN_INSTANCE_EXTRA_MEMORY_SIZE_ARG) {
156154
parse_min_instance_extra_memory_size(value_view);
157155
} else {
158156
kphp::log::warning("unexpected argument format: {}", key_view);

runtime-light/state/component-state.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include "runtime-light/stdlib/kml/kml-state.h"
2020

2121
struct ComponentState final : private vk::not_copyable {
22-
AllocatorState component_allocator_state{INIT_COMPONENT_ALLOCATOR_SIZE, MIN_EXTRA_MEMORY_POOL_SIZE, 0};
22+
AllocatorState component_allocator_state{INIT_COMPONENT_ALLOCATOR_SIZE, DEFAULT_MIN_EXTRA_MEMORY_POOL_SIZE, 0};
2323
KmlComponentState kml_component_state; // This member does not hold any KPHP types, so setting a reference counter is unnecessary.
2424

2525
const uint32_t argc{k2::args_count()};
@@ -30,7 +30,7 @@ struct ComponentState final : private vk::not_copyable {
3030
string cluster_name{DEFAULT_CLUSTER_NAME.data(), DEFAULT_CLUSTER_NAME.size()};
3131
bool exit_after_response{};
3232
uint64_t initial_instance_memory_size{INIT_INSTANCE_ALLOCATOR_SIZE};
33-
uint64_t min_instance_extra_memory_size{MIN_EXTRA_MEMORY_POOL_SIZE};
33+
uint64_t min_instance_extra_memory_size{DEFAULT_MIN_EXTRA_MEMORY_POOL_SIZE};
3434

3535
ComponentState() noexcept {
3636
parse_env();
@@ -61,8 +61,8 @@ struct ComponentState final : private vk::not_copyable {
6161
static constexpr std::string_view CLUSTER_NAME_ARG = "cluster-name";
6262
static constexpr std::string_view DEFAULT_CLUSTER_NAME = "default";
6363
static constexpr std::string_view EXIT_AFTER_RESPONSE_ARG = "exit-after-response";
64-
static constexpr std::string_view INITIAL_INSTANCE_MEMORY_SIZE = "initial-instance-memory-size";
65-
static constexpr std::string_view MIN_INSTANCE_EXTRA_MEMORY_SIZE = "min-instance-extra-memory-size";
64+
static constexpr std::string_view INITIAL_INSTANCE_MEMORY_SIZE_ARG = "initial-instance-memory-size";
65+
static constexpr std::string_view MIN_INSTANCE_EXTRA_MEMORY_SIZE_ARG = "min-instance-extra-memory-size";
6666
static constexpr auto INIT_COMPONENT_ALLOCATOR_SIZE = static_cast<size_t>(1024U * 1024U); // 1MB
6767
static constexpr auto INIT_INSTANCE_ALLOCATOR_SIZE = static_cast<size_t>(64U * 1024U * 1024U); // 64MB
6868

runtime-light/state/image-state.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include "runtime-light/stdlib/visitors/shape-visitors.h"
3030

3131
struct ImageState final : private vk::not_copyable {
32-
AllocatorState image_allocator_state{INIT_IMAGE_ALLOCATOR_SIZE, MIN_EXTRA_MEMORY_POOL_SIZE, 0};
32+
AllocatorState image_allocator_state{INIT_IMAGE_ALLOCATOR_SIZE, DEFAULT_MIN_EXTRA_MEMORY_POOL_SIZE, 0};
3333

3434
uint32_t pid{k2::getpid()};
3535
uid_t uid{k2::getuid()};

0 commit comments

Comments
 (0)