[opensuse] Trying to adjust the swapiness of clamd
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I'm trying to force the clamd process to swap agresively, because by default it eats 500 MB of my limited memory even when it is doing nothing but waiting. Sorting process list in "top" by "RES" column shows that clamd is the 5th process using most memory in my system: top - 14:21:12 up 7 days, 14 min, 1 user, load average: 0,60, 0,70, 0,74 Tasks: 532 total, 2 running, 529 sleeping, 0 stopped, 1 zombie %Cpu(s): 5,8 us, 1,6 sy, 0,0 ni, 91,0 id, 1,7 wa, 0,0 hi, 0,0 si, 0,0 st KiB Mem: 8174528 total, 7765124 used, 409404 free, 24892 buffers KiB Swap: 25165820 total, 5177256 used, 19988564 free. 1970388 cached Mem PID USER PR NI VIRT RES SHR SWAP S %CPU %MEM TIME+ COMMAND 7098 cer 20 0 4249152 1,415g 61572 392760 S 0,000 18,15 295:54.17 thunderbird-bin 7494 cer 20 0 3040184 839476 51296 256248 S 0,330 10,27 155:16.49 Web Content 7341 cer 20 0 2858436 746840 41012 202296 S 3,300 9,136 74:35.03 Web Content 5221 cer 20 0 10,139g 740952 137364 464756 S 1,650 9,064 134:50.52 firefox 12020 vscan 20 0 711128 552372 1660 0 S 0,000 6,757 0:00.00 clamd ... Apparently this is done with cgroups, about which I know close to nothing. First I see: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/htm... but I do not understand how to make use of it, except that I want to change memory.swappiness of the process. But I do not see where is that virtual file for the clamd process, if it exists. The examples there do things like: ~]# echo 1G > /cgroup/memory/lab1/memory.limit_in_bytes but they have a "lab1" entry for the particular process they are managing. I don't know how that entry appears. This is what I have: Telcontar:~ # ls /sys/fs/cgroup/memory/ cgroup.clone_children cgroup.sane_behavior memory.limit_in_bytes memory.move_charge_at_immigrate memory.pressure_level memory.swappiness notify_on_release cgroup.event_control memory.failcnt memory.low_limit_in_bytes memory.numa_stat memory.soft_limit_in_bytes memory.usage_in_bytes release_agent cgroup.procs memory.force_empty memory.max_usage_in_bytes memory.oom_control memory.stat memory.use_hierarchy tasks Telcontar:~ # So I continue googling. Aparently systemd can control cgroups. On systemd documentation site, http://0pointer.de/blog/projects/resources.html, I see that cgroup settings can be set on the systemd unit file. systemd for Administrators, Part XVIII Managing Resources ... Managing Other Resource Parameters which gives the exact example I want to try: [Service] ControlGroupAttribute=memory.swappiness 70 Fantastic! So I create "/etc/systemd/system/clamd.service.d/override.conf" file: [Service] ControlGroupAttribute=memory.swappiness 100 And try: Telcontar:~ # systemctl daemon-reload Telcontar:~ # systemctl status clamd.service ● clamd.service - Clamav antivirus Deamon Loaded: loaded (/usr/lib/systemd/system/clamd.service; disabled; vendor preset: disabled) Drop-In: /etc/systemd/system/clamd.service.d └─override.conf Active: active (running) since Mon 2018-10-15 14:07:56 CEST; 1min 2s ago Main PID: 12020 (clamd) Tasks: 2 (limit: 512) CGroup: /system.slice/clamd.service └─12020 /usr/sbin/clamd Oct 15 14:07:55 Telcontar clamd[12020]: Mail files support enabled. Oct 15 14:07:55 Telcontar clamd[12020]: OLE2 support enabled. Oct 15 14:07:55 Telcontar clamd[12020]: PDF support enabled. Oct 15 14:07:55 Telcontar clamd[12020]: SWF support enabled. Oct 15 14:07:55 Telcontar clamd[12020]: HTML support enabled. Oct 15 14:07:55 Telcontar clamd[12020]: XMLDOCS support enabled. Oct 15 14:07:55 Telcontar clamd[12020]: HWP3 support enabled. Oct 15 14:07:55 Telcontar clamd[12020]: Self checking every 3600 seconds. Oct 15 14:07:56 Telcontar systemd[1]: Started Clamav antivirus Deamon. Oct 15 14:08:49 Telcontar systemd[1]: [/etc/systemd/system/clamd.service.d/override.conf:2] Unknown lvalue 'ControlGroupAttribute' in section 'Service' Telcontar:~ # What? The lvalue is copied from the documentation! How can I then do it? - -- Cheers Carlos E. R. (from 42.3 x86_64 at Telcontar) -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iEYEARECAAYFAlvEiR4ACgkQtTMYHG2NR9XivACdGYCwgSru7a07vrXoejO/VP3A zXAAnjnb3Alv/2OxyH9Yit2rdBca2J0H =ZRmA -----END PGP SIGNATURE-----
Carlos E. R. wrote:
I'm trying to force the clamd process to swap agresively, because by default it eats 500 MB of my limited memory even when it is doing nothing but waiting.
Be aware this will increase email processing time, otherwise it ought to work fine.
Apparently this is done with cgroups, about which I know close to nothing.
Search the list for an example in the last couple of weeks. I can't remember who it was, but one process was gobbling up too much memory, rendering the entire system unworkable. The issue was solved by setting a memory limit using cgroups.
Oct 15 14:08:49 Telcontar systemd[1]: [/etc/systemd/system/clamd.service.d/override.conf:2] Unknown lvalue ['ControlGroupAttribute' in section 'Service' Telcontar:~ #
What? The lvalue is copied from the documentation! How can I then do it?
The option was removed: https://bugzilla.redhat.com/show_bug.cgi?id=1172890 -- Per Jessen, Zürich (21.1°C) http://www.dns24.ch/ - free dynamic DNS, made in Switzerland. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Monday, 2018-10-15 at 14:54 +0200, Per Jessen wrote:
Carlos E. R. wrote:
I'm trying to force the clamd process to swap agresively, because by default it eats 500 MB of my limited memory even when it is doing nothing but waiting.
Be aware this will increase email processing time, otherwise it ought to work fine.
That's fine. Swapping out is not immediate, so if there is a continuous flow of mails it should not swap. A delay of a fraction of a second when sending a single email is not important.
Apparently this is done with cgroups, about which I know close to nothing.
Search the list for an example in the last couple of weeks. I can't remember who it was, but one process was gobbling up too much memory, rendering the entire system unworkable. The issue was solved by setting a memory limit using cgroups.
Limiting memory would probably make the process to crash, I suppose.
Probably this one:
Date: Wed, 19 Sep 2018 12:21:11 +0100
From: Peter Suetterlin <>
To: "opensuse@opensuse.org"
Oct 15 14:08:49 Telcontar systemd[1]: [/etc/systemd/system/clamd.service.d/override.conf:2] Unknown lvalue ['ControlGroupAttribute' in section 'Service' Telcontar:~ #
What? The lvalue is copied from the documentation! How can I then do it?
The option was removed: https://bugzilla.redhat.com/show_bug.cgi?id=1172890
Damm! :-/ Lukáš Nykrýn 2014-12-11 01:35:42 EST This option was removed in 208 - From 208 release notes: * As discussed earlier, the low-level cgroup configuration options ControlGroup=, ControlGroupModify=, ControlGroupPersistent=, ControlGroupAttribute= have been removed. Please use high-level attribute settings instead as well as slice units. And some other info http://lwn.net/Articles/555923/ But what "high-level attribute setting"? The link does not explain. Those entries were used when the high-level attributes do not exist - so says the doc. Where are they listed, if the documentation is incorrect? - -- Cheers, Carlos E. R. (from openSUSE 42.3 x86_64 "Malachite" at Telcontar) -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iEYEARECAAYFAlvEme8ACgkQtTMYHG2NR9XG8wCeJnEGyQ79gRWjSqLA8ql0vxzD 78MAoIXsdX/G5/Mhf+w8QA6FrKELEDT9 =+TsZ -----END PGP SIGNATURE-----
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Monday, 2018-10-15 at 15:45 +0200, Carlos E. R. wrote: ...
But still does not swap out anything.
It does now. Not as much as I would like, though.
top - 15:36:30 up 7 days, 1:29, 1 user, load average: 0,76, 0,71, 0,72 Tasks: 531 total, 1 running, 529 sleeping, 0 stopped, 1 zombie % Cpu(s): 12,0 us, 3,1 sy, 0,0 ni, 75,5 id, 9,3 wa, 0,0 hi, 0,1 si, 0,0 % st KiB Mem: 8174528 total, 7674028 used, 500500 free, 18516 buffers KiB Swap: 25165820 total, 5125572 used, 20040248 free. 1780272 cached Mem
PID USER PR NI VIRT RES SHR SWAP S %CPU %MEM TIME+ COMMAND 7098 cer 20 0 4340104 1,534g 58612 388588 S 0,330 19,67 306:21.50 thunderbird-bin 7494 cer 20 0 3080508 845212 67024 255556 S 15,18 10,34 159:22.82 Web Content 5221 cer 20 0 10,116g 670840 136600 462136 S 18,48 8,206 137:51.72 firefox 7341 cer 20 0 2892228 660472 37464 202260 S 0,330 8,080 78:58.07 Web Content 16284 vscan 20 0 784860 554400 3508 0 S 0,000 6,782 0:00.01 clamd . . . . . . . . . . . . . . . . . . . . . .*******
16284 vscan 20 0 785012 208696 3296 345896 S 0,000 2,553 0:14.70 clamd That's with memory.swappiness = 99. I'll try 100 now. Notice that the TIME+ is now used, so some automatic emails were sent, or its database was updated. - -- Cheers, Carlos E. R. (from openSUSE 42.3 x86_64 "Malachite" at Telcontar) -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iEYEARECAAYFAlvE4X0ACgkQtTMYHG2NR9Xb4wCeLrKMQGxEpRk/+oQJCn1iRiG+ 8P4AoIR6UrJasbzhPVJpWjndFueJk5/3 =YQwf -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Monday, 2018-10-15 at 20:50 +0200, Carlos E. R. wrote:
On Monday, 2018-10-15 at 15:45 +0200, Carlos E. R. wrote:
...
But still does not swap out anything.
It does now. Not as much as I would like, though.
top - 15:36:30 up 7 days, 1:29, 1 user, load average: 0,76, 0,71, 0,72 Tasks: 531 total, 1 running, 529 sleeping, 0 stopped, 1 zombie % Cpu(s): 12,0 us, 3,1 sy, 0,0 ni, 75,5 id, 9,3 wa, 0,0 hi, 0,1 si, % 0,0 % st KiB Mem: 8174528 total, 7674028 used, 500500 free, 18516 buffers KiB Swap: 25165820 total, 5125572 used, 20040248 free. 1780272 cached Mem
PID USER PR NI VIRT RES SHR SWAP S %CPU %MEM TIME+ COMMAND 7098 cer 20 0 4340104 1,534g 58612 388588 S 0,330 19,67 306:21.50 thunderbird-bin 7494 cer 20 0 3080508 845212 67024 255556 S 15,18 10,34 159:22.82 Web Content 5221 cer 20 0 10,116g 670840 136600 462136 S 18,48 8,206 137:51.72 firefox 7341 cer 20 0 2892228 660472 37464 202260 S 0,330 8,080 78:58.07 Web Content 16284 vscan 20 0 784860 554400 3508 0 S 0,000 6,782 0:00.01 clamd . . . . . . . . . . . . . . . . . . . . . .*******
16284 vscan 20 0 785012 208696 3296 345896 S 0,000 2,553 0:14.70 clamd
That's with memory.swappiness = 99. I'll try 100 now. Notice that the TIME+ is now used, so some automatic emails were sent, or its database was updated.
with 100, after a while: 16284 vscan 20 0 785012 107380 3244 447160 S 0,000 1,314 0:14.73 clamd Much better :-) Next step: automatize init. - -- Cheers, Carlos E. R. (from openSUSE 42.3 x86_64 "Malachite" at Telcontar) -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iEYEARECAAYFAlvE5C0ACgkQtTMYHG2NR9WtpACdGtcGIDlN3ouh9blczpIHjOft NJUAnA+AdvyyeK18C/7Ye4LrURgUwKup =qTKD -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Monday, 2018-10-15 at 21:02 +0200, Carlos E. R. wrote:
On Monday, 2018-10-15 at 20:50 +0200, Carlos E. R. wrote:
On Monday, 2018-10-15 at 15:45 +0200, Carlos E. R. wrote:
...
But still does not swap out anything.
It does now. Not as much as I would like, though.
top - 15:36:30 up 7 days, 1:29, 1 user, load average: 0,76, 0,71, 0,72 Tasks: 531 total, 1 running, 529 sleeping, 0 stopped, 1 zombie %Cpu(s): 12,0 us, 3,1 sy, 0,0 ni, 75,5 id, 9,3 wa, 0,0 hi, 0,1 si, 0,0 st KiB Mem: 8174528 total, 7674028 used, 500500 free, 18516 buffers KiB Swap: 25165820 total, 5125572 used, 20040248 free. 1780272 cached Mem
PID USER PR NI VIRT RES SHR SWAP S %CPU %MEM TIME+ COMMAND 7098 cer 20 0 4340104 1,534g 58612 388588 S 0,330 19,67 306:21.50 thunderbird-bin 7494 cer 20 0 3080508 845212 67024 255556 S 15,18 10,34 159:22.82 Web Content 5221 cer 20 0 10,116g 670840 136600 462136 S 18,48 8,206 137:51.72 firefox 7341 cer 20 0 2892228 660472 37464 202260 S 0,330 8,080 78:58.07 Web Content 16284 vscan 20 0 784860 554400 3508 0 S 0,000 6,782 0:00.01 clamd . . . . . . . . . . . . . . . . . . . . . .*******
16284 vscan 20 0 785012 208696 3296 345896 S 0,000 2,553 0:14.70 clamd
That's with memory.swappiness = 99. I'll try 100 now. Notice that the TIME+ is now used, so some automatic emails were sent, or its database was updated.
with 100, after a while:
16284 vscan 20 0 785012 107380 3244 447160 S 0,000 1,314 0:14.73 clamd
Much better :-)
and improving: 16284 vscan 20 0 785012 43892 3084 510488 S 0,000 0,537 0:14.87 clamd I wonder why it took so long to swap it out :-?
Next step: automatize init.
- -- Cheers, Carlos E. R. (from openSUSE 42.3 x86_64 "Malachite" at Telcontar) -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iEYEARECAAYFAlvE/uUACgkQtTMYHG2NR9VumQCeLXwyx3XME5nMxA+IjWAaB9DY t+MAnj5PY2Z3UertY0ZyCff9BlPjHWxB =djzb -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 10/15/2018 03:56 PM, Carlos E. R. wrote:
and improving:
16284 vscan 20 0 785012 43892 3084 510488 S 0,000 0,537 0:14.87 clamd
I wonder why it took so long to swap it out :-?
Did you try echoing 100 > /proc/sys/vm/swappiness directly? It should respect the /etc/sysctl.d/99-sysctl.conf vm.swappiness config option, but I'm not sure when that is re-read on change. -- David C. Rankin, J.D.,P.E.
On 16/10/2018 00.46, David C. Rankin wrote:
On 10/15/2018 03:56 PM, Carlos E. R. wrote:
and improving:
16284 vscan 20 0 785012 43892 3084 510488 S 0,000 0,537 0:14.87 clamd
I wonder why it took so long to swap it out :-?
Did you try echoing 100 > /proc/sys/vm/swappiness directly? It should respect the /etc/sysctl.d/99-sysctl.conf vm.swappiness config option, but I'm not sure when that is re-read on change.
No, no. That would be global, and I want it on a single process, which is working now. What remains is doing it automatically, some setting on the systemd clamd.service unit. -- Cheers / Saludos, Carlos E. R. (from openSUSE 15.0 (Legolas))
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Monday, 2018-10-15 at 15:45 +0200, Carlos E. R. wrote:
On Monday, 2018-10-15 at 14:54 +0200, Per Jessen wrote:
Carlos E. R. wrote:
I'm trying to force the clamd process to swap agresively, because by default it eats 500 MB of my limited memory even when it is doing nothing but waiting.
...
Apparently this is done with cgroups, about which I know close to nothing.
Search the list for an example in the last couple of weeks. I can't remember who it was, but one process was gobbling up too much memory, rendering the entire system unworkable. The issue was solved by setting a memory limit using cgroups.
...
Limiting memory would probably make the process to crash, I suppose.
Probably this one:
Date: Wed, 19 Sep 2018 12:21:11 +0100 From: Peter Suetterlin <> To: "opensuse@opensuse.org"
Subject: Re: [opensuse] swap performance ...
Ok, so I created a clamd cgroup to adjust its memory.swappiness to 100, and that works. It is not swaped out fast. Now I have edited "/usr/lib/systemd/system/clamd.service" thus: [Unit] Description=Clamav antivirus Deamon After=syslog.target network.target [Service] Type=forking ExecStartPre=/bin/sh -c "mkdir /sys/fs/cgroup/memory/clamd" ExecStartPre=/bin/sh -c "echo 100 > /sys/fs/cgroup/memory/clamd/memory.swappiness" ExecStart=/usr/sbin/clamd ExecStartPost=/bin/sh -c "echo $MAINPID > /sys/fs/cgroup/memory/clamd/cgroup.procs" ;User=vscan ;Group=vscan ;PrivateTmp=yes ExecStopPost=/bin/sh -c "rmdir /sys/fs/cgroup/memory/clamd" [Install] WantedBy=multi-user.target :-) Maybe I can move the modifications to "/etc/systemd/system/clamd.service.d/override.conf" instead. :-? - -- Cheers, Carlos E. R. (from openSUSE 42.3 x86_64 "Malachite" at Telcontar) -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iEYEARECAAYFAlwBRdYACgkQtTMYHG2NR9WIGgCcDv+ZwgGBdc7XA2mK5jjMxkRa JbMAniRyMVYqbvkWZsejz+nE2RVuFZjn =NstW -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
participants (3)
-
Carlos E. R.
-
David C. Rankin
-
Per Jessen