From 2aacf8400a34805ee7ab1f720e2f65de1f695eb8 Mon Sep 17 00:00:00 2001
From: Petr Shumilov
Date: Tue, 28 Apr 2026 17:32:43 +0300
Subject: [PATCH 1/2] Temporary disable all logging in runtime-allocator
Signed-off-by: Petr Shumilov
---
runtime-light/allocator/runtime-light-allocator.cpp | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/runtime-light/allocator/runtime-light-allocator.cpp b/runtime-light/allocator/runtime-light-allocator.cpp
index 3e6002e2ad..ea2ceb7819 100644
--- a/runtime-light/allocator/runtime-light-allocator.cpp
+++ b/runtime-light/allocator/runtime-light-allocator.cpp
@@ -16,21 +16,21 @@ RuntimeAllocator& RuntimeAllocator::get() noexcept {
RuntimeAllocator::RuntimeAllocator(size_t script_mem_size, size_t min_extra_mem_size, size_t oom_handling_mem_size)
: m_min_extra_mem_size(min_extra_mem_size) {
- kphp::log::debug("create runtime allocator -> {:p}: script memory -> {}, oom handling size -> {}", reinterpret_cast(this), script_mem_size,
- oom_handling_mem_size);
+ // kphp::log::debug("create runtime allocator -> {:p}: script memory -> {}, oom handling size -> {}", reinterpret_cast(this), script_mem_size,
+ // oom_handling_mem_size);
void* buffer{alloc_global_memory(script_mem_size)};
memory_resource.init(buffer, script_mem_size, oom_handling_mem_size);
}
void RuntimeAllocator::init(void* buffer, size_t script_mem_size, size_t oom_handling_mem_size) {
kphp::log::assertion(buffer != nullptr);
- kphp::log::debug("init runtime allocator -> {:p}: buffer -> {:p}, script memory -> {}, oom handling size -> {}", reinterpret_cast(this), buffer,
- script_mem_size, oom_handling_mem_size);
+ // kphp::log::debug("init runtime allocator -> {:p}: buffer -> {:p}, script memory -> {}, oom handling size -> {}", reinterpret_cast(this), buffer,
+ // script_mem_size, oom_handling_mem_size);
memory_resource.init(buffer, script_mem_size, oom_handling_mem_size);
}
void RuntimeAllocator::free() {
- kphp::log::debug("free runtime allocator -> {:p}", reinterpret_cast(this));
+ // kphp::log::debug("free runtime allocator -> {:p}", reinterpret_cast(this));
auto* extra_memory{memory_resource.get_extra_memory_head()};
while (extra_memory->get_pool_payload_size() != 0) {
auto* extra_memory_to_release{extra_memory};
@@ -111,7 +111,7 @@ void RuntimeAllocator::request_extra_memory(size_t requested_size) noexcept {
// Take into account internal layout of `memory_resource::extra_memory_pool`
extra_mem_size += sizeof(memory_resource::extra_memory_pool);
- kphp::log::debug("requested extra memory pool with size {} bytes, will be allocated {} bytes", requested_size, extra_mem_size);
+ // kphp::log::debug("requested extra memory pool with size {} bytes, will be allocated {} bytes", requested_size, extra_mem_size);
auto* extra_mem{alloc_global_memory(extra_mem_size)};
memory_resource.add_extra_memory(new (extra_mem) memory_resource::extra_memory_pool{extra_mem_size});
From d1c0ef733c547cbf4d629cfbd0e1a3e6fe0123da Mon Sep 17 00:00:00 2001
From: Petr Shumilov
Date: Tue, 28 Apr 2026 17:33:59 +0300
Subject: [PATCH 2/2] Remove useless heap allocations from kphp::log::assertion
Signed-off-by: Petr Shumilov
---
runtime-light/stdlib/diagnostics/logs.h | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/runtime-light/stdlib/diagnostics/logs.h b/runtime-light/stdlib/diagnostics/logs.h
index fcae786d78..b332553be9 100644
--- a/runtime-light/stdlib/diagnostics/logs.h
+++ b/runtime-light/stdlib/diagnostics/logs.h
@@ -21,10 +21,11 @@ namespace kphp::log {
namespace impl {
+static constexpr size_t DEFAULT_LOG_BUFFER_SIZE = 2048UZ;
+
template
void log(level level, std::optional> trace, std::format_string...> fmt, Args&&... args) noexcept {
- static constexpr size_t LOG_BUFFER_SIZE = 2048UZ;
- std::array log_buffer; // NOLINT
+ std::array log_buffer; // NOLINT
size_t message_size{impl::format_log_message(log_buffer, fmt, std::forward(args)...)};
auto message{std::string_view{log_buffer.data(), static_cast(message_size)}};
@@ -67,7 +68,10 @@ void log(level level, std::optional> trace, std::format_s
// If assertion is modified, the backtrace algorithm should be updated accordingly
inline void assertion(bool condition, const std::source_location& location = std::source_location::current()) noexcept {
if (!condition) [[unlikely]] {
- impl::log(level::error, std::nullopt, "assertion failed at {}:{}", location.file_name(), location.line());
+ std::array log_buffer; // NOLINT
+ size_t message_size{impl::format_log_message(log_buffer, "assertion failed at {}:{}", location.file_name(), location.line())};
+ auto message{std::string_view{log_buffer.data(), static_cast(message_size)}};
+ k2::log(std::to_underlying(level::error), message, {});
k2::exit(1);
}
}