[k2] add separate memory for coroutines - #1675
Open
LLirikkkk wants to merge 39 commits into
Open
Conversation
LLirikkkk
marked this pull request as ready for review
August 14, 2026 10:03
apolyakov
requested changes
Aug 18, 2026
apolyakov
reviewed
Aug 21, 2026
|
|
||
| namespace kphp::memory::details { | ||
|
|
||
| struct pool_allocator : private vk::not_copyable { |
Contributor
There was a problem hiding this comment.
It may be worth making it public
|
|
||
| #include <cstddef> | ||
|
|
||
| namespace kphp::memory::global { |
Contributor
There was a problem hiding this comment.
nit: kphp::memory::platform
| namespace kphp::memory::global { | ||
|
|
||
| auto alloc(size_t size) noexcept -> void*; | ||
| auto alloc0(size_t size) noexcept -> void*; |
| auto alloc(size_t size) noexcept -> void*; | ||
| auto alloc0(size_t size) noexcept -> void*; | ||
| auto realloc(void* mem, size_t new_size, size_t old_size) noexcept -> void*; | ||
| auto free(void* mem, size_t size) noexcept -> void; |
Contributor
There was a problem hiding this comment.
Can we have malloc-like free interface?
| 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 get_memory_resource() noexcept -> memory_resource::unsynchronized_pool_resource&; |
Contributor
There was a problem hiding this comment.
Isn't it better to have this method defined here?
| private: | ||
| static constexpr auto INIT_IMAGE_ALLOCATOR_SIZE = static_cast<size_t>(1024U * 1024U); // 1MiB | ||
| static constexpr auto INIT_IMAGE_ALLOCATOR_SIZE = static_cast<size_t>(1024U * 1024U); // 1MiB | ||
| static constexpr auto DEFAULT_MIN_EXTRA_MEMORY_POOL_SIZE = static_cast<size_t>(1024U * 1024U); // 1MiB |
Contributor
There was a problem hiding this comment.
Looks like DEFAULT_ is redundant here
| // 3) empty list => the event is triggered and all coroutines are resumed | ||
| std::variant<std::monostate, vk::intrusive::list<vk::intrusive::list_node<std::coroutine_handle<>>>> m_state; | ||
|
|
||
| void* operator new(size_t n) noexcept { |
Contributor
There was a problem hiding this comment.
Does it really need to be allocated in coro memory?
Contributor
Author
There was a problem hiding this comment.
i think, you're right, let's move it to default memory
LLirikkkk
force-pushed
the
kkotliar/k2_add_coroutine_memory
branch
from
August 21, 2026 17:28
80eed40 to
a784e3b
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.