Skip to content
Closed
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions common/src/java/org/apache/hadoop/hive/conf/HiveConf.java
Original file line number Diff line number Diff line change
Expand Up @@ -4053,6 +4053,10 @@ public static enum ConfVars {
LLAP_ALLOCATOR_DEFRAG_HEADROOM("hive.llap.io.allocator.defrag.headroom", "1Mb",
"How much of a headroom to leave to allow allocator more flexibility to defragment.\n" +
"The allocator would further cap it to a fraction of total memory."),
LLAP_ALLOCATOR_MAX_FORCE_EVICTED("hive.llap.io.allocator.max.force.eviction", "16Mb",
"Fragmentation can lead to some cases where more eviction has to happen to accommodate allocations\n" +
" This configuration puts a limit on how many bytes to force evict before using Allocator Discard method."
+ " Higher values will allow allocator more flexibility and will lead to better caching."),
LLAP_TRACK_CACHE_USAGE("hive.llap.io.track.cache.usage", true,
"Whether to tag LLAP cache contents, mapping them to Hive entities (paths for\n" +
"partitions and tables) for reporting."),
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -22,41 +22,41 @@
/**
* MXbean to expose cache allocator related information through JMX.
*/
@MXBean
public interface BuddyAllocatorMXBean {
@MXBean public interface BuddyAllocatorMXBean {

/**
* Gets if bytebuffers are allocated directly offheap.
*
* @return gets if direct bytebuffer allocation
*/
public boolean getIsDirect();
boolean getIsDirect();

/**
* Gets minimum allocation size of allocator.
*
* @return minimum allocation size
*/
public int getMinAllocation();
int getMinAllocation();

/**
* Gets maximum allocation size of allocator.
*
* @return maximum allocation size
*/
public int getMaxAllocation();
int getMaxAllocation();

/**
* Gets the arena size.
*
* @return arena size
*/
public int getArenaSize();
int getArenaSize();

/**
* Gets the maximum cache size.
*
* @return max cache size
*/
public long getMaxCacheSize();
}
long getMaxCacheSize();

}
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ public void reserveMemory(final long memoryToReserve, AtomicBoolean isStopped) {
throw new ReserveFailedException(isStopped);
}

@Override public long evictMemory(long memoryToEvict) {
if (evictor == null) {
return 0;
}
long evicted = evictor.evictSomeBlocks(memoryToEvict);
releaseMemory(evicted);
return evicted;
}

@VisibleForTesting
public boolean reserveMemory(final long memoryToReserve,
boolean waitForEviction, AtomicBoolean isStopped) {
Expand Down Expand Up @@ -154,4 +163,9 @@ public long purge() {
metrics.incrCacheCapacityUsed(-evicted);
return evicted;
}

@VisibleForTesting
public long getCurrentUsedSize() {
return usedMemory.get();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,13 @@ public interface MemoryManager {
* allocate the space.
*/
void reserveMemory(long memoryToReserve, AtomicBoolean isStopped);

/**
* Request the memory manager to evict more memory, this will be blocking and might return 0 if nothing was evicted.
*
* @param memoryToEvict amount of bytes to evict.
* @return actual amount of evicted bytes.
*/
long evictMemory(long memoryToEvict);

}
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ static class DummyMemoryManager implements MemoryManager {
public void reserveMemory(long memoryToReserve, AtomicBoolean isStopped) {
}

@Override public long evictMemory(long memoryToEvict) {
return 0;
}

@Override
public void releaseMemory(long memUsage) {
}
Expand Down Expand Up @@ -93,8 +97,7 @@ public void testSameSizes() throws Exception {
}
}

@Test
public void testMultipleArenas() throws Exception {
@Test public void testMultipleArenas() throws Exception {
int max = 8, maxAlloc = 1 << max, allocLog2 = max - 1, arenaCount = 5;
BuddyAllocator a = new BuddyAllocator(isDirect, isMapped, 1 << 3, maxAlloc, maxAlloc,
maxAlloc * arenaCount, 0, tmpDir, new DummyMemoryManager(),
Expand Down
Loading