提交 0d0803f5 编写于 作者: S Stephan Ewen

Fix the managed memory planning after patch 9ce62930

上级 9ce62930
...@@ -272,7 +272,7 @@ public class NepheleMiniCluster { ...@@ -272,7 +272,7 @@ public class NepheleMiniCluster {
config.setBoolean(ConfigConstants.FILESYSTEM_DEFAULT_OVERWRITE_KEY, defaultOverwriteFiles); config.setBoolean(ConfigConstants.FILESYSTEM_DEFAULT_OVERWRITE_KEY, defaultOverwriteFiles);
config.setBoolean(ConfigConstants.FILESYSTEM_OUTPUT_ALWAYS_CREATE_DIRECTORY_KEY, defaultAlwaysCreateDirectory); config.setBoolean(ConfigConstants.FILESYSTEM_OUTPUT_ALWAYS_CREATE_DIRECTORY_KEY, defaultAlwaysCreateDirectory);
if(memorySize < 0){ if (memorySize < 0){
memorySize = HardwareDescriptionFactory.extractFromSystem().getSizeOfFreeMemory(); memorySize = HardwareDescriptionFactory.extractFromSystem().getSizeOfFreeMemory();
// at this time, we need to scale down the memory, because we cannot dedicate all free memory to the // at this time, we need to scale down the memory, because we cannot dedicate all free memory to the
...@@ -282,9 +282,12 @@ public class NepheleMiniCluster { ...@@ -282,9 +282,12 @@ public class NepheleMiniCluster {
GlobalConfiguration.getLong(ConfigConstants.TASK_MANAGER_NETWORK_BUFFER_SIZE_KEY, GlobalConfiguration.getLong(ConfigConstants.TASK_MANAGER_NETWORK_BUFFER_SIZE_KEY,
ConfigConstants.DEFAULT_TASK_MANAGER_NETWORK_BUFFER_SIZE); ConfigConstants.DEFAULT_TASK_MANAGER_NETWORK_BUFFER_SIZE);
memorySize = (long) (0.8 * (memorySize - bufferMem)); memorySize = memorySize - bufferMem;
// apply the fraction that makes sure memory is left to the heap for other data structures and UDFs.
memorySize = (long) (memorySize * ConfigConstants.DEFAULT_MEMORY_MANAGER_MEMORY_FRACTION);
//convert from bytes to mega bytes //convert from bytes to megabytes
memorySize >>>= 20; memorySize >>>= 20;
} }
......
...@@ -334,9 +334,8 @@ public class TaskManager implements TaskOperationProtocol { ...@@ -334,9 +334,8 @@ public class TaskManager implements TaskOperationProtocol {
throw new Exception("Failed to instantiate ChannelManager.", ioe); throw new Exception("Failed to instantiate ChannelManager.", ioe);
} }
// initialize the number of slots
{ {
HardwareDescription resources = HardwareDescriptionFactory.extractFromSystem();
int slots = GlobalConfiguration.getInteger(ConfigConstants.TASK_MANAGER_NUM_TASK_SLOTS, -1); int slots = GlobalConfiguration.getInteger(ConfigConstants.TASK_MANAGER_NUM_TASK_SLOTS, -1);
if (slots == -1) { if (slots == -1) {
slots = 1; slots = 1;
...@@ -347,23 +346,34 @@ public class TaskManager implements TaskOperationProtocol { ...@@ -347,23 +346,34 @@ public class TaskManager implements TaskOperationProtocol {
LOG.info("Creating " + slots + " task slot(s)."); LOG.info("Creating " + slots + " task slot(s).");
} }
this.numberOfSlots = slots; this.numberOfSlots = slots;
}
this.hardwareDescription = HardwareDescriptionFactory.extractFromSystem();
// initialize the memory manager
{
// Check whether the memory size has been explicitly configured.
final long configuredMemorySize = GlobalConfiguration.getInteger(ConfigConstants.TASK_MANAGER_MEMORY_SIZE_KEY, -1);
final long memorySize;
// Check whether the memory size has been explicitly configured. if so that overrides the default mechanism if (configuredMemorySize == -1) {
// of taking as much as is mentioned in the hardware description // no manually configured memory. take a relative fraction of the free heap space
long memorySize = GlobalConfiguration.getInteger(ConfigConstants.TASK_MANAGER_MEMORY_SIZE_KEY, -1); float fraction = GlobalConfiguration.getFloat(ConfigConstants.TASK_MANAGER_MEMORY_FRACTION_KEY, ConfigConstants.DEFAULT_MEMORY_MANAGER_MEMORY_FRACTION);
memorySize = (long) (this.hardwareDescription.getSizeOfFreeMemory() * fraction);
if (memorySize > 0) { LOG.info("Using " + fraction + " of the free heap space for managed memory.");
// manually configured memory size. override the value in the hardware config }
resources = HardwareDescriptionFactory.construct(resources.getNumberOfCPUCores(), else if (configuredMemorySize <= 0) {
resources.getSizeOfPhysicalMemory(), memorySize * 1024L * 1024L); throw new Exception("Invalid value for Memory Manager memory size: " + configuredMemorySize);
}
else {
memorySize = configuredMemorySize << 20;
} }
this.hardwareDescription = resources;
final int pageSize = GlobalConfiguration.getInteger(ConfigConstants.TASK_MANAGER_NETWORK_BUFFER_SIZE_KEY, final int pageSize = GlobalConfiguration.getInteger(ConfigConstants.TASK_MANAGER_NETWORK_BUFFER_SIZE_KEY,
ConfigConstants.DEFAULT_TASK_MANAGER_NETWORK_BUFFER_SIZE); ConfigConstants.DEFAULT_TASK_MANAGER_NETWORK_BUFFER_SIZE);
// Initialize the memory manager // Initialize the memory manager
LOG.info("Initializing memory manager with " + (resources.getSizeOfFreeMemory() >>> 20) + " megabytes of memory. " + LOG.info("Initializing memory manager with " + (memorySize >>> 20) + " megabytes of memory. " +
"Page size is " + pageSize + " bytes."); "Page size is " + pageSize + " bytes.");
try { try {
...@@ -371,11 +381,9 @@ public class TaskManager implements TaskOperationProtocol { ...@@ -371,11 +381,9 @@ public class TaskManager implements TaskOperationProtocol {
final boolean lazyAllocation = GlobalConfiguration.getBoolean(ConfigConstants.TASK_MANAGER_MEMORY_LAZY_ALLOCATION_KEY, final boolean lazyAllocation = GlobalConfiguration.getBoolean(ConfigConstants.TASK_MANAGER_MEMORY_LAZY_ALLOCATION_KEY,
ConfigConstants.DEFAULT_TASK_MANAGER_MEMORY_LAZY_ALLOCATION); ConfigConstants.DEFAULT_TASK_MANAGER_MEMORY_LAZY_ALLOCATION);
this.memoryManager = new DefaultMemoryManager(resources.getSizeOfFreeMemory(), this.numberOfSlots, this.memoryManager = new DefaultMemoryManager(memorySize, this.numberOfSlots, pageSize);
pageSize);
} catch (Throwable t) { } catch (Throwable t) {
LOG.fatal("Unable to initialize memory manager with " + (resources.getSizeOfFreeMemory() >>> 20) LOG.fatal("Unable to initialize memory manager with " + (memorySize >>> 20) + " megabytes of memory.", t);
+ " megabytes of memory.", t);
throw new Exception("Unable to initialize memory manager.", t); throw new Exception("Unable to initialize memory manager.", t);
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册