[k2] add separate memory for coroutines - #1675
Conversation
|
|
||
| namespace memory { | ||
|
|
||
| namespace details { |
There was a problem hiding this comment.
nit: you can merge this into namespace kphp::memory::details {...}
|
|
||
| constexpr uint64_t MALLOC_REPLACER_MAX_ALLOC = 0xFFFFFF00; // 4GiB | ||
|
|
||
| template<auto AllocatorGetter> |
There was a problem hiding this comment.
nit: auto get_allocator_func
| auto realloc_script_memory(void* mem, size_t new_size, size_t old_size) noexcept -> void*; | ||
| auto free_script_memory(void* mem, size_t size) noexcept -> void; | ||
|
|
||
| auto alloc_global_memory(size_t size) noexcept -> void*; |
There was a problem hiding this comment.
Do we need these global alloc functions here? They are not related to unsynchronized_pool_resource. If so, this allocator can even have an allocator-like interface: alloc, free, realloc, calloc
|
|
||
| namespace kphp::memory::details { | ||
|
|
||
| struct PoolAllocator : vk::not_copyable { |
There was a problem hiding this comment.
nit: pool_allocator. Let's follow runtime-light's naming policy
|
|
||
| private: | ||
| void request_extra_memory(size_t requested_size) noexcept; | ||
| auto alloc_script_memory(size_t size) noexcept -> void*; |
There was a problem hiding this comment.
Can we have common implementations for some of these methods?
| inline bool is_power_of_2(uint64_t v) noexcept { | ||
| return v && !(v & (v - 1)); | ||
| inline auto alloc(size_t size) noexcept -> void* { | ||
| return details::malloc_interface<RuntimeAllocator::get>::alloc(size); |
There was a problem hiding this comment.
Could you please use fully qualified names? Otherwise this code isn't so obvious:
::details::malloc_interfacekphp::details::malloc_interfacekphp::memory::details::malloc_interfacekphp::memory::script::details::malloc_interface
| #include "runtime-common/core/allocator/runtime-allocator.h" | ||
| #include "runtime-common/core/utils/kphp-assert-core.h" | ||
|
|
||
| namespace kphp { |
There was a problem hiding this comment.
nit: namespace kphp::memory::script {...}
| auto init() noexcept -> void; | ||
|
|
||
| private: | ||
| static constexpr auto INIT_INSTANCE_ALLOCATOR_SIZE = static_cast<size_t>(16U * 1024U * 1024U); // 16MiB |
There was a problem hiding this comment.
Why did you change this?
No description provided.