1 |
www-apps/gitea often used all 4 of my CPU cores and slowed everything |
2 |
else down. So I attempted to limit CPU usage with cgroups: |
3 |
|
4 |
I have set this in /etc/rc.conf: |
5 |
|
6 |
rc_cgroup_mode="unified" |
7 |
rc_cgroup_controllers="cpu memory io pids" |
8 |
|
9 |
And this in /etc/conf.d/gitea: |
10 |
|
11 |
rc_cgroup_settings=" |
12 |
cpu.shares 128 |
13 |
cpu.cfs_period_us 1000000 |
14 |
cpu.cfs_quota_us 1000000 |
15 |
memory.limit_in_bytes 8G |
16 |
" |
17 |
|
18 |
According to my research, setting cpu.cfs_period_us and |
19 |
cpu.cfs_quota_us to the same value should ensure that only the power of |
20 |
one core is used, and “cpu.shares 128” should only use 12.5% (half a |
21 |
core in my case) of the CPU if the system is under load. The CPU usage |
22 |
in htop should be at most 100%, right?. However, I often see 110%, |
23 |
sometimes up to 180% and rarely 230%. Are that all accounting errors or |
24 |
did I do someting wrong? How can I check if my settings are applied? |
25 |
|
26 |
/sys/fs/cgroup/gitea/cgroup.threads contains all the gitea-pids and the |
27 |
pids of its child processes. |
28 |
|
29 |
$ zgrep CGROUP /proc/config.gz |
30 |
CONFIG_CGROUPS=y |
31 |
CONFIG_BLK_CGROUP=y |
32 |
CONFIG_CGROUP_WRITEBACK=y |
33 |
CONFIG_CGROUP_SCHED=y |
34 |
CONFIG_CGROUP_PIDS=y |
35 |
# CONFIG_CGROUP_RDMA is not set |
36 |
CONFIG_CGROUP_FREEZER=y |
37 |
CONFIG_CGROUP_HUGETLB=y |
38 |
CONFIG_CGROUP_DEVICE=y |
39 |
CONFIG_CGROUP_CPUACCT=y |
40 |
CONFIG_CGROUP_PERF=y |
41 |
# CONFIG_CGROUP_DEBUG is not set |
42 |
CONFIG_SOCK_CGROUP_DATA=y |
43 |
CONFIG_BLK_CGROUP_RWSTAT=y |
44 |
# CONFIG_BLK_CGROUP_IOLATENCY is not set |
45 |
# CONFIG_BLK_CGROUP_IOCOST is not set |
46 |
# CONFIG_NETFILTER_XT_MATCH_CGROUP is not set |
47 |
CONFIG_NET_CLS_CGROUP=y |
48 |
CONFIG_CGROUP_NET_PRIO=y |
49 |
CONFIG_CGROUP_NET_CLASSID=y |
50 |
|
51 |
$ mount | grep cgroup |
52 |
none on /sys/fs/cgroup type cgroup2 (rw,nosuid,nodev,noexec,relatime) |
53 |
|
54 |
Kind regards, tastytea |
55 |
|
56 |
-- |
57 |
Get my PGP key with `gpg --locate-keys tastytea@××××××××.de` or at |
58 |
<https://tastytea.de/tastytea.asc>. |