Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Track startup memory for resource group
Greenplum has several different counters to track virtual memory consumption - `pResGroupControl->totalChunks` is the total number of memory on this segment - `pResGroupControl->freeChunks` is the current amount of shared global memory - `self->slot->memUsage` is the current session's slot consumption. It can be greater than self->slot->memQuota if group or global shared memory is consumed - `self->group` is the current session's group consumption - `self->memUsage` is the current process' consumption - `MySessionState->sessionVmem` is the current session's consumption - `segmentVmemChunks` is the segment's total consumption You can see that some of these counters basically count the same things yet they still have different variables for that. Such approach requires consistency across all these counters, however, gpdb fails to provide it. A newly forked procces calls `VmemTracker_RegisterStartupMemory` to track some memory it inherited from a parent process, it's usually about 12MB. It adds this memory to `MySessionState->sessionVmem` and `segmentVmemChunks` before vmem tracker is initialized. When vmem tracker is ready and a group is assigned to a proccess groupIncMemUsage is called to add this startup memory to group. However, the arguments are `groupIncMemUsage(group, slot, self->memUsage)` where `self->memUsage` is 0 at this moment because `VmemTracker_RegisterStartupMemory` didn't increase it. This patch adds startup memory to self->memUsage to fix this behavior.
- Loading branch information