[opensuse] cpulimit question
Hi, In the past I have used cpulimit to limit the CPU percent used by a process. But I'm having dificulties. AME cpulimit -- limits the CPU usage of a process SYNOPSIS cpulimit [TARGET] [OPTIONS...] [ -- PROGRAM] DESCRIPTION TARGET must be exactly one of these: -p, --pid=N pid of the process -e, --exe=FILE name of the executable program file -P, --path=PATH absolute path name of the executable program file ... So I do: Isengard:~ # ps afxu | grep rsyncd root 10824 0.0 0.0 7432 812 pts/29 S+ 13:57 0:00 \_ grep --color=auto rsyncd root 4781 0.0 0.0 24584 760 ? Ss Aug01 0:00 /usr/sbin/rsyncd --daemon --no-detach root 8501 0.6 0.0 97452 4788 ? S 12:37 0:32 \_ /usr/sbin/rsyncd --daemon --no-detach root 8502 88.8 0.0 153260 5968 ? R 12:37 70:42 \_ /usr/sbin/rsyncd --daemon --no-detach Isengard:~ # cpulimit -e rsyncd -l 90 Warning: no target process found. Waiting for it... ^CExiting... Isengard:~ # cpulimit -p 8502 -l 90 Process 8502 detected Why doesn't it act on the process by name "rsyncd"? It is obviously in the list of processes. And I'm root. -- Cheers / Saludos, Carlos E. R. (from 15.0 x86_64 at Telcontar)
On 2019/08/02 05:07, Carlos E. R. wrote:
...
So I do:
Isengard:~ # ps afxu | grep rsyncd root 10824 0.0 0.0 7432 812 pts/29 S+ 13:57 0:00 \_ grep --color=auto rsyncd root 4781 0.0 0.0 24584 760 ? Ss Aug01 0:00 /usr/sbin/rsyncd --daemon --no-detach root 8501 0.6 0.0 97452 4788 ? S 12:37 0:32 \_ /usr/sbin/rsyncd --daemon --no-detach root 8502 88.8 0.0 153260 5968 ? R 12:37 70:42 \_ /usr/sbin/rsyncd --daemon --no-detach Isengard:~ # cpulimit -e rsyncd -l 90 Warning: no target process found. Waiting for it... ^CExiting... Isengard:~ # cpulimit -p 8502 -l 90 Process 8502 detected
Why doesn't it act on the process by name "rsyncd"? It is obviously in the list of processes.. And I'm root.
---- It says it only acts on 1 process by that name, and to have it act on a specific one, use the pid. Which it did, you said 90%, and I see 88.8% So what's the problem? I did it on a specific pid, and it seemed to keep it within 10%. Problem is that it only seems to control one at a time. Too bad there's no option for a process-group.
-- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 03/08/2019 05.33, L A Walsh wrote:
On 2019/08/02 05:07, Carlos E. R. wrote:
...
So I do:
Isengard:~ # ps afxu | grep rsyncd root 10824 0.0 0.0 7432 812 pts/29 S+ 13:57 0:00 \_ grep --color=auto rsyncd root 4781 0.0 0.0 24584 760 ? Ss Aug01 0:00 /usr/sbin/rsyncd --daemon --no-detach root 8501 0.6 0.0 97452 4788 ? S 12:37 0:32 \_ /usr/sbin/rsyncd --daemon --no-detach root 8502 88.8 0.0 153260 5968 ? R 12:37 70:42 \_ /usr/sbin/rsyncd --daemon --no-detach Isengard:~ # cpulimit -e rsyncd -l 90 Warning: no target process found. Waiting for it... ^CExiting... Isengard:~ # cpulimit -p 8502 -l 90 Process 8502 detected
Why doesn't it act on the process by name "rsyncd"? It is obviously in the list of processes.. And I'm root.
---- It says it only acts on 1 process by that name, and to have it act on a specific one, use the pid. Which it did, you said 90%, and I see 88.8% So what's the problem?
Well... I need it to act on the last one, which is the one that does the job, and do it by name. You apparently found out why it doesn't act by name: only one process. More and it bails out.
I did it on a specific pid, and it seemed to keep it within 10%.
Problem is that it only seems to control one at a time.
You can call it several times, one per PID, then it acts on all of them: Isengard:~ # ps afxu | grep rsyncd root 14857 0.0 0.0 7432 888 pts/29 S+ 12:45 0:00 \_ grep --color=auto rsyncd root 4781 0.0 0.0 24584 768 ? Ss Aug01 0:00 /usr/sbin/rsyncd --daemon --no-detach root 14843 8.1 0.0 90880 4980 ? S 12:45 0:00 \_ /usr/sbin/rsyncd --daemon --no-detach root 14844 56.2 0.0 94748 4004 ? R 12:45 0:04 \_ /usr/sbin/rsyncd --daemon --no-detach Isengard:~ # cpulimit --lazy --background -p 14843 -l 85 Isengard:~ # Process 14843 detected cpulimit --lazy --background -p 14844 -l 85 Isengard:~ # Process 14844 detected Isengard:~ # ps afxu | grep cpulimit root 14891 0.0 0.0 7432 884 pts/29 S+ 12:46 0:00 \_ grep --color=auto cpulimit root 21475 0.1 0.0 8556 28 pts/29 S< Aug02 1:15 cpulimit --lazy --background -p 4781 -l 85 root 14873 0.2 0.0 8556 108 pts/29 S< 12:45 0:00 cpulimit --lazy --background -p 14843 -l 85 root 14878 0.2 0.0 8556 108 pts/29 S< 12:45 0:00 cpulimit --lazy --background -p 14844 -l 85 Isengard:~ # This method I tried yesterday might be it: Isengard:~ # cpulimit -v -p `pidof rsyncd` -l 85 4 CPUs detected. Priority changed to -10 Process 20048 detected %CPU work quantum sleep quantum active rate 0.00% 100000 us 0 us 99.89% 1.11% 100000 us 0 us 99.90% 2.22% 100000 us 0 us 99.89% 2.22% 100000 us 0 us 99.89% 2.22% 100000 us 0 us 99.87% 2.22% 100000 us 0 us 99.89% 2.22% 100000 us 0 us 99.90% 2.22% 100000 us 0 us 99.91% ^CExiting... Isengard:~ # ps afxu | grep rsyncd root 20185 0.0 0.0 7432 904 pts/29 S+ 20:13 0:00 \_ grep --color=auto rsyncd root 4781 0.0 0.0 24584 728 ? Ss Aug01 0:00 /usr/sbin/rsyncd --daemon --no-detach root 20047 34.9 0.7 114440 59936 ? S 20:08 1:54 \_ /usr/sbin/rsyncd --daemon --no-detach root 20048 3.9 0.8 146580 66200 ? S 20:08 0:13 \_ /usr/sbin/rsyncd --daemon --no-detach Isengard:~ #
Too bad there's no option for a process-group.
I wonder if systemd has something to limit total cpu load of a daemon, that would be the best thing. [...] (googling) Apparently there is: <https://stackoverflow.com/questions/29667758/use-of-cpuquota-in-systemd> [Service] CPUQuota=85% Doing it (systemctl edit rsyncd) Isengard:~ # systemctl status rsyncd ● rsyncd.service - Start the rsync server daemon Loaded: loaded (/usr/lib/systemd/system/rsyncd.service; enabled; vendor preset: disabled) Drop-In: /etc/systemd/system/rsyncd.service.d └─override.conf Active: active (running) since Sat 2019-08-03 13:11:26 CEST; 1s ago Main PID: 15728 (rsyncd) Tasks: 1 (limit: 4915) CPU: 73ms CGroup: /system.slice/rsyncd.service └─15728 /usr/sbin/rsyncd --daemon --no-detach Aug 03 13:11:26 Isengard systemd[1]: Started Start the rsync server daemon. Isengard:~ # Now call the script to do rsync job one more time. Check: Isengard:~ # systemctl status rsyncd ● rsyncd.service - Start the rsync server daemon Loaded: loaded (/usr/lib/systemd/system/rsyncd.service; enabled; vendor preset: disabled) Drop-In: /etc/systemd/system/rsyncd.service.d └─override.conf Active: active (running) since Sat 2019-08-03 13:11:26 CEST; 3min 37s ago Main PID: 15728 (rsyncd) Tasks: 3 (limit: 4915) <============= CPU: 2.066s CGroup: /system.slice/rsyncd.service ├─15728 /usr/sbin/rsyncd --daemon --no-detach ├─15796 /usr/sbin/rsyncd --daemon --no-detach └─15797 /usr/sbin/rsyncd --daemon --no-detach Aug 03 13:11:26 Isengard systemd[1]: Started Start the rsync server daemon. Isengard:~ # Bingo! :-D Sometimes I love systemd :-! :-) I was trying already a method when calling rsync job on the client to launch ssh to run cpulimit on the server and getting stump... when there was a systemd method nice and easy within a single google search :-D -- Cheers / Saludos, Carlos E. R. (from 15.0 x86_64 at Telcontar)
On 2019/08/03 04:20, Carlos E. R. wrote:
Isengard:~ # systemctl status rsyncd ● rsyncd.service - Start the rsync server daemon Loaded: loaded (/usr/lib/systemd/system/rsyncd.service; enabled; vendor preset: disabled) Drop-In: /etc/systemd/system/rsyncd.service.d └─override.conf Active: active (running) since Sat 2019-08-03 13:11:26 CEST; 3min 37s ago Main PID: 15728 (rsyncd) Tasks: 3 (limit: 4915) <============= CPU: 2.066s CGroup: /system.slice/rsyncd.service ├─15728 /usr/sbin/rsyncd --daemon --no-detach ├─15796 /usr/sbin/rsyncd --daemon --no-detach └─15797 /usr/sbin/rsyncd --daemon --no-detach
Aug 03 13:11:26 Isengard systemd[1]: Started Start the rsync server daemon. Isengard:~ #
Bingo! :-D
Sometimes I love systemd :-! :-)
--- That's nice. Um, so 2.066s out of 217s = 90%? Must be systemd math. :^/ You haven't shown that it is limiting it to 90% of 1 cpu. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 04/08/2019 04.58, L A Walsh wrote:
On 2019/08/03 04:20, Carlos E. R. wrote:
Isengard:~ # systemctl status rsyncd ● rsyncd.service - Start the rsync server daemon Loaded: loaded (/usr/lib/systemd/system/rsyncd.service; enabled; vendor preset: disabled) Drop-In: /etc/systemd/system/rsyncd.service.d └─override.conf Active: active (running) since Sat 2019-08-03 13:11:26 CEST; 3min 37s ago Main PID: 15728 (rsyncd) Tasks: 3 (limit: 4915) <============= CPU: 2.066s CGroup: /system.slice/rsyncd.service ├─15728 /usr/sbin/rsyncd --daemon --no-detach ├─15796 /usr/sbin/rsyncd --daemon --no-detach └─15797 /usr/sbin/rsyncd --daemon --no-detach
Aug 03 13:11:26 Isengard systemd[1]: Started Start the rsync server daemon. Isengard:~ #
Bingo! :-D
Sometimes I love systemd :-! :-)
--- That's nice. Um, so 2.066s out of 217s = 90%?
Must be systemd math. :^/
You haven't shown that it is limiting it to 90% of 1 cpu.
For that, you need to fire up top and observe the load going up and down, but not passing 85% (I set the load limit to 85). See: (s): 9.4 us, 16.7 sy, 0.0 ni, 72.8 id, 0.1 wa, 0.0 hi, 1.1 si, 0.0 st KiB Mem : 8012476 total, 125164 free, 681720 used, 7205592 buff/cache KiB Swap: 9446396 total, 8819452 free, 626944 used. 6880100 avail Mem PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 19518 root 20 0 91204 4108 1860 R 84.87 0.051 3:32.60 rsyncd 25536 root 20 0 52992 7308 2304 S 3.947 0.091 121:29.16 iotop ... top - 12:35:36 up 39 days, 22:21, 6 users, load average: 2.55, 2.06, 1.07 Tasks: 394 total, 2 running, 392 sleeping, 0 stopped, 0 zombie %Cpu(s): 9.5 us, 17.0 sy, 0.0 ni, 70.1 id, 1.8 wa, 0.0 hi, 1.7 si, 0.0 st KiB Mem : 8012476 total, 130232 free, 678100 used, 7204144 buff/cache KiB Swap: 9446396 total, 8819452 free, 626944 used. 6885392 avail Mem PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 19518 root 20 0 91204 4108 1860 R 85.25 0.051 4:03.47 rsyncd 25536 root 20 0 52992 7308 2304 S 4.262 0.091 121:30.59 iotop ... top - 12:36:00 up 39 days, 22:22, 6 users, load average: 2.22, 2.03, 1.08 Tasks: 394 total, 2 running, 392 sleeping, 0 stopped, 0 zombie %Cpu(s): 9.4 us, 19.5 sy, 1.5 ni, 66.4 id, 1.3 wa, 0.0 hi, 1.8 si, 0.0 st KiB Mem : 8012476 total, 141572 free, 676808 used, 7194096 buff/cache KiB Swap: 9446396 total, 8819452 free, 626944 used. 6886684 avail Mem PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 19518 root 20 0 91204 3872 1624 R 84.26 0.048 4:20.53 rsyncd 925 cer 20 0 2832304 143504 5512 S 10.82 1.791 825:42.78 kodi-x11 25536 root 20 0 52992 7136 2132 S 4.262 0.089 121:31.53 iotop -- Cheers / Saludos, Carlos E. R. (from 15.0 x86_64 at Telcontar)
On 2019/08/04 04:06, Carlos E. R. wrote:
You haven't shown that it is limiting it to 90% of 1 cpu.
For that, you need to fire up top and observe the load going up and down, but not passing 85% (I set the load limit to 85). See:
your previous example showed it at or near the limit, so I'd expected a similar output like below....
%Cpu(s): 9.4 us, 16.7 sy, 0.0 ni, 72.8 id, 0.1 wa, 0.0 hi, 1.1 si, 0.0 st 19518 root 20 0 91204 4108 1860 R 84.87 0.051 3:32.60 rsyncd .... %Cpu(s): 9.5 us, 17.0 sy, 0.0 ni, 70.1 id, 1.8 wa, 0.0 hi, 1.7 si, 0.0 st 19518 root 20 0 91204 4108 1860 R 85.25 0.051 4:03.47 rsyncd
%Cpu(s): 9.4 us, 19.5 sy, 1.5 ni, 66.4 id, 1.3 wa, 0.0 hi, 1.8 si, 0.0 st 19518 root 20 0 91204 3872 1624 R 84.26 0.048 4:20.53 rsyncd
---- You have a quad core, I take it? Wonder if it can do the same with io & network bandwidth... :-) -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 04/08/2019 13.46, L A Walsh wrote:
On 2019/08/04 04:06, Carlos E. R. wrote:
You haven't shown that it is limiting it to 90% of 1 cpu.
For that, you need to fire up top and observe the load going up and down, but not passing 85% (I set the load limit to 85). See:
your previous example showed it at or near the limit, so I'd expected a similar output like below....
%Cpu(s): 9.4 us, 16.7 sy, 0.0 ni, 72.8 id, 0.1 wa, 0.0 hi, 1.1 si, 0.0 st 19518 root 20 0 91204 4108 1860 R 84.87 0.051 3:32.60 rsyncd .... %Cpu(s): 9.5 us, 17.0 sy, 0.0 ni, 70.1 id, 1.8 wa, 0.0 hi, 1.7 si, 0.0 st 19518 root 20 0 91204 4108 1860 R 85.25 0.051 4:03.47 rsyncd
%Cpu(s): 9.4 us, 19.5 sy, 1.5 ni, 66.4 id, 1.3 wa, 0.0 hi, 1.8 si, 0.0 st 19518 root 20 0 91204 3872 1624 R 84.26 0.048 4:20.53 rsyncd
Yes, the rsyncd process keeps constantly below 85%, it is working correctly.
You have a quad core, I take it?
Right. With program "cpulimit" you can set a limit of 200%, if the process uses more cores. Apparently rsyncd only uses one core. Thus on systemd I wondered if I had to define the limit related to the total number of cores, ie, 20%, or related to 400%. I hit the correct number per chance, at the first try.
Wonder if it can do the same with io & network bandwidth...
:-)
Dunno. I asked google for cpu limit on systemd ;-) -- Cheers / Saludos, Carlos E. R. (from 15.0 x86_64 at Telcontar)
participants (2)
-
Carlos E. R.
-
L A Walsh