main/openrc: rc-service stop deley one second for each service
@psykose
issue
let's say we have 5 services to stop in a script :
for service in A B C D E ; do rc-service $service stop ; done
A takes 0.09s to stop, but after that, each of B C D E takes about 1 seconds to stop.
Tested on alpine 3.11-3.17 and current edge, aarch64 and x86_64, all have the same issue
Also tested on Gentoo livecd /openrc 0.45.2 , but NO issue. every service takes about 0.05s~0.09s to stop
some questions: is this related to musl libc or the patches alpine uses or the openrc compile options?
it would be nice if the devs could run below test and verify, thanks a lot
test script
#!/bin/sh
# what is this for
# well, if we stop multiple services in a script
# the first one is always fast, but after that, it becomes super slow
#
# nc is a good program to test supervise-daemon
# create 5 nc daemons, listen on 5 different port
# prepare
echo '+++ prepare 5 nc daemons +++'
echo
for i in 1 2 3 4 5 ; do
cat <<EOF > /etc/init.d/supervise-daemon_$i
#!/sbin/openrc-run
supervisor="supervise-daemon"
command="/bin/busybox"
command_args="nc -l -s 127.0.0.1 -p 3000$i"
EOF
chmod +x /etc/init.d/supervise-daemon_$i
echo "created /etc/init.d/supervise-daemon_$i"
done
echo
# measure start
echo "+++ measure time to start 5 daemons +++"
echo
for i in 1 2 3 4 5 ; do
echo "==> starting supervise-daemon_$i"
time rc-service -q supervise-daemon_$i start
echo
done
echo "+++ measure time to stop 5 daemons +++"
echo
# measure stop
for i in 1 2 3 4 5 ; do
echo "==> stopping supervise-daemon_$i"
time rc-service -q supervise-daemon_$i stop
echo
done
# clean
for i in 1 2 3 4 5 ; do
rm -f /etc/init.d/supervise-daemon_$i
echo "/etc/init.d/supervise-daemon_$i deleted"
done
test result
+++ prepare 5 nc daemons +++
created /etc/init.d/supervise-daemon_1
created /etc/init.d/supervise-daemon_2
created /etc/init.d/supervise-daemon_3
created /etc/init.d/supervise-daemon_4
created /etc/init.d/supervise-daemon_5
+++ measure time to start 5 daemons +++
==> starting supervise-daemon_1
real 0m 0.91s
user 0m 0.43s
sys 0m 0.49s
==> starting supervise-daemon_2
real 0m 0.09s
user 0m 0.02s
sys 0m 0.04s
==> starting supervise-daemon_3
real 0m 0.08s
user 0m 0.03s
sys 0m 0.03s
==> starting supervise-daemon_4
real 0m 0.09s
user 0m 0.02s
sys 0m 0.03s
==> starting supervise-daemon_5
real 0m 0.10s
user 0m 0.03s
sys 0m 0.03s
+++ measure time to stop 5 daemons +++
==> stopping supervise-daemon_1
real 0m 0.09s
user 0m 0.03s
sys 0m 0.04s
==> stopping supervise-daemon_2
real 0m 1.00s
user 0m 0.06s
sys 0m 0.33s
==> stopping supervise-daemon_3
real 0m 1.00s
user 0m 0.09s
sys 0m 0.36s
==> stopping supervise-daemon_4
real 0m 0.99s
user 0m 0.09s
sys 0m 0.35s
==> stopping supervise-daemon_5
real 0m 1.00s
user 0m 0.08s
sys 0m 0.39s
/etc/init.d/supervise-daemon_1 deleted
/etc/init.d/supervise-daemon_2 deleted
/etc/init.d/supervise-daemon_3 deleted
/etc/init.d/supervise-daemon_4 deleted
/etc/init.d/supervise-daemon_5 deleted