1 /*! \page tracing Tracing Simulations
4 Tracing is widely used to observe and understand the behavior of
5 parallel applications and distributed algorithms. Usually, this is
6 done in a two-step fashion: the user instruments the application and
7 the traces are analyzed after the end of the execution. The analysis
8 can highlights unexpected behaviors, bottlenecks and sometimes can be
9 used to correct distributed algorithms. The SimGrid team has
10 instrumented the library in order to let users trace their simulations
11 and analyze them. This part of the user manual explains how the
12 tracing-related features can be enabled and used during the
13 development of simulators using the SimGrid library.
15 \section instr_category_functions Tracing categories functions
17 The SimGrid library is instrumented so users can trace the platform
18 utilization using MSG, SimDAG and SMPI interfaces. It registers how
19 much power is used for each host and how much bandwidth is used for
20 each link of the platform. The idea with this type of tracing is to
21 observe the overall view of resources utilization in the first place,
22 especially the identification of bottlenecks, load-balancing among
25 Another possibility is to trace resource utilization by
26 categories. Categorized resource utilization tracing gives SimGrid
27 users to possibility to classify MSG and SimDAG tasks by category,
28 tracing resource utilization for each of the categories. The functions
29 below let the user declare a category and apply it to tasks. <em>The
30 tasks that are not classified according to a category are not
31 traced</em>. Even if the user does not specify any category, the
32 simulations can still be traced in terms of resource utilization by
33 using a special parameter that is detailed below (see section \ref
34 tracing_tracing_options).
36 \li \c TRACE_category(const char *category)
37 \li \c TRACE_category_with_color(const char *category, const char *color)
38 \li \c MSG_task_set_category(msg_task_t task, const char *category)
39 \li \c MSG_task_get_category(msg_task_t task)
40 \li \c SD_task_set_category(SD_task_t task, const char *category)
41 \li \c SD_task_get_category(SD_task_t task)
43 \section instr_mark_functions Tracing marks functions
44 \li \c TRACE_declare_mark(const char *mark_type)
45 \li \c TRACE_mark(const char *mark_type, const char *mark_value)
47 \section instr_uservariables_functions Tracing user variables functions
51 \li \c TRACE_host_variable_declare(const char *variable)
52 \li \c TRACE_host_variable_declare_with_color(const char *variable, const char *color)
53 \li \c TRACE_host_variable_set(const char *host, const char *variable, double value)
54 \li \c TRACE_host_variable_add(const char *host, const char *variable, double value)
55 \li \c TRACE_host_variable_sub(const char *host, const char *variable, double value)
56 \li \c TRACE_host_variable_set_with_time(double time, const char *host, const char *variable, double value)
57 \li \c TRACE_host_variable_add_with_time(double time, const char *host, const char *variable, double value)
58 \li \c TRACE_host_variable_sub_with_time(double time, const char *host, const char *variable, double value)
62 \li \c TRACE_link_variable_declare(const char *variable)
63 \li \c TRACE_link_variable_declare_with_color(const char *variable, const char *color)
64 \li \c TRACE_link_variable_set(const char *link, const char *variable, double value)
65 \li \c TRACE_link_variable_add(const char *link, const char *variable, double value)
66 \li \c TRACE_link_variable_sub(const char *link, const char *variable, double value)
67 \li \c TRACE_link_variable_set_with_time(double time, const char *link, const char *variable, double value)
68 \li \c TRACE_link_variable_add_with_time(double time, const char *link, const char *variable, double value)
69 \li \c TRACE_link_variable_sub_with_time(double time, const char *link, const char *variable, double value)
71 For links, but use source and destination to get route:
73 \li \c TRACE_link_srcdst_variable_set(const char *src, const char *dst, const char *variable, double value)
74 \li \c TRACE_link_srcdst_variable_add(const char *src, const char *dst, const char *variable, double value)
75 \li \c TRACE_link_srcdst_variable_sub(const char *src, const char *dst, const char *variable, double value)
76 \li \c TRACE_link_srcdst_variable_set_with_time(double time, const char *src, const char *dst, const char *variable, double value)
77 \li \c TRACE_link_srcdst_variable_add_with_time(double time, const char *src, const char *dst, const char *variable, double value)
78 \li \c TRACE_link_srcdst_variable_sub_with_time(double time, const char *src, const char *dst, const char *variable, double value)
80 \section tracing_tracing_options Tracing configuration Options
82 To check which tracing options are available for your simulator, you
83 can just run it with the option \verbatim --help-tracing \endverbatim
84 to get a very detailed and updated explanation of each tracing
85 parameter. These are some of the options accepted by the tracing
86 system of SimGrid, you can use them by running your simulator with the
92 Safe switch. It activates (or deactivates) the tracing system.
93 No other tracing options take effect if this one is not activated.
101 It activates the categorized resource utilization tracing. It should
102 be enabled if tracing categories are used by this simulator.
104 --cfg=tracing/categorized:yes
108 tracing/uncategorized
110 It activates the uncategorized resource utilization tracing. Use it if
111 this simulator do not use tracing categories and resource use have to be
114 --cfg=tracing/uncategorized:yes
120 A file with this name will be created to register the simulation. The file
121 is in the Paje format and can be analyzed using Viva or Paje visualization
122 tools. More information can be found in these webpages:
123 <a href="http://github.com/schnorr/viva/">http://github.com/schnorr/viva/</a>
124 <a href="http://github.com/schnorr/pajeng/">http://github.com/schnorr/pajeng/</a>
126 --cfg=tracing/filename:mytracefile.trace
128 If you do not provide this parameter, the trace file will be named simgrid.trace.
133 This option only has effect if this simulator is SMPI-based. Traces the MPI
134 interface and generates a trace that can be analyzed using Gantt-like
135 visualizations. Every MPI function (implemented by SMPI) is transformed in a
136 state, and point-to-point communications can be analyzed with arrows.
138 --cfg=tracing/smpi:yes
144 This option only has effect if this simulator is SMPI-based. The processes
145 are grouped by the hosts where they were executed.
147 --cfg=tracing/smpi/group:yes
151 tracing/smpi/computing
153 This option only has effect if this simulator is SMPI-based. The parts external
154 to SMPI are also outputted to the trace. Provides better way to analyze the data automatically.
156 --cfg=tracing/smpi/computing:yes
160 tracing/smpi/internals
162 This option only has effect if this simulator is SMPI-based. Display internal communications
163 happening during a collective MPI call.
165 --cfg=tracing/smpi/internals:yes
169 tracing/smpi/display-sizes
171 This option only has effect if this simulator is SMPI-based. Display the sizes of the messages
172 exchanged in the trace, both in the links and on the states. For collective, size means the global size of data sent by the process in general.
174 --cfg=tracing/smpi/display-sizes:yes
178 tracing/smpi/sleeping
194 tracing/smpi/format/ti-one-file
212 This option only has effect if this simulator is MSG-based. It traces the
213 behavior of all categorized MSG processes, grouping them by hosts. This option
214 can be used to track process location if this simulator has process migration.
216 --cfg=tracing/msg/process:yes
222 This option put some events in a time-ordered buffer using the
223 insertion sort algorithm. The process of acquiring and releasing
224 locks to access this buffer and the cost of the sorting algorithm
225 make this process slow. The simulator performance can be severely
226 impacted if this option is activated, but you are sure to get a trace
227 file with events sorted.
229 --cfg=tracing/buffer:yes
235 This option changes the way SimGrid register its platform on the trace
236 file. Normally, the tracing considers all routes (no matter their
237 size) on the platform file to re-create the resource topology. If this
238 option is activated, only the routes with one link are used to
239 register the topology within an AS. Routes among AS continue to be
242 --cfg=tracing/onelink-only:yes
254 tracing/disable-power
262 tracing/disable-destroy
264 Disable the destruction of containers at the end of simulation. This
265 can be used with simulators that have a different notion of time
266 (different from the simulated time).
268 --cfg=tracing/disable-destroy:yes
274 Some visualization tools are not able to parse correctly the Paje file format.
275 Use this option if you are using one of these tools to visualize the simulation
276 trace. Keep in mind that the trace might be incomplete, without all the
277 information that would be registered otherwise.
279 --cfg=tracing/basic:yes
285 Use this to add a comment line to the top of the trace file.
287 --cfg=tracing/comment:my_string
293 Use this to add the contents of a file to the top of the trace file as comment.
295 --cfg=tracing/comment-file:textual_file.txt
315 tracing/platform/topology
325 This option generates a graph configuration file for Viva considering
326 categorized resource utilization.
328 --cfg=viva/categorized:graph_categorized.plist
334 This option generates a graph configuration file for Viva considering
335 uncategorized resource utilization.
337 --cfg=viva/uncategorized:graph_uncategorized.plist
340 Please pass \verbatim --help-tracing \endverbatim to your simulator
341 for the updated list of tracing options.
343 \section tracing_tracing_example_parameters Case studies
345 Some scenarios that might help you decide which tracing options
346 you should use to analyze your simulator.
348 \li I want to trace the resource utilization of all hosts
349 and links of the platform, and my simulator <b>does not</b> use
350 the tracing API. For that, you can run a uncategorized trace
351 with the following parameters (it will work with <b>any</b> Simgrid
356 --cfg=tracing/uncategorized:yes \
357 --cfg=tracing/filename:mytracefile.trace \
358 --cfg=viva/uncategorized:uncat.plist
361 \li I want to trace only a subset of my MSG (or SimDAG) tasks.
362 For that, you will need to create tracing categories using the
363 <b>TRACE_category (...)</b> function (as explained above),
364 and then classify your tasks to a previously declared category
365 using the <b>MSG_task_set_category (...)</b>
366 (or <b>SD_task_set_category (...)</b> for SimDAG tasks). After
367 recompiling, run your simulator with the following parameters:
371 --cfg=tracing/categorized:yes \
372 --cfg=tracing/filename:mytracefile.trace \
373 --cfg=viva/categorized:cat.plist
377 \section tracing_tracing_example Example of Instrumentation
379 A simplified example using the tracing mandatory functions.
382 int main (int argc, char **argv)
384 MSG_init (&argc, &argv);
386 //(... after deployment ...)
388 //note that category declaration must be called after MSG_create_environment
389 TRACE_category_with_color ("request", "1 0 0");
390 TRACE_category_with_color ("computation", "0.3 1 0.4");
391 TRACE_category ("finalize");
393 msg_task_t req1 = MSG_task_create("1st_request_task", 10, 10, NULL);
394 msg_task_t req2 = MSG_task_create("2nd_request_task", 10, 10, NULL);
395 msg_task_t req3 = MSG_task_create("3rd_request_task", 10, 10, NULL);
396 msg_task_t req4 = MSG_task_create("4th_request_task", 10, 10, NULL);
397 MSG_task_set_category (req1, "request");
398 MSG_task_set_category (req2, "request");
399 MSG_task_set_category (req3, "request");
400 MSG_task_set_category (req4, "request");
402 msg_task_t comp = MSG_task_create ("comp_task", 100, 100, NULL);
403 MSG_task_set_category (comp, "computation");
405 msg_task_t finalize = MSG_task_create ("finalize", 0, 0, NULL);
406 MSG_task_set_category (finalize, "finalize");
415 \section tracing_tracing_analyzing Analyzing SimGrid Simulation Traces
417 A SimGrid-based simulator, when executed with the correct parameters
418 (see above) creates a trace file in the Paje file format holding the
419 simulated behavior of the application or the platform. You have
420 several options to analyze this trace file:
422 - Dump its contents to a CSV-like format using `pj_dump` (see <a
423 href="https://github.com/schnorr/pajeng/wiki/pj_dump">PajeNG's wiki
424 on pj_dump</a> and more generally the <a
425 href="https://github.com/schnorr/pajeng/">PajeNG suite</a>) and use
426 gnuplot to plot resource usage, time spent on blocking/executing
427 functions, and so on. Filtering capabilities are at your hand by
428 doing `grep`, with the best regular expression you can provide, to
429 get only parts of the trace (for instance, only a subset of
430 resources or processes).
432 - Derive statistics from trace metrics (the ones built-in with any
433 SimGrid simulation, but also those metrics you injected in the trace
434 using the TRACE module) using the <a
435 href="http://www.r-project.org/">R project</a> and all its
436 modules. You can also combine R with <a
437 href="http://ggplot2.org/">ggplot2</a> to get a number of high
438 quality plots from your simulation metrics. You need to `pj_dump`
439 the contents of the SimGrid trace file to use R.
441 - Visualize the behavior of your simulation using classic space/time
442 views (gantt-charts) provided by the <a
443 href="https://github.com/schnorr/pajeng/">PajeNG suite</a> and any
444 other tool that supports the <a
445 href="http://paje.sourceforge.net/download/publication/lang-paje.pdf">Paje
446 file format</a>. Consider this option if you need to understand the
447 causality of your distributed simulation.
449 - Visualize the behavior of your simulation with treemaps (specially
450 if your simulation has a platform with several thousand resources),
451 provided by the <a href="http://github.com/schnorr/viva/">Viva</a>
452 visualization tool. See <a
453 href="https://github.com/schnorr/viva/wiki">Viva's wiki</a> for
454 further details on what is a treemap and how to use it.
456 - Correlate the behavior of your simulator with the platform topology
457 with an interactive, force-directed, and hierarchical graph
458 visualization, provided by <a
459 href="http://github.com/schnorr/viva/">Viva</a>. Check <a
460 href="https://github.com/schnorr/viva/wiki">Viva's wiki</a> for
461 further details. This <a
462 href="http://hal.inria.fr/hal-00738321/">research report</a>,
463 published at ISPASS 2013, has a detailed description of this
464 visualization technique.
466 - You can also check our online <a
467 href="http://simgrid.gforge.inria.fr/tutorials.html"> tutorial
468 section</a> that contains a dedicated tutorial with several
469 suggestions on how to use the tracing infrastructure. Look for the
470 SimGrid User::Visualization 101 tutorial.
472 - Ask for help on the <a
473 href="mailto:simgrid-user@lists.gforge.inria.fr">simgrid-user@lists.gforge.inria.fr</a>
474 mailing list, giving us a detailed explanation on what your
475 simulator does and what kind of information you want to trace. You
476 can also check the <a
477 href="http://lists.gforge.inria.fr/pipermail/simgrid-user/">mailing
478 list archive</a> for old messages regarding tracing and analysis.
480 \subsection tracing_viva_analysis Viva Visualization Tool
482 This subsection describe some of the concepts regarding the <a
483 href="http://github.com/schnorr/viva/">Viva Visualization Tool</a> and
484 its relation with SimGrid traces. You should refer to Viva's website
485 for further details on all its visualization techniques.
487 \subsubsection tracing_viva_time_slice Time Slice
489 The analysis of a trace file using the tool always takes into account
490 the concept of the <em>time-slice</em>. This concept means that what
491 is being visualized in the screen is always calculated considering a
492 specific time frame, with its beggining and end timestamp. The
493 time-slice is configured by the user and can be changed dynamically
494 through the window called <em>Time Interval</em> that is opened
495 whenever a trace file is being analyzed. Users are capable to select
496 the beggining and size of the time slice.
498 \subsubsection tracing_viva_graph Hierarchical Graph View
500 %As stated above (see section \ref tracing_tracing_analyzing), one
501 possibility to analyze SimGrid traces is to use Viva's graph view with
502 a graph configuration to customize the graph according to the
503 traces. A valid graph configuration (we are using the non-XML <a
504 href="http://en.wikipedia.org/wiki/Property_list">Property List
505 Format</a> to describe the configuration) can be created for any
506 SimGrid-based simulator using the
507 <em>--cfg=viva/uncategorized:graph_uncategorized.plist</em> or
508 <em>--cfg=viva/categorized:graph_categorized.plist</em> (if the
509 simulator defines resource utilization categories) when executing the
512 \subsubsection basic_conf Basic Graph Configuration
514 The basic description of the configuration is as follows:
517 node = (LINK, HOST, );
518 edge = (HOST-LINK, LINK-HOST, LINK-LINK, );
521 The nodes of the graph will be created based on the <i>node</i>
522 parameter, which in this case is the different <em>"HOST"</em>s and
523 <em>"LINK"</em>s of the platform used to simulate. The <i>edge</i>
524 parameter indicates that the edges of the graph will be created based
525 on the <em>"HOST-LINK"</em>s, <em>"LINK-HOST"</em>s, and
526 <em>"LINK-LINK"</em>s of the platform. After the definition of these
527 two parameters, the configuration must detail how the nodes
528 (<em>HOST</em>s and <em>LINK</em>s) should be drawn.
530 For that, the configuration must have an entry for each of
531 the types used. For <em>HOST</em>, as basic configuration, we have:
537 values = (power_used);
541 The parameter <em>size</em> indicates which variable from the trace
542 file will be used to define the size of the node HOST in the
543 visualization. If the simulation was executed with availability
544 traces, the size of the nodes will be changed according to these
545 traces. The parameter <em>type</em> indicates which geometrical shape
546 will be used to represent HOST, and the <em>values</em> parameter
547 indicates which values from the trace will be used to fill the shape.
549 For <em>LINK</em> we have:
555 values = (bandwidth_used);
560 The same configuration parameters are used here: <em>type</em> (with a
561 rhombus), the <em>size</em> (whose value is from trace's bandwidth
562 variable) and the <em>values</em>.
564 \subsubsection custom_graph Customizing the Graph Representation
566 Viva is capable to handle a customized graph representation based on
567 the variables present in the trace file. In the case of SimGrid, every
568 time a category is created for tasks, two variables in the trace file
569 are defined: one to indicate node utilization (how much power was used
570 by that task category), and another to indicate link utilization (how
571 much bandwidth was used by that category). For instance, if the user
572 declares a category named <i>request</i>, there will be variables
573 named <b>p</b><i>request</i> and a <b>b</b><i>request</i> (<b>p</b>
574 for power and <b>b</b> for bandwidth). It is important to notice that
575 the variable <i>prequest</i> in this case is only available for HOST,
576 and <i>brequest</i> is only available for LINK. <b>Example</b>:
577 suppose there are two categories for tasks: request and compute. To
578 create a customized graph representation with a proportional
579 separation of host and link utilization, use as configuration for HOST
586 values = (prequest, pcomputation);
591 values = (brequest, bcomputation);
595 This configuration enables the analysis of resource utilization by MSG
596 tasks through the identification of load-balancing issues and network
597 bottlenecks, for instance.