-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
parse the timing info from dmesg to give uses a rough accounting of time spent during boot. this may fail to be accurate if run a long time from boot (i.e. if the messages have left the kernel message ring buffer)
- Loading branch information
1 parent
7f44b79
commit 3263928
Showing
3 changed files
with
107 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#!/bin/sh | ||
# vim: set ts=4 sw=4 et ft=awk: | ||
|
||
if [ -n "$1" ]; then | ||
printf "Usage: runit-startuptime\n\nPrint a rough accounting of where time is spent during boot\n" >&2 | ||
exit 1 | ||
fi | ||
|
||
dmesg -l debug | LANG=C.UTF-8 awk -F '[][ :]+' ' | ||
BEGIN { | ||
PROCINFO["sorted_in"] = "@ind_str_asc" | ||
initramfs = 0 | ||
coresvtotal = 0 | ||
rclocal = 0 | ||
total = 0 | ||
} | ||
|
||
function svbasename(file) { | ||
sub(".*/", "", file) | ||
sub(".sh$", "", file) | ||
return file | ||
} | ||
|
||
$3 == "/init" { | ||
initramfs = $2 | ||
next | ||
} | ||
|
||
$3 == "runit" { | ||
if ($5 == "core") { | ||
sv = svbasename($6) | ||
if ($4 == "start") { | ||
coresv[sv] = $2 | ||
if (coresvtotal == 0) | ||
coresvtotal = $2 | ||
} else if ($4 == "finish") { | ||
if ($6 != "") { | ||
if (sv in coresv) | ||
coresv[sv] = $2 - coresv[sv] | ||
else | ||
# /dev is not guaranteed until 00-pseudofs | ||
# so the first start message may not exist | ||
coresv[sv] = $2 - initramfs | ||
} else | ||
coresvtotal = $2 - coresvtotal | ||
} | ||
} else if ($5 == "rclocal") { | ||
if ($4 == "start") | ||
rclocal = $2 | ||
else if ($4 == "finish") | ||
rclocal = $2 - rclocal | ||
} else if ($5 == "runsvdir") | ||
total = $2 | ||
next | ||
} | ||
|
||
END { | ||
if (NR > 2) { | ||
printf "initramfs\t%0.3f s\n", initramfs | ||
printf "core-services\t%0.3f s\n", coresvtotal | ||
for (sv in coresv) | ||
printf " %-20s\t%0.3f s\n", sv, coresv[sv] | ||
printf "rc.local\t%0.3f s\n", rclocal | ||
printf "total\t\t%0.3f s\n", total | ||
} | ||
}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
.Dd September 4, 2024 | ||
.Dt RUNIT-STARTUPTIME 1 | ||
.Os | ||
.Sh NAME | ||
.Nm runit-startuptime | ||
.Nd Print a rough accounting of where time is spent during boot | ||
.Sh SYNOPSIS | ||
.Nm runit-startuptime | ||
.Sh DESCRIPTION | ||
Void's runit init scripts print messages to the kernel message buffer at startup, | ||
marking when some procedures start and finish. | ||
.Nm | ||
prints a rough accounting of where time is spent during boot using these messages. | ||
.Nm | ||
may require superuser privileges to read from dmesg. | ||
.Sh EXAMPLES | ||
.Bd -literal | ||
# runit-startuptime | ||
initramfs 0.646 s | ||
core-services 4.002 s | ||
00-pseudofs 0.056 s | ||
01-static-devnodes 1.178 s | ||
02-kmods 0.027 s | ||
02-udev 2.413 s | ||
03-console-setup 0.096 s | ||
03-filesystems 0.202 s | ||
04-swap 0.004 s | ||
05-misc 0.015 s | ||
08-sysctl 0.008 s | ||
20-screen 0.001 s | ||
98-sbin-merge 0.000 s | ||
99-cleanup 0.001 s | ||
rc.local 0.002 s | ||
total 7.952 s | ||
.Ed | ||
.Sh SEE ALSO | ||
.Xr runit-init 8 | ||
.Sh AUTHOR | ||
.An classabbyamp , | ||
.Mt [email protected] . |