[systemd-devel] [PATCH 1/2] analyze: show generators on plot

Umut Tezduyar umut at tezduyar.com
Tue May 14 00:56:02 PDT 2013


Hi,

Attached is a screen shot of the new legend area. It is placed on exactly
where the previous text based legend was.


On Tue, May 14, 2013 at 8:52 AM, Thomas H.P. Andersen <phomes at gmail.com>wrote:

> On Wed, May 8, 2013 at 6:03 PM, Umut Tezduyar <umut at tezduyar.com> wrote:
> > ---
> >  src/analyze/systemd-analyze.c |   42 ++++++++++++++++++++++++++++----
> >  src/core/dbus-manager.c       |    8 ++++++
> >  src/core/manager.c            |    2 +
> >  src/core/manager.h            |    2 +
> >  4 files changed, 48 insertions(+), 6 deletions(-)
> >
> > diff --git a/src/analyze/systemd-analyze.c
> b/src/analyze/systemd-analyze.c
> > index bb86ec7..df3d307 100644
> > --- a/src/analyze/systemd-analyze.c
> > +++ b/src/analyze/systemd-analyze.c
> > @@ -78,6 +78,8 @@ struct boot_times {
> >          usec_t initrd_time;
> >          usec_t userspace_time;
> >          usec_t finish_time;
> > +        usec_t generators_start_time;
> > +        usec_t generators_finish_time;
> >  };
> >  struct unit_times {
> >          char *name;
> > @@ -303,7 +305,17 @@ static int acquire_boot_times(DBusConnection *bus,
> struct boot_times **bt) {
> >                                      "/org/freedesktop/systemd1",
> >                                      "org.freedesktop.systemd1.Manager",
> >                                      "FinishTimestampMonotonic",
> > -                                    &times.finish_time) < 0)
> > +                                    &times.finish_time) < 0 ||
> > +            bus_get_uint64_property(bus,
> > +                                    "/org/freedesktop/systemd1",
> > +                                    "org.freedesktop.systemd1.Manager",
> > +                                    "GeneratorsStartTimestampMonotonic",
> > +                                    &times.generators_start_time) < 0 ||
> > +            bus_get_uint64_property(bus,
> > +                                    "/org/freedesktop/systemd1",
> > +                                    "org.freedesktop.systemd1.Manager",
> > +
>  "GeneratorsFinishTimestampMonotonic",
> > +                                    &times.generators_finish_time) < 0)
> >                  return -EIO;
> >
> >          if (times.finish_time <= 0) {
> > @@ -459,7 +471,8 @@ 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));
> > +                        80.0 + width, 150.0 + (m * SCALE_Y) +
> > +                        4 * 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"
> > @@ -480,6 +493,7 @@ static int analyze_plot(DBusConnection *bus) {
> >              "      rect.firmware     { fill: rgb(150,150,150);
> fill-opacity: 0.7; }\n"
> >              "      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.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"
> > @@ -495,8 +509,6 @@ static int analyze_plot(DBusConnection *bus) {
> >          svg("<text x=\"20\" y=\"30\">%s %s (%s %s) %s</text>",
> >              isempty(osname) ? "Linux" : osname,
> >              name.nodename, name.release, name.version, name.machine);
> > -        svg("<text x=\"20\" y=\"%.0f\">Legend: Red = Activating; Pink =
> Active; Dark Pink = Deactivating</text>",
> > -                        120.0 + (m *SCALE_Y));
> >
> >          svg("<g transform=\"translate(%.3f,100)\">\n", 20.0 + (SCALE_X
> * boot->firmware_time));
> >          svg_graph_box(m, -boot->firmware_time, boot->finish_time);
> > @@ -521,8 +533,9 @@ static int analyze_plot(DBusConnection *bus) {
> >                  svg_text(true, boot->initrd_time, y, "initrd");
> >                  y++;
> >          }
> > -        svg_bar("userspace", boot->userspace_time, boot->finish_time,
> y);
> > -        svg_text("left", boot->userspace_time, y, "userspace");
> > +        svg_bar("active", boot->userspace_time, boot->finish_time, y);
> > +        svg_bar("generators", boot->generators_start_time,
> boot->generators_finish_time, y);
> > +        svg_text("left", boot->userspace_time, y, "systemd");
> >          y++;
> >
> >          for (u = times; u < times + n; u++) {
> > @@ -544,6 +557,23 @@ static int analyze_plot(DBusConnection *bus) {
> >                          svg_text(b, u->ixt, y, "%s", u->name);
> >                  y++;
> >          }
> > +
> > +        /* Legend */
> > +        y++;
> > +        svg_bar("activating", 0, 300000, y);
> > +        svg_text("right", 400000, y, "Activating");
> > +        y++;
> > +        svg_bar("active", 0, 300000, y);
> > +        svg_text("right", 400000, y, "Active");
> > +        y++;
> > +        svg_bar("deactivating", 0, 300000, y);
> > +        svg_text("right", 400000, y, "Deactivating");
> > +        y++;
> > +        svg_bar("generators", 0, 300000, y);
> > +        svg_text("right", 400000, y, "Generators");
> > +        y++;
> > +
> > +
> It would be nice to see a full screenshot that includes the new legend
> area.
>
> >          svg("</g>\n\n");
> >
> >          svg("</svg>");
> > diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c
> > index 56b02a1..c932437 100644
> > --- a/src/core/dbus-manager.c
> > +++ b/src/core/dbus-manager.c
> > @@ -275,6 +275,10 @@
> >          "  <property name=\"UserspaceTimestampMonotonic\" type=\"t\"
> access=\"read\"/>\n" \
> >          "  <property name=\"FinishTimestamp\" type=\"t\"
> access=\"read\"/>\n" \
> >          "  <property name=\"FinishTimestampMonotonic\" type=\"t\"
> access=\"read\"/>\n" \
> > +        "  <property name=\"GeneratorsStartTimestamp\" type=\"t\"
> access=\"read\"/>\n" \
> > +        "  <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=\"LogLevel\" type=\"s\"
> access=\"readwrite\"/>\n"  \
> >          "  <property name=\"LogTarget\" type=\"s\"
> access=\"readwrite\"/>\n" \
> >          "  <property name=\"NNames\" type=\"u\" access=\"read\"/>\n"
>  \
> > @@ -580,6 +584,10 @@ static const BusProperty bus_manager_properties[] =
> {
> >          { "UserspaceTimestampMonotonic", bus_property_append_uint64,
>   "t",  offsetof(Manager, userspace_timestamp.monotonic) },
> >          { "FinishTimestamp",             bus_property_append_uint64,
>   "t",  offsetof(Manager, finish_timestamp.realtime)     },
> >          { "FinishTimestampMonotonic",    bus_property_append_uint64,
>   "t",  offsetof(Manager, finish_timestamp.monotonic)    },
> > +        { "GeneratorsStartTimestamp",
> bus_property_append_uint64,     "t",  offsetof(Manager,
> generators_start_timestamp.realtime)   },
> > +        { "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) },
> >          { "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                                                },
> > diff --git a/src/core/manager.c b/src/core/manager.c
> > index c7f8f20..7b7ace6 100644
> > --- a/src/core/manager.c
> > +++ b/src/core/manager.c
> > @@ -2525,7 +2525,9 @@ void manager_run_generators(Manager *m) {
> >          argv[4] = NULL;
> >
> >          RUN_WITH_UMASK(0022) {
> > +                dual_timestamp_get(&m->generators_start_timestamp);
> >                  execute_directory(generator_path, d, (char**) argv);
> > +                dual_timestamp_get(&m->generators_finish_timestamp);
> >          }
> The timestamps can be overwritten later as this is also called from
> manager_reload. You cancheck with dual_timestamp_is_set to avoid that.
>
> Or simply move the timestamps out into manager_startup. This will make
> them also include the create/trim of the generator directories. This
> might make sense if we are trying to find the total time cost of the
> generators.
>
Umut: I think it makes more sense to save the time before and after
manager_run_generators in manager_startup.

> [image: Inline image 1]
> >          trim_generator_dir(m, &m->generator_unit_path);
> > diff --git a/src/core/manager.h b/src/core/manager.h
> > index bf83354..5d777e6 100644
> > --- a/src/core/manager.h
> > +++ b/src/core/manager.h
> > @@ -150,6 +150,8 @@ struct Manager {
> >          dual_timestamp initrd_timestamp;
> >          dual_timestamp userspace_timestamp;
> >          dual_timestamp finish_timestamp;
> > +        dual_timestamp generators_start_timestamp;
> > +        dual_timestamp generators_finish_timestamp;
> >
> >          char *generator_unit_path;
> >          char *generator_unit_path_early;
> > --
> > 1.7.2.5
> >
> > _______________________________________________
> > systemd-devel mailing list
> > systemd-devel at lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/systemd-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20130514/a9930fb8/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 3267 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20130514/a9930fb8/attachment-0001.png>


More information about the systemd-devel mailing list