what if native systemd service is slower than old sysvinit script?

Michał Piotrowski mkkp4x4 at gmail.com
Wed Sep 14 07:25:42 UTC 2011


2011/9/14 Tom Lane <tgl at redhat.com>:
> =?ISO-8859-2?Q?Micha=B3_Piotrowski?= <mkkp4x4 at gmail.com> writes:
>> 2011/9/14 Tom Lane <tgl at redhat.com>:
>>> Certainly postgresql.init was never exactly lean-and-mean, so it
>>> seems like it ought to have been doing more work than the unit file
>>> requires.  Are you sure you were comparing apples to apples as far as
>>> the state of the database, kernel disk cache, etc goes?
>
>> I copied the service to /etc/systemd/system and changed PGDATA
>> variable, then I enabled the service and rebooted. After boot I
>> checked system boot time with systemd-analyze - I saw that it starts
>> slow, so I disabled it and deleted from /etc/systemd/system. After
>> another reboot again checked boot time with systemd-analyze.
>
>> I'll check tomorrow how repeatable is native service boot time.
>
> I'd suggest first timing some rounds of manual "service postgresql start",
> "service postgresql stop" to see what things look like without all
> the other noise involved in a system boot.

Ok, I made four series of tests:
- start/stop an old init script
- start/stop an old init script with dropping caches - should simulate
system booting
- start/stop service file
- start/stop service file with dropping caches

In each series of tests were repeated five times.
series 1 - start - 2.2+ sec
series 1 - stop - 1.2+ sec

series 2 - start - 2.4+ sec
series 2 - stop - 1.3+ sec

series 3 - start - 3.1+ sec
series 3 - stop - 1.1+ sec

series 4 - start - 4.2+ sec
series 4 - stop - 1.1+ sec

Results are reproducible.

=== old init script ===

time sudo systemctl start postgresql.service
real    0m2.248s
user    0m0.012s
sys     0m0.022s

time sudo systemctl stop postgresql.service
real    0m1.288s
user    0m0.007s
sys     0m0.027s

time sudo systemctl start postgresql.service
real    0m2.252s
user    0m0.014s
sys     0m0.020s

time sudo systemctl stop postgresql.service
real    0m1.282s
user    0m0.012s
sys     0m0.021s

time sudo systemctl start postgresql.service
real    0m2.230s
user    0m0.006s
sys     0m0.028s

time sudo systemctl stop postgresql.service
real    0m1.273s
user    0m0.012s
sys     0m0.021s

time sudo systemctl start postgresql.service
real    0m2.232s
user    0m0.007s
sys     0m0.028s

time sudo systemctl stop postgresql.service
real    0m1.266s
user    0m0.010s
sys     0m0.023s

time sudo systemctl start postgresql.service
real    0m2.246s
user    0m0.011s
sys     0m0.023s

time sudo systemctl stop postgresql.service
real    0m1.277s
user    0m0.007s
sys     0m0.026s


=== old init script + echo 1 > drop_caches ===

time sudo systemctl start postgresql.service
real    0m2.586s
user    0m0.013s
sys     0m0.034s

time sudo systemctl stop postgresql.service
real    0m1.393s
user    0m0.009s
sys     0m0.034s

time sudo systemctl start postgresql.service
real    0m2.492s
user    0m0.014s
sys     0m0.032s

time sudo systemctl stop postgresql.service
real    0m1.391s
user    0m0.009s
sys     0m0.036s

time sudo systemctl start postgresql.service
real    0m2.598s
user    0m0.009s
sys     0m0.037s

time sudo systemctl stop postgresql.service
real    0m1.385s
user    0m0.011s
sys     0m0.031s

time sudo systemctl start postgresql.service
real    0m2.563s
user    0m0.015s
sys     0m0.031s

time sudo systemctl stop postgresql.service
real    0m1.384s
user    0m0.015s
sys     0m0.029s

time sudo systemctl start postgresql.service
real    0m2.581s
user    0m0.016s
sys     0m0.030s

time sudo systemctl stop postgresql.service
real    0m1.391s
user    0m0.010s
sys     0m0.035s


=== systemd service ===

time sudo systemctl start postgresql.service
real    0m3.167s
user    0m0.008s
sys     0m0.025s

time sudo systemctl stop postgresql.service
real    0m1.124s
user    0m0.014s
sys     0m0.020s

time sudo systemctl start postgresql.service
real    0m3.180s
user    0m0.009s
sys     0m0.024s

time sudo systemctl stop postgresql.service
real    0m1.121s
user    0m0.008s
sys     0m0.025s

time sudo systemctl start postgresql.service
real    0m3.164s
user    0m0.012s
sys     0m0.022s

time sudo systemctl stop postgresql.service
real    0m1.112s
user    0m0.006s
sys     0m0.027s

time sudo systemctl start postgresql.service
real    0m3.161s
user    0m0.014s
sys     0m0.019s

time sudo systemctl stop postgresql.service
real    0m1.130s
user    0m0.010s
sys     0m0.024s

time sudo systemctl start postgresql.service
real    0m3.174s
user    0m0.011s
sys     0m0.022s

time sudo systemctl stop postgresql.service
real    0m1.123s
user    0m0.008s
sys     0m0.026s


=== systemd service + echo 1 > drop_caches ===

time sudo systemctl start postgresql.service
real    0m4.320s
user    0m0.014s
sys     0m0.030s

time sudo systemctl stop postgresql.service
real    0m1.196s
user    0m0.012s
sys     0m0.033s

time sudo systemctl start postgresql.service
real    0m4.289s
user    0m0.008s
sys     0m0.037s

time sudo systemctl stop postgresql.service
real    0m1.204s
user    0m0.011s
sys     0m0.033s

time sudo systemctl start postgresql.service
real    0m4.284s
user    0m0.013s
sys     0m0.031s

time sudo systemctl stop postgresql.service
real    0m1.187s
user    0m0.014s
sys     0m0.032s

time sudo systemctl start postgresql.service
real    0m4.275s
user    0m0.012s
sys     0m0.033s

time sudo systemctl stop postgresql.service
real    0m1.172s
user    0m0.012s
sys     0m0.033s

time sudo systemctl start postgresql.service
real    0m4.309s
user    0m0.012s
sys     0m0.032s

time sudo systemctl stop postgresql.service
real    0m1.195s
user    0m0.010s
sys     0m0.035s


>
>                        regards, tom lane
>
> --
> devel mailing list
> devel at lists.fedoraproject.org
> https://admin.fedoraproject.org/mailman/listinfo/devel
>



-- 
Best regards,
Michal

http://eventhorizon.pl/


More information about the devel mailing list