Skip to content

Commit 13b780f

Browse files
committed
Add rc-analyze
Adds a commandline utility to view various runtime statistics using the event log Closes: #997
1 parent 94593b0 commit 13b780f

6 files changed

Lines changed: 749 additions & 1 deletion

File tree

man/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ man3 = [
1212
man8 = [
1313
'openrc.8',
1414
'openrc-run.8',
15+
'rc-analyze.8',
1516
'rc-service.8',
1617
'rc-status.8',
1718
'rc-update.8',

man/rc-analyze.8

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
.\" Copyright (c) 2026 The OpenRC Authors.
2+
.\" See the Authors file at the top-level directory of this distribution and
3+
.\" https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS
4+
.\"
5+
.\" This file is part of OpenRC. It is subject to the license terms in
6+
.\" the LICENSE file found in the top-level directory of this
7+
.\" distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE
8+
.\" This file may not be copied, modified, propagated, or distributed
9+
.\" except according to the terms contained in the LICENSE file.
10+
.\"
11+
.Dd April 2, 2026
12+
.Dt RC-ANALYZE 8 SMM
13+
.Os OpenRC
14+
.Sh NAME
15+
.Nm rc-analyze
16+
.Nd analyze OpenRC startup performance
17+
.Sh SYNOPSIS
18+
.Nm
19+
.Ar blame | critical-chain | time
20+
.Sh DESCRIPTION
21+
The
22+
.Nm
23+
utility provides commands to analyze the boot performance of an OpenRC-based
24+
system.
25+
.Sh COMMANDS
26+
The following commands are available:
27+
.Bl -tag -width ".Fl critical-chain"
28+
.It Nm blame
29+
Prints a list of all services that were started, sorted by the time they took
30+
to start up (longest first). This helps identify the slowest services during
31+
boot.
32+
.It Nm critical-chain
33+
.Op Ar service
34+
Shows the chain of dependencies that led to the specified
35+
.Ar service
36+
starting. If no service is specified, it shows the chain for the last service
37+
to start in the default runlevel. The output is a tree where each dependency
38+
is a parent of the service that depends on it. The time at which each service
39+
became active and the time it took to start are printed.
40+
.It Nm time
41+
Prints a summary of the time spent getting to the default runlevel.
42+
.El
43+
.Sh SEE ALSO
44+
.Xr openrc 8 ,
45+
.Sh AUTHORS
46+
.An The OpenRC Authors <openrc@lists.gentoo.org>

src/librc/rc-eventlog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ static const char *rc_service_state_name(RC_SERVICE state)
5252
*/
5353
static char *format_timestamp(void)
5454
{
55-
time_t now;
55+
struct timespec ts;
5656
struct tm *tm;
5757
char timebuf[32];
5858
char *result;

src/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ subdir('openrc-user')
2222
subdir('pam_openrc')
2323
subdir('poweroff')
2424
subdir('rc-abort')
25+
subdir('rc-analyze')
2526
subdir('rc-depend')
2627
subdir('rc-service')
2728
subdir('rc-sstat')

src/rc-analyze/meson.build

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
libm = cc.find_library('m', required: true)
2+
3+
executable('rc-analyze', 'rc-analyze.c',
4+
dependencies: [rc, einfo, shared, libm],
5+
include_directories: incdir,
6+
install: true,
7+
install_dir: bindir)

0 commit comments

Comments
 (0)