hawq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jiny2 <...@git.apache.org>
Subject [GitHub] incubator-hawq pull request: HAWQ-47. Make user able to set statem...
Date Mon, 26 Oct 2015 11:05:35 GMT
Github user jiny2 commented on a diff in the pull request:

    https://github.com/apache/incubator-hawq/pull/34#discussion_r42980226
  
    --- Diff: src/backend/resourcemanager/resqueuemanager.c ---
    @@ -3301,66 +3277,107 @@ void minusResourceBundleDataByBundle(ResourceBundle detail, ResourceBundle
sourc
     /**
      * Compute the query quota.
      */
    -int computeQueryQuota( DynResourceQueueTrack	 track,
    -		   	   	   	   int32_t			 		*max_segcountfix,
    -		   	   	   	   int32_t			 		*min_segcountfix,
    -		   	   	   	   int32_t		       		*segmemmb,
    -					   double		       		*segcore,
    -					   int32_t		       		*segnum,
    -					   int32_t					*segnummin,
    -					   int32_t					 segnumlimit)
    +int computeQueryQuota( ConnectionTrack conn)
     {
    -	int			res				= FUNC_RETURN_OK;
    -	int			policy			= 0;
    +	Assert( conn != NULL );
    +	Assert( conn->QueueTrack != NULL );
     
    -	Assert( track != NULL );
    +	int					  res		= FUNC_RETURN_OK;
    +	int					  policy	= 0;
    +	DynResourceQueueTrack track		= (DynResourceQueueTrack)(conn->QueueTrack);
     
     	policy = track->QueueInfo->AllocatePolicy;
     	Assert( policy >= 0 && policy < RSQ_ALLOCATION_POLICY_COUNT );
     
    -	/* Get one segment resource quota. */
    -	*segmemmb = track->QueueInfo->SegResourceQuotaMemoryMB;
    -	*segcore  = track->QueueInfo->SegResourceQuotaVCore;
    -
    -	/* Decide segment number and minimum runnable segment number. */
    -
    -	if (*min_segcountfix > segnumlimit)
    +	/*
    +	 *--------------------------------------------------------------------------
    +	 * Get one segment resource quota. If statement level resource quota is not
    +	 * specified, the queue vseg resource quota is derived, otherwise, statement
    +	 * level resource quota. The resource memory/core ratio is not changed, thus
    +	 * code has to calculate the adjusted vcore quota for each vseg in case
    +	 * statement level resource quota is active.
    +	 *--------------------------------------------------------------------------
    +	 */
    +	if ( conn->StatNVSeg > 0 )
     	{
    -		res = RESQUEMGR_TOO_MANY_FIXED_SEGNUM;
    -		elog(LOG, " Expect too many virtual segments %d, can not be more "
    -		"than %d",
    -		*min_segcountfix,
    -		segnumlimit);
    -		return res;
    +		conn->SegMemoryMB = conn->StatVSegMemoryMB;
    +		conn->SegCore	  = track->QueueInfo->SegResourceQuotaVCore *
    +							conn->StatVSegMemoryMB /
    +							track->QueueInfo->SegResourceQuotaMemoryMB;
    +		conn->SegNum	  = conn->StatNVSeg;
    +		conn->SegNumMin	  = conn->StatNVSeg;
    +
    +		/* Check if the resource capacity is more than the capacity of queue. */
    +		conn->SegNumEqual = ceil(1.0 * conn->SegMemoryMB * conn->SegNumMin /
    +						  	     track->QueueInfo->SegResourceQuotaMemoryMB);
    +		Assert( conn->SegNumEqual > 0 );
    +		if ( conn->SegNumEqual > track->ClusterSegNumberMax )
    +		{
    +			res = RESQUEMGR_TOO_MANY_FIXED_SEGNUM;
    +			elog(WARNING, "ConnID %d expects too many virtual segments %d that is"
    +						  "set by hawq_rm_stmt_nvseg.",
    +						  conn->ConnID,
    +						  conn->SegNum);
    +			return res;
    +		}
     	}
    -	if(*max_segcountfix > segnumlimit)
    +	else
     	{
    -		*max_segcountfix = segnumlimit;
    +		conn->SegMemoryMB = track->QueueInfo->SegResourceQuotaMemoryMB;
    +		conn->SegCore 	  = track->QueueInfo->SegResourceQuotaVCore;
     	}
     
    -	/* Compute total resource quota. */
    -	res = AllocationPolicy[policy] (track, segnum, segnummin, segnumlimit);
    -
    -	if ( *segnum < *min_segcountfix )
    +	/* Decide vseg number and minimum runnable vseg number. */
    +	if ( conn->SegNumMin > conn->VSegLimit )
     	{
     		res = RESQUEMGR_TOO_MANY_FIXED_SEGNUM;
    -		elog(LOG, " Expect too many virtual segments %d, can not be more "
    -		"than %d",
    -		*min_segcountfix,
    -		*segnum);
    +		elog(WARNING, "ConnID %d expects too many virtual segments %d, "
    +					  "cannot be more than %d",
    +					  conn->ConnID,
    +					  conn->SegNumMin,
    +					  conn->VSegLimit);
     		return res;
    +	}
     
    +	if ( conn->SegNum > conn->VSegLimit )
    +	{
    +		conn->SegNum = conn->VSegLimit;
     	}
     
    -	/* Always respect the expected minimum vseg num. */
    -	*segnummin = *min_segcountfix;
    +	if ( conn->StatNVSeg <= 0 )
    +	{
    +		/* Compute total resource quota. */
    +		res = AllocationPolicy[policy] (track,
    +										&(conn->SegNum),
    +										&(conn->SegNumMin),
    +										conn->VSegLimit);
    +
    +		/*
    +		 * If fixed vseg count range is lower than estimated vseg count range
    +		 * based on one allocation policy, we always respect the fixed range.
    +		 */
    +		if ( conn->SegNum < conn->MinSegCountFixed )
    +		{
    +			res = RESQUEMGR_TOO_MANY_FIXED_SEGNUM;
    +			elog(WARNING, " Expect too many virtual segments %d, cannot be more "
    +			"than %d",
    +			conn->MinSegCountFixed,
    +			conn->SegNum);
    +			return res;
    +		}
    +
    +		conn->SegNumMin = conn->MinSegCountFixed;
    +		conn->SegNum = conn->SegNum < conn->MaxSegCountFixed ?
    +					   conn->SegNum :
    +					   conn->MaxSegCountFixed;
    +	}
     
     	elog(DEBUG3, "Expect cluster resource (%d MB, %lf CORE) x %d "
     				 "minimum runnable %d segment(s).",
    -			     *segmemmb,
    -			     *segcore,
    -				 *segnum,
    -				 *segnummin);
    +			     conn->SegMemoryMB,
    +			     conn->SegCore,
    --- End diff --
    
    Fixed


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message