resgroup: reorder resource group struct properties
Reorder the resource group struct properties to reduce paddings and
cache line misses.
@@ -124,12 +124,12 @@ struct ResGroupProcData
{
Oid groupId;
+ int32 memUsage; /* memory usage of current proc */
+
ResGroupData *group;
ResGroupSlotData *slot;
ResGroupCaps caps;
-
- int32 memUsage; /* memory usage of current proc */
};
/*
@@ -144,13 +144,13 @@ struct ResGroupSlotData
{
Oid groupId;
- ResGroupCaps caps;
-
int32 memQuota; /* memory quota of current slot */
int32 memUsage; /* total memory usage of procs belongs to this slot */
int nProcs; /* number of procs in this slot */
ResGroupSlotData *next;
+
+ ResGroupCaps caps;
};
/*
@@ -174,15 +174,6 @@ typedef struct ResGroupMemOperations
struct ResGroupData
{
Oid groupId; /* Id for this group */
- ResGroupCaps caps; /* capabilities of this group */
- volatile int nRunning; /* number of running trans */
- volatile int nRunningBypassed; /* number of running trans in bypass mode */
- PROC_QUEUE waitProcs; /* list of PGPROC objects waiting on this group */
- int totalExecuted; /* total number of executed trans */
- int totalQueued; /* total number of queued trans */
- Interval totalQueuedTime;/* total queue time */
-
- bool lockedForDrop; /* true if resource group is dropped but not committed yet */
/*
* memGap is calculated as:
@@ -207,33 +198,44 @@ struct ResGroupData
volatile int32 memUsage;
volatile int32 memSharedUsage;
+ volatile int nRunning; /* number of running trans */
+ volatile int nRunningBypassed; /* number of running trans in bypass mode */
+ int totalExecuted; /* total number of executed trans */
+ int totalQueued; /* total number of queued trans */
+ Interval totalQueuedTime;/* total queue time */
+ PROC_QUEUE waitProcs; /* list of PGPROC objects waiting on this group */
+
/*
* operation functions for resource group
*/
const ResGroupMemOperations *groupMemOps;
+
+ bool lockedForDrop; /* true if resource group is dropped but not committed yet */
+
+ ResGroupCaps caps; /* capabilities of this group */
};
struct ResGroupControl
{
- HTAB *htbl;
- int segmentsOnMaster;
-
- /*
- * The hash table for resource groups in shared memory should only be populated
- * once, so we add a flag here to implement this requirement.
- */
- bool loaded;
-
int32 totalChunks; /* total memory chunks on this segment */
volatile int32 freeChunks; /* memory chunks not allocated to any group,
will be used for the query which group share
memory is not enough*/
int32 chunkSizeInBits;
+ int segmentsOnMaster;
ResGroupSlotData *slots; /* slot pool shared by all resource groups */
ResGroupSlotData *freeSlot; /* head of the free list */
+ HTAB *htbl;
+
+ /*
+ * The hash table for resource groups in shared memory should only be populated
+ * once, so we add a flag here to implement this requirement.
+ */
+ bool loaded;
+
int nGroups;
ResGroupData groups[1];
};
