• P
    Implement resource group cpu rate limitation. · 2650f728
    Pengzhou Tang 提交于
    Resource group cpu rate limitation is implemented with cgroup on linux
    system. When resource group is enabled via GUC we check whether cgroup
    is available and properly configured on the system. A sub cgroup is
    created for each resource group, cpu quota and share weight will be set
    depends on the resource group configuration. The queries will run under
    these cgroups, and the cpu usage will be restricted by cgroup.
    
    The cgroups directory structures:
    * /sys/fs/cgroup/{cpu,cpuacct}/gpdb: the toplevel gpdb cgroup
    * /sys/fs/cgroup/{cpu,cpuacct}/gpdb/*/: cgroup for each resource group
    
    The logic for cpu rate limitation:
    
    * in toplevel gpdb cgroup we set the cpu quota and share weight as:
    
        cpu.cfs_quota_us := cpu.cfs_period_us * 256 * gp_resource_group_cpu_limit
        cpu.shares := 1024 * ncores
    
    * for each sub group we set the cpu quota and share weight as:
    
        sub.cpu.cfs_quota_us := -1
        sub.cpu.shares := top.cpu.shares * sub.cpu_rate_limit
    
    The minimum and maximum cpu percentage for a sub cgroup:
    
        sub.cpu.min_percentage := gp_resource_group_cpu_limit * sub.cpu_rate_limit
        sub.cpu.max_percentage := gp_resource_group_cpu_limit
    
    The acutal percentage depends on how busy the system is.
    
    gp_resource_group_cpu_limit is a GUC introduced to control the cpu
    resgroups assigned on each host.
    
        gpconfig -c gp_resource_group_cpu_limit -v '0.9'
    
    A new pipeline is created to perform the tests as we need privileged
    permission to enable and setup cgroups on the system.
    Signed-off-by: NNing Yu <nyu@pivotal.io>
    2650f728
cdbvars.c 33.5 KB