Github user selvaganesang commented on a diff in the pull request:
https://github.com/apache/incubator-trafodion/pull/1228#discussion_r138634994
--- Diff: core/sql/generator/GenProbeCache.cpp ---
@@ -470,30 +463,38 @@ CostScalar
ProbeCache::getEstimatedRunTimeMemoryUsage(NABoolean perCPU)
}
const double outputBufferSize = resultSize * numBufferPoolEntries; //
in bytes
- // totalMemory is perCPU at this point of time.
+ // totalMemory is perNode at this point of time.
double totalMemory = cacheSize + outputBufferSize;
-
- if ( perCPU == FALSE ) {
- const PhysicalProperty* const phyProp = getPhysicalProperty();
-
- if (phyProp != NULL)
- {
- PartitioningFunction * partFunc = phyProp ->
getPartitioningFunction() ;
- totalMemory *= partFunc->getCountOfPartitions();
- }
+ Lng32 numOfStreams = 1;
+ const PhysicalProperty* const phyProp = getPhysicalProperty();
+ if (phyProp)
+ {
+ PartitioningFunction * partFunc = phyProp ->
getPartitioningFunction() ;
+ numOfStreams = partFunc->getCountOfPartitions();
+ if (numOfStreams <= 0)
+ numOfStreams = 1;
+ double memoryLimitPerInstance =
+
ActiveSchemaDB()->getDefaults().getAsLong(EXE_MEMORY_FOR_PROBE_CACHE_IN_MB) *
1024 * 1024;
+ if (totalMemory > memoryLimitPerInstance)
+ totalMemory = memoryLimitPerInstance;
+ totalMemory *= numOfStreams;
}
-
- double memoryLimitPerCpu =
-
ActiveSchemaDB()->getDefaults().getAsLong(EXE_MEMORY_FOR_PROBE_CACHE_IN_MB) *
1024 * 1024;
- if (totalMemory > memoryLimitPerCpu)
- totalMemory = memoryLimitPerCpu;
+ if (numStreams != NULL)
+ *numStreams = numOfStreams;
+ if ( perNode == TRUE )
+ totalMemory /=
MINOF(MAXOF(((NAClusterInfoLinux*)gpClusterInfo)->getTotalNumberOfCPUs(), 1),
numOfStreams);
--- End diff --
While making the change, I realized that I didn't get what is expected. I
believe it is already taking the MINOF(numOfStreams, NumberOfNodes())
---