Skip to content

Commit 69ff82f

Browse files
macvincentfacebook-github-bot
authored andcommitted
Introduce JK to Disable Memory Reallocation Optimization (#325)
Summary: When implementing the stream chunker, we anticipated that stream buffers after chunking will end up growing to the size that previously triggered chunking. As a tradeoff between minimizing reallocations (for performance) and actually releasing memory (to relieve memory pressure), we heuristically determine the new buffer capacity for each stream to be larger that required. The issue with this optimization is that it conflicts with the rest of our memory tracking logic since we now have retained memory in the memory pool that is not accounted for. We now know through local testing that disabling this optimization leads to better memory pressure relief. In this diff, we introduce a JK, [dwio/nimble_chunking:disable_memory_reallocation_optimization](https://www.internalfb.com/intern/justknobs/?name=dwio%2Fnimble_chunking#disable_memory_reallocation_optimization), that will be enabled just for DISCO experiments. This will help us understand the full impact of this optimization and whether it should be retained. Differential Revision: D87494427
1 parent 93a536d commit 69ff82f

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ set(CMAKE_CXX_STANDARD 20)
2020
set(CMAKE_CXX_STANDARD_REQUIRED True)
2121

2222
add_compile_definitions(DISABLE_META_INTERNAL_COMPRESSOR=1)
23+
add_compile_definitions(DISABLE_META_INTERNAL_MEMORY_REALLOCATION_OPTIMIZATION=1)
2324

2425
# Sets new behavior for CMP0135, which controls how timestamps are extracted
2526
# when using ExternalProject_Add():

dwio/nimble/velox/StreamChunker.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
#pragma once
1818

1919
#include "dwio/nimble/velox/StreamData.h"
20+
#ifndef DISABLE_META_INTERNAL_MEMORY_REALLOCATION_OPTIMIZATION
21+
#include "justknobs/JustKnobProxy.h"
22+
#endif
2023

2124
namespace facebook::nimble {
2225
namespace detail {
@@ -32,6 +35,14 @@ uint64_t getNewBufferCapacity(
3235
uint64_t maxChunkSize,
3336
uint64_t currentCapacityCount,
3437
uint64_t requiredCapacityCount) {
38+
#ifndef DISABLE_META_INTERNAL_MEMORY_REALLOCATION_OPTIMIZATION
39+
static facebook::jk::BooleanKnob disableMemoryReallocationOptimization(
40+
"dwio/nimble_chunking:disable_memory_reallocation_optimization");
41+
if (disableMemoryReallocationOptimization()) {
42+
return requiredCapacityCount;
43+
}
44+
#endif
45+
3546
const auto maxChunkElementCount = maxChunkSize / sizeof(T);
3647
if (currentCapacityCount < maxChunkElementCount) {
3748
return std::max<uint64_t>(

0 commit comments

Comments
 (0)