You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hawq.apache.org by yj...@apache.org on 2016/11/29 07:44:49 UTC

incubator-hawq git commit: HAWQ-1174. double type core counter of container set has precision issue

Repository: incubator-hawq
Updated Branches:
  refs/heads/master cb3328d47 -> c80e4e35a


HAWQ-1174. double type core counter of container set has precision issue


Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/c80e4e35
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/c80e4e35
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/c80e4e35

Branch: refs/heads/master
Commit: c80e4e35a9a2c8fc834b3390a0b3bceaeb0e7675
Parents: cb3328d
Author: Yi <yj...@pivotal.io>
Authored: Tue Nov 29 18:44:39 2016 +1100
Committer: Yi <yj...@pivotal.io>
Committed: Tue Nov 29 18:44:39 2016 +1100

----------------------------------------------------------------------
 src/backend/resourcemanager/include/resourcepool.h | 1 +
 src/backend/resourcemanager/resourcepool.c         | 9 ++++-----
 src/backend/resourcemanager/resqueuemanager.c      | 4 ++++
 3 files changed, 9 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/c80e4e35/src/backend/resourcemanager/include/resourcepool.h
----------------------------------------------------------------------
diff --git a/src/backend/resourcemanager/include/resourcepool.h b/src/backend/resourcemanager/include/resourcepool.h
index f23e77b..718e5fc 100644
--- a/src/backend/resourcemanager/include/resourcepool.h
+++ b/src/backend/resourcemanager/include/resourcepool.h
@@ -715,6 +715,7 @@ SimpStringPtr build_segment_status_description(SegStat segstat);
 #define EPSILON 1e-7
 #define IS_DOUBLE_ZERO(d)       (fabs(d) < EPSILON)
 #define IS_DOUBLE_EQ(x, y)      ((fabs((x) - (y))) <= (EPSILON))
+#define IS_DOUBLE_GE(x, y)      (((x) + EPSILON) >= (y))
 
 void validateResourcePoolStatus(bool refquemgr);
 

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/c80e4e35/src/backend/resourcemanager/resourcepool.c
----------------------------------------------------------------------
diff --git a/src/backend/resourcemanager/resourcepool.c b/src/backend/resourcemanager/resourcepool.c
index 22bc0eb..ed91d8e 100644
--- a/src/backend/resourcemanager/resourcepool.c
+++ b/src/backend/resourcemanager/resourcepool.c
@@ -3650,11 +3650,10 @@ void timeoutIdleGRMResourceToRBByRatio(int 		 ratioindex,
 		GRMContainer retcont = getGRMContainerSetContainerFirst(containerset);
 
 		if ( containerset->Available.MemoryMB >= retcont->MemoryMB &&
-			 containerset->Available.Core     >= retcont->Core )
+		     IS_DOUBLE_GE(containerset->Available.Core, retcont->Core ) )
 		{
-
 			Assert(resource->Available.MemoryMB >= retcont->MemoryMB);
-			Assert(resource->Available.Core     >= retcont->Core);
+			Assert(IS_DOUBLE_GE(resource->Available.Core, retcont->Core));
 
 			retcont = popGRMContainerSetContainerList(containerset);
 
@@ -3669,12 +3668,12 @@ void timeoutIdleGRMResourceToRBByRatio(int 		 ratioindex,
 			Assert( resource->Allocated.MemoryMB >= 0 );
 			Assert( resource->Allocated.Core >= 0  );
 			Assert( resource->Available.MemoryMB >= 0 );
-			Assert( resource->Available.Core >= 0  );
+			Assert( IS_DOUBLE_GE(resource->Available.Core, 0) );
 
 			Assert( containerset->Allocated.MemoryMB >= 0 );
 			Assert( containerset->Allocated.Core >= 0   );
 			Assert( containerset->Available.MemoryMB >= 0 );
-			Assert( containerset->Available.Core >= 0   );
+			Assert( IS_DOUBLE_GE(containerset->Available.Core, 0) );
 
 			reorderSegResourceAllocIndex(resource, ratio);
 			reorderSegResourceAvailIndex(resource, ratio);

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/c80e4e35/src/backend/resourcemanager/resqueuemanager.c
----------------------------------------------------------------------
diff --git a/src/backend/resourcemanager/resqueuemanager.c b/src/backend/resourcemanager/resqueuemanager.c
index ca58507..d98c11c 100644
--- a/src/backend/resourcemanager/resqueuemanager.c
+++ b/src/backend/resourcemanager/resqueuemanager.c
@@ -3267,6 +3267,10 @@ void minusResourceBundleData(ResourceBundle detail, int32_t mem, double core)
 {
 	detail->MemoryMB -= mem;
 	detail->Core -= core;
+	if (IS_DOUBLE_EQ(detail->Core, 0)) {
+		// this setting is to avoid accumulating double precision problem
+		detail->Core = 0.0;
+	}
 }
 
 void resetResourceBundleDataByBundle(ResourceBundle detail, ResourceBundle source)