HIVE-16545 : LLAP: bug in arena size determination logic (Sergey Shelukhin, reviewed by Prasanth Jayachandran)
Project: http://git-wip-us.apache.org/repos/asf/hive/repo Commit: http://git-wip-us.apache.org/repos/asf/hive/commit/81be9d0d Tree: http://git-wip-us.apache.org/repos/asf/hive/tree/81be9d0d Diff: http://git-wip-us.apache.org/repos/asf/hive/diff/81be9d0d Branch: refs/heads/master Commit: 81be9d0d2e84bf0cb2791b7fe1478e8c9ece89c8 Parents: f4d017b Author: sergey <ser...@apache.org> Authored: Thu Apr 27 11:53:25 2017 -0700 Committer: sergey <ser...@apache.org> Committed: Thu Apr 27 11:53:25 2017 -0700 ---------------------------------------------------------------------- .../java/org/apache/hadoop/hive/llap/cache/BuddyAllocator.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hive/blob/81be9d0d/llap-server/src/java/org/apache/hadoop/hive/llap/cache/BuddyAllocator.java ---------------------------------------------------------------------- diff --git a/llap-server/src/java/org/apache/hadoop/hive/llap/cache/BuddyAllocator.java b/llap-server/src/java/org/apache/hadoop/hive/llap/cache/BuddyAllocator.java index c049d27..302918a 100644 --- a/llap-server/src/java/org/apache/hadoop/hive/llap/cache/BuddyAllocator.java +++ b/llap-server/src/java/org/apache/hadoop/hive/llap/cache/BuddyAllocator.java @@ -124,7 +124,8 @@ public final class BuddyAllocator } else { cacheDir = null; } - int arenaSizeVal = (arenaCount == 0) ? MAX_ARENA_SIZE : (int)(maxSizeVal / arenaCount); + long arenaSizeVal = (arenaCount == 0) ? MAX_ARENA_SIZE : maxSizeVal / arenaCount; + // The math.min, and the fact that maxAllocation is an int, ensures we don't overflow. arenaSizeVal = Math.max(maxAllocation, Math.min(arenaSizeVal, MAX_ARENA_SIZE)); if (LlapIoImpl.LOG.isInfoEnabled()) { LlapIoImpl.LOG.info("Buddy allocator with " + (isDirect ? "direct" : "byte") + " buffers; " @@ -153,7 +154,7 @@ public final class BuddyAllocator LlapIoImpl.LOG.warn("Rounding arena size to " + arenaSizeVal + " from " + oldArenaSize + " to be divisible by allocation size " + maxAllocation); } - arenaSize = arenaSizeVal; + arenaSize = (int)arenaSizeVal; if ((maxSizeVal % arenaSize) > 0) { long oldMaxSize = maxSizeVal; maxSizeVal = (maxSizeVal / arenaSize) * arenaSize;