chiark / gitweb /
analyze: show unit file loading on plot
authorThomas Hindoe Paaboel Andersen <phomes@gmail.com>
Wed, 15 May 2013 19:18:26 +0000 (21:18 +0200)
committerThomas Hindoe Paaboel Andersen <phomes@gmail.com>
Sun, 2 Jun 2013 20:26:13 +0000 (22:26 +0200)
This will add another color to the legend called "Loading unit files"
Like the generators it will mark a part of the systemd bar indicating
the time spent while loading unit files.

src/analyze/systemd-analyze.c
src/core/dbus-manager.c
src/core/manager.c
src/core/manager.h

index df3d3072403e1c21f9296b5ffbd081d5db48fac6..6d97256c73977c4ab9e328b440f8c3f1ae8c9670 100644 (file)
@@ -80,6 +80,8 @@ struct boot_times {
         usec_t finish_time;
         usec_t generators_start_time;
         usec_t generators_finish_time;
+        usec_t unitsload_start_time;
+        usec_t unitsload_finish_time;
 };
 struct unit_times {
         char *name;
@@ -315,7 +317,17 @@ static int acquire_boot_times(DBusConnection *bus, struct boot_times **bt) {
                                     "/org/freedesktop/systemd1",
                                     "org.freedesktop.systemd1.Manager",
                                     "GeneratorsFinishTimestampMonotonic",
-                                    &times.generators_finish_time) < 0)
+                                    &times.generators_finish_time) < 0 ||
+            bus_get_uint64_property(bus,
+                                    "/org/freedesktop/systemd1",
+                                    "org.freedesktop.systemd1.Manager",
+                                    "UnitsLoadStartTimestampMonotonic",
+                                    &times.unitsload_start_time) < 0 ||
+            bus_get_uint64_property(bus,
+                                    "/org/freedesktop/systemd1",
+                                    "org.freedesktop.systemd1.Manager",
+                                    "UnitsLoadFinishTimestampMonotonic",
+                                    &times.unitsload_finish_time) < 0)
                 return -EIO;
 
         if (times.finish_time <= 0) {
@@ -472,7 +484,7 @@ static int analyze_plot(DBusConnection *bus) {
         svg("<svg width=\"%.0fpx\" height=\"%.0fpx\" version=\"1.1\" "
             "xmlns=\"http://www.w3.org/2000/svg\">\n\n",
                         80.0 + width, 150.0 + (m * SCALE_Y) +
-                        4 * SCALE_Y /* legend */);
+                        5 * SCALE_Y /* legend */);
 
         /* write some basic info as a comment, including some help */
         svg("<!-- This file is a systemd-analyze SVG file. It is best rendered in a   -->\n"
@@ -494,6 +506,7 @@ static int analyze_plot(DBusConnection *bus) {
             "      rect.loader       { fill: rgb(150,150,150); fill-opacity: 0.7; }\n"
             "      rect.userspace    { fill: rgb(150,150,150); fill-opacity: 0.7; }\n"
             "      rect.generators   { fill: rgb(102,204,255); fill-opacity: 0.7; }\n"
+            "      rect.unitsload    { fill: rgb( 82,184,255); fill-opacity: 0.7; }\n"
             "      rect.box   { fill: rgb(240,240,240); stroke: rgb(192,192,192); }\n"
             "      line       { stroke: rgb(64,64,64); stroke-width: 1; }\n"
             "//    line.sec1  { }\n"
@@ -535,6 +548,7 @@ static int analyze_plot(DBusConnection *bus) {
         }
         svg_bar("active", boot->userspace_time, boot->finish_time, y);
         svg_bar("generators", boot->generators_start_time, boot->generators_finish_time, y);
+        svg_bar("unitsload", boot->unitsload_start_time, boot->unitsload_finish_time, y);
         svg_text("left", boot->userspace_time, y, "systemd");
         y++;
 
@@ -572,6 +586,9 @@ static int analyze_plot(DBusConnection *bus) {
         svg_bar("generators", 0, 300000, y);
         svg_text("right", 400000, y, "Generators");
         y++;
+        svg_bar("unitsload", 0, 300000, y);
+        svg_text("right", 400000, y, "Loading unit files");
+        y++;
 
 
         svg("</g>\n\n");
index 988c06aa44db3f1204c7ddc20504c579d58295a3..25d38cc491e5b7d4cc038f829a6947172ea3da47 100644 (file)
         "  <property name=\"GeneratorsStartTimestampMonotonic\" type=\"t\" access=\"read\"/>\n" \
         "  <property name=\"GeneratorsFinishTimestamp\" type=\"t\" access=\"read\"/>\n" \
         "  <property name=\"GeneratorsFinishTimestampMonotonic\" type=\"t\" access=\"read\"/>\n" \
+        "  <property name=\"UnitsLoadStartTimestamp\" type=\"t\" access=\"read\"/>\n" \
+        "  <property name=\"UnitsLoadStartTimestampMonotonic\" type=\"t\" access=\"read\"/>\n" \
+        "  <property name=\"UnitsLoadFinishTimestamp\" type=\"t\" access=\"read\"/>\n" \
+        "  <property name=\"UnitsLoadFinishTimestampMonotonic\" type=\"t\" access=\"read\"/>\n" \
         "  <property name=\"LogLevel\" type=\"s\" access=\"readwrite\"/>\n"  \
         "  <property name=\"LogTarget\" type=\"s\" access=\"readwrite\"/>\n" \
         "  <property name=\"NNames\" type=\"u\" access=\"read\"/>\n"    \
@@ -595,6 +599,10 @@ static const BusProperty bus_manager_properties[] = {
         { "GeneratorsStartTimestampMonotonic",  bus_property_append_uint64,     "t",  offsetof(Manager, generators_start_timestamp.monotonic)  },
         { "GeneratorsFinishTimestamp",          bus_property_append_uint64,     "t",  offsetof(Manager, generators_finish_timestamp.realtime)  },
         { "GeneratorsFinishTimestampMonotonic", bus_property_append_uint64,     "t",  offsetof(Manager, generators_finish_timestamp.monotonic) },
+        { "UnitsLoadStartTimestamp",            bus_property_append_uint64,     "t",  offsetof(Manager, unitsload_start_timestamp.realtime)    },
+        { "UnitsLoadStartTimestampMonotonic",   bus_property_append_uint64,     "t",  offsetof(Manager, unitsload_start_timestamp.monotonic)   },
+        { "UnitsLoadFinishTimestamp",           bus_property_append_uint64,     "t",  offsetof(Manager, unitsload_finish_timestamp.realtime)   },
+        { "UnitsLoadFinishTimestampMonotonic",  bus_property_append_uint64,     "t",  offsetof(Manager, unitsload_finish_timestamp.monotonic)  },
         { "LogLevel",                    bus_manager_append_log_level,   "s",  0,                                               false, bus_manager_set_log_level },
         { "LogTarget",                   bus_manager_append_log_target,  "s",  0,                                               false, bus_manager_set_log_target },
         { "NNames",                      bus_manager_append_n_names,     "u",  0                                                },
index 73f4c102e8583ffb9a4ddb01cce6a1a24d974138..f16621ac2bbe38837b41eb64f05f9321124edb50 100644 (file)
@@ -847,7 +847,9 @@ int manager_startup(Manager *m, FILE *serialization, FDSet *fds) {
                 m->n_reloading ++;
 
         /* First, enumerate what we can from all config files */
+        dual_timestamp_get(&m->unitsload_start_timestamp);
         r = manager_enumerate(m);
+        dual_timestamp_get(&m->unitsload_finish_timestamp);
 
         /* Second, deserialize if there is something to deserialize */
         if (serialization) {
index 5d777e6ed39a25703eaaf41b35b6cb1533f978b0..dcc4ebed923ea60b585efe9d299eceb1daba8320 100644 (file)
@@ -152,6 +152,8 @@ struct Manager {
         dual_timestamp finish_timestamp;
         dual_timestamp generators_start_timestamp;
         dual_timestamp generators_finish_timestamp;
+        dual_timestamp unitsload_start_timestamp;
+        dual_timestamp unitsload_finish_timestamp;
 
         char *generator_unit_path;
         char *generator_unit_path_early;