Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWill Chandler <wchandler@gitlab.com>2023-10-23 17:38:06 +0300
committerWill Chandler <wchandler@gitlab.com>2023-11-07 23:00:26 +0300
commit762a060bb986816f165a9fec7e8864f35cd0e410 (patch)
tree57a82c64b3bb6dad3ef5a1af080f628f86240ddc
parentc65b631d971809d9e0294356d7892860d4800cf3 (diff)
cgroups: Store repo resources in CGroupManager
Currently we generate the `reposResources` value via the `configRepositoryResources()` function on the `CGroupManager`. This works well when we create all of the repository cgroups in one batch, but we will shortly move to creating them on-demand. To avoid regenerating this struct for each of the N repository cgroups defined, create it once during construction of the `CgroupManger` and store it in the struct.
-rw-r--r--internal/cgroups/manager_linux.go18
1 files changed, 10 insertions, 8 deletions
diff --git a/internal/cgroups/manager_linux.go b/internal/cgroups/manager_linux.go
index f2cf383dd..01db422f2 100644
--- a/internal/cgroups/manager_linux.go
+++ b/internal/cgroups/manager_linux.go
@@ -40,6 +40,7 @@ type CGroupManager struct {
cfg cgroupscfg.Config
pid int
enabled bool
+ repoRes *specs.LinuxResources
handler cgroupHandler
}
@@ -65,6 +66,7 @@ func newCgroupManagerWithMode(cfg cgroupscfg.Config, logger log.Logger, pid int,
cfg: cfg,
pid: pid,
handler: handler,
+ repoRes: configRepositoryResources(cfg),
}
}
@@ -73,7 +75,7 @@ func (cgm *CGroupManager) Setup() error {
if err := cgm.handler.setupParent(cgm.configParentResources()); err != nil {
return err
}
- if err := cgm.handler.setupRepository(cgm.configRepositoryResources()); err != nil {
+ if err := cgm.handler.setupRepository(cgm.repoRes); err != nil {
return err
}
cgm.enabled = true
@@ -191,23 +193,23 @@ func (cgm *CGroupManager) configParentResources() *specs.LinuxResources {
return &parentResources
}
-func (cgm *CGroupManager) configRepositoryResources() *specs.LinuxResources {
+func configRepositoryResources(cfg cgroupscfg.Config) *specs.LinuxResources {
cfsPeriodUs := cfsPeriodUs
var reposResources specs.LinuxResources
// Leave them `nil` so it takes kernel default unless cfg value above `0`.
reposResources.CPU = &specs.LinuxCPU{}
- if cgm.cfg.Repositories.CPUShares > 0 {
- reposResources.CPU.Shares = &cgm.cfg.Repositories.CPUShares
+ if cfg.Repositories.CPUShares > 0 {
+ reposResources.CPU.Shares = &cfg.Repositories.CPUShares
}
- if cgm.cfg.Repositories.CPUQuotaUs > 0 {
- reposResources.CPU.Quota = &cgm.cfg.Repositories.CPUQuotaUs
+ if cfg.Repositories.CPUQuotaUs > 0 {
+ reposResources.CPU.Quota = &cfg.Repositories.CPUQuotaUs
reposResources.CPU.Period = &cfsPeriodUs
}
- if cgm.cfg.Repositories.MemoryBytes > 0 {
- reposResources.Memory = &specs.LinuxMemory{Limit: &cgm.cfg.Repositories.MemoryBytes}
+ if cfg.Repositories.MemoryBytes > 0 {
+ reposResources.Memory = &specs.LinuxMemory{Limit: &cfg.Repositories.MemoryBytes}
}
return &reposResources
}