core: add ExecMainHandoverTimestamp property recording time-of-execve

Enable the exec_fd logic for Type=notify* services too, and change it
to send a timestamp instead of a '1' byte. Record the timestamp in a
new ExecMainHandoverTimestamp property so that users can track accurately
when control is handed over from systemd to the service payload, so
that latency and startup performance can be trivially and accurately
tracked and attributed.
This commit is contained in:
Luca Boccassi
2024-04-22 15:16:05 +02:00
committed by Zbigniew Jędrzejewski-Szmek
parent 489ae6b3d5
commit 93cb78aee2
7 changed files with 100 additions and 29 deletions
+17
View File
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -eux
set -o pipefail
# Check that timestamps of a Type=notify service are consistent
systemd-run --service-type notify --property NotifyAccess=all --unit notify.service --wait sh -c 'systemd-notify --ready; exit 1' || :
start=$(systemctl show --property=ExecMainStartTimestampMonotonic --value notify.service)
handover=$(systemctl show --property=ExecMainHandoverTimestampMonotonic --value notify.service)
active=$(systemctl show --property=ActiveEnterTimestampMonotonic --value notify.service)
exit=$(systemctl show --property=ExecMainExitTimestampMonotonic --value notify.service)
[[ $start -le $handover ]]
[[ $handover -le $active ]]
[[ $active -le $exit ]]