Skip to content

Disable arena for small Arrow allocations #20701

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions yql/essentials/minikql/mkql_alloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace NKikimr {

namespace NMiniKQL {

constexpr ui64 ArrowSizeForArena = (TAllocState::POOL_PAGE_SIZE >> 2);
// constexpr ui64 ArrowSizeForArena = (TAllocState::POOL_PAGE_SIZE >> 2);

Y_POD_THREAD(TAllocState*) TlsAllocState;

Expand Down Expand Up @@ -298,9 +298,9 @@ void* MKQLArrowAllocateOnArena(ui64 size) {
}

void* MKQLArrowAllocate(ui64 size) {
if (size <= ArrowSizeForArena) {
return MKQLArrowAllocateOnArena(size);
}
// if (size <= ArrowSizeForArena) {
// return MKQLArrowAllocateOnArena(size);
// }

TAllocState* state = TlsAllocState;
Y_ENSURE(state);
Expand Down Expand Up @@ -366,9 +366,9 @@ void MKQLArrowFreeOnArena(const void* ptr) {
}

void MKQLArrowFree(const void* mem, ui64 size) {
if (size <= ArrowSizeForArena) {
return MKQLArrowFreeOnArena(mem);
}
// if (size <= ArrowSizeForArena) {
// return MKQLArrowFreeOnArena(mem);
// }

auto fullSize = size + sizeof(TMkqlArrowHeader);
auto header = ((TMkqlArrowHeader*)mem) - 1;
Expand All @@ -393,29 +393,29 @@ void MKQLArrowFree(const void* mem, ui64 size) {
ReleaseAlignedPage(header, fullSize);
}

void MKQLArrowUntrack(const void* mem, ui64 size) {
void MKQLArrowUntrack(const void* mem, ui64) {
TAllocState* state = TlsAllocState;
Y_ENSURE(state);
if (!state->EnableArrowTracking) {
return;
}

if (size <= ArrowSizeForArena) {
auto* page = (TMkqlArrowHeader*)TAllocState::GetPageStart(mem);
// if (size <= ArrowSizeForArena) {
// auto* page = (TMkqlArrowHeader*)TAllocState::GetPageStart(mem);

auto it = state->ArrowBuffers.find(page);
if (it == state->ArrowBuffers.end()) {
return;
}
// auto it = state->ArrowBuffers.find(page);
// if (it == state->ArrowBuffers.end()) {
// return;
// }

if (!page->Entry.IsUnlinked()) {
page->Entry.Unlink(); // unlink page immediately so we don't accidentally free untracked memory within `TAllocState`
state->ArrowBuffers.erase(it);
state->OffloadFree(page->Size);
}
// if (!page->Entry.IsUnlinked()) {
// page->Entry.Unlink(); // unlink page immediately so we don't accidentally free untracked memory within `TAllocState`
// state->ArrowBuffers.erase(it);
// state->OffloadFree(page->Size);
// }

return;
}
// return;
// }

auto it = state->ArrowBuffers.find(mem);
if (it == state->ArrowBuffers.end()) {
Expand Down
Loading