Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
and now kebab-case the tracing options
[simgrid.git] / doc / doxygen / tracing.doc
1 /*! \page tracing Tracing Simulations
2
3
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.
14
15 \section instr_category_functions Tracing categories functions
16
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
23 hosts, and so on.
24
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).
35
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)
42
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)
46
47 \section instr_uservariables_functions Tracing user variables functions
48
49 For hosts:
50
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)
59
60 For links:
61
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)
70
71 For links, but use source and destination to get route:
72
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)
79
80 \section tracing_tracing_options Tracing configuration Options
81
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
87 <b>--cfg=</b> switch:
88
89 \li <b>\c
90 tracing
91 </b>:
92   Safe switch. It activates (or deactivates) the tracing system.
93   No other tracing options take effect if this one is not activated.
94 \verbatim
95 --cfg=tracing:yes
96 \endverbatim
97
98 \li <b>\c
99 tracing/categorized
100 </b>:
101   It activates the categorized resource utilization tracing. It should
102   be enabled if tracing categories are used by this simulator.
103 \verbatim
104 --cfg=tracing/categorized:yes
105 \endverbatim
106
107 \li <b>\c
108 tracing/uncategorized
109 </b>:
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
112   traced.
113 \verbatim
114 --cfg=tracing/uncategorized:yes
115 \endverbatim
116
117 \li <b>\c
118 tracing/filename
119 </b>:
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>
125 \verbatim
126 --cfg=tracing/filename:mytracefile.trace
127 \endverbatim
128   If you do not provide this parameter, the trace file will be named simgrid.trace.
129
130 \li <b>\c
131 tracing/smpi
132 </b>:
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.
137 \verbatim
138 --cfg=tracing/smpi:yes
139 \endverbatim
140
141 \li <b>\c
142 tracing/smpi/group
143 </b>:
144   This option only has effect if this simulator is SMPI-based. The processes
145   are grouped by the hosts where they were executed.
146 \verbatim
147 --cfg=tracing/smpi/group:yes
148 \endverbatim
149
150 \li <b>\c
151 tracing/smpi/computing
152 </b>:
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.
155 \verbatim
156 --cfg=tracing/smpi/computing:yes
157 \endverbatim
158
159 \li <b>\c
160 tracing/smpi/internals
161 </b>:
162   This option only has effect if this simulator is SMPI-based. Display internal communications
163 happening during a collective MPI call.
164 \verbatim
165 --cfg=tracing/smpi/internals:yes
166 \endverbatim
167
168 \li <b>\c
169 tracing/smpi/display-sizes
170 </b>:
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.
173 \verbatim
174 --cfg=tracing/smpi/display-sizes:yes
175 \endverbatim
176
177 \li <b>\c
178 tracing/smpi/sleeping
179 </b>:
180 TODO
181 \verbatim
182 TODO
183 \endverbatim
184
185 \li <b>\c
186 tracing/smpi/format
187 </b>:
188 TODO
189 \verbatim
190 TODO
191 \endverbatim
192
193 \li <b>\c
194 tracing/smpi/format/ti-one-file
195 </b>:
196 TODO
197 \verbatim
198 TODO
199 \endverbatim
200
201 \li <b>\c
202 tracing/msg/vm
203 </b>:
204 TODO
205 \verbatim
206 TODO
207 \endverbatim
208
209 \li <b>\c
210 tracing/msg/process
211 </b>:
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.
215 \verbatim
216 --cfg=tracing/msg/process:yes
217 \endverbatim
218
219 \li <b>\c
220 tracing/buffer
221 </b>:
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.
228 \verbatim
229 --cfg=tracing/buffer:yes
230 \endverbatim
231
232 \li <b>\c
233 tracing/onelink-only
234 </b>:
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
240 traced as usual.
241 \verbatim
242 --cfg=tracing/onelink-only:yes
243 \endverbatim
244
245 \li <b>\c
246 tracing/disable-link
247 </b>:
248 TODO
249 \verbatim
250 TODO
251 \endverbatim
252
253 \li <b>\c
254 tracing/disable-power
255 </b>:
256 TODO
257 \verbatim
258 TODO
259 \endverbatim
260
261 \li <b>\c
262 tracing/disable-destroy
263 </b>:
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).
267 \verbatim
268 --cfg=tracing/disable-destroy:yes
269 \endverbatim
270
271 \li <b>\c
272 tracing/basic
273 </b>:
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.
278 \verbatim
279 --cfg=tracing/basic:yes
280 \endverbatim
281
282 \li <b>\c
283 tracing/comment
284 </b>:
285 Use this to add a comment line to the top of the trace file.
286 \verbatim
287 --cfg=tracing/comment:my_string
288 \endverbatim
289
290 \li <b>\c
291 tracing/comment-file
292 </b>:
293 Use this to add the contents of a file to the top of the trace file as comment.
294 \verbatim
295 --cfg=tracing/comment-file:textual_file.txt
296 \endverbatim
297
298 \li <b>\c
299 tracing/precision
300 </b>:
301 TODO
302 \verbatim
303 TODO
304 \endverbatim
305
306 \li <b>\c
307 tracing/platform
308 </b>:
309 TODO
310 \verbatim
311 TODO
312 \endverbatim
313
314 \li <b>\c
315 tracing/platform/topology
316 </b>:
317 TODO
318 \verbatim
319 TODO
320 \endverbatim
321
322 \li <b>\c
323 viva/categorized
324 </b>:
325   This option generates a graph configuration file for Viva considering
326   categorized resource utilization.
327 \verbatim
328 --cfg=viva/categorized:graph_categorized.plist
329 \endverbatim
330
331 \li <b>\c
332 viva/uncategorized
333 </b>:
334   This option generates a graph configuration file for Viva considering
335   uncategorized resource utilization.
336 \verbatim
337 --cfg=viva/uncategorized:graph_uncategorized.plist
338 \endverbatim
339
340 Please pass \verbatim --help-tracing \endverbatim to your simulator
341 for the updated list of tracing options.
342
343 \section tracing_tracing_example_parameters Case studies
344
345 Some scenarios that might help you decide which tracing options
346 you should use to analyze your simulator.
347
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
352 simulator):
353 \verbatim
354 ./your_simulator \
355           --cfg=tracing:yes \
356           --cfg=tracing/uncategorized:yes \
357           --cfg=tracing/filename:mytracefile.trace \
358           --cfg=viva/uncategorized:uncat.plist
359 \endverbatim
360
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:
368 \verbatim
369 ./your_simulator \
370           --cfg=tracing:yes \
371           --cfg=tracing/categorized:yes \
372           --cfg=tracing/filename:mytracefile.trace \
373           --cfg=viva/categorized:cat.plist
374 \endverbatim
375
376
377 \section tracing_tracing_example Example of Instrumentation
378
379 A simplified example using the tracing mandatory functions.
380
381 \verbatim
382 int main (int argc, char **argv)
383 {
384   MSG_init (&argc, &argv);
385
386   //(... after deployment ...)
387
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");
392
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");
401
402   msg_task_t comp = MSG_task_create ("comp_task", 100, 100, NULL);
403   MSG_task_set_category (comp, "computation");
404
405   msg_task_t finalize = MSG_task_create ("finalize", 0, 0, NULL);
406   MSG_task_set_category (finalize, "finalize");
407
408   //(...)
409
410   MSG_clean();
411   return 0;
412 }
413 \endverbatim
414
415 \section tracing_tracing_analyzing Analyzing SimGrid Simulation Traces
416
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:
421
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).
431
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.
440
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.
448
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.
455
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.
465
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.
471
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.
479
480 \subsection tracing_viva_analysis Viva Visualization Tool
481
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.
486
487 \subsubsection tracing_viva_time_slice Time Slice
488
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.
497
498 \subsubsection tracing_viva_graph Hierarchical Graph View
499
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
510 simulation.
511
512 \subsubsection basic_conf Basic Graph Configuration
513
514 The basic description of the configuration is as follows:
515 \verbatim
516 {
517   node = (LINK, HOST, );
518   edge = (HOST-LINK, LINK-HOST, LINK-LINK, );
519 \endverbatim
520
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.
529
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:
532
533 \verbatim
534   HOST = {
535     type = square;
536     size = power;
537     values = (power_used);
538   };
539 \endverbatim
540
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.
548
549 For <em>LINK</em> we have:
550
551 \verbatim
552   LINK = {
553     type = rhombus;
554     size = bandwidth;
555     values = (bandwidth_used);
556   };
557 }
558 \endverbatim
559
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>.
563
564 \subsubsection custom_graph Customizing the Graph Representation
565
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
580 and LINK this:
581
582 \verbatim
583   HOST = {
584     type = square;
585     size = power;
586     values = (prequest, pcomputation);
587   };
588   LINK = {
589     type = rhombus;
590     size = bandwidth;
591     values = (brequest, bcomputation);
592   };
593 \endverbatim
594
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.
598
599 */