| The Gaudi Framework v29r0 (ff2e7097)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

GaudiProfiling/doc/jemallocprofiler.md
Go to the documentation of this file.
1 Profiling Gaudi jobs with Jemalloc {#profiling-jemalloc}
2 ===============================================================================
3
4 Integration of Jemalloc within Gaudi jobs.
5 Uses the Jemalloc library from http://www.canonware.com/jemalloc/
6
7 It is possible to profile the memory used by Gaudi jobs, using the jemalloc library
8 as documented in https://github.com/jemalloc/jemalloc/wiki
9
10 To run the profiler, it is necessary to:
11 * preload libjemalloc.so, using the LD_PRELOAD environment variable
12 * set the MALLOC_CONF environment variable to enable profiling
13
14 gaudirun.py has been updated to set the environment accordingly (a prerequisite is however
15 that libjemalloc.so has to be available in the library path).
16
17 A Gaudi algorithm has also been developed to perform memory heap dumps at various event,
18 and is configured using the StartFromEventN, StopAtEventN and DumpPeriod, as described
19 in the example below.
20
21 A Gaudi service is also available to provide the same functionality, with the advantage
22 of being able to profile without modifying the algorithm sequence.
23
24 Running with the JemallocProfile algorithm
25 --------------------------------------------------------------------------------
26
27 ### Change Options File
28
29 Simple example of using the JemallocProfile algorithm in a Gaudi configurable:
30
31 ~~~~~~~~{.py}
32 #!/usr/bin/env gaudirun.py
33 from Configurables import JemallocProfile
34 #...
35 jp = JemallocProfile()
36 jp.StartFromEventN = 49
37 jp.StopAtEventN = 99
38 jp.DumpPeriod = 10
39
40 GaudiSequencer("PhysicsSeq").Members += [ jp ]
41 ~~~~~~~~
42
43 ### Run the job
44
45 ~~~~~~~~{.sh}
46 $> gaudirun.py --profilerName=jemalloc --run-info-file=runinfo.json myoptions.py
47 ~~~~~~~~
48
49 Please note the the `--profilerName=jemalloc` to enbale the profiling, and the `--run-info-file` that produces
50 a file containing information useful to interpret the results (process id of the Gaudi job, and the absolute path
51 of the executable, necessary to run the jeprof analysis tool).
52
53 Running with the JemallocProfileSvc service
54 --------------------------------------------------------------------------------
55
56 ### Change Options File
57
58 Simple example of using the JemallocProfileSvc service in a Gaudi configurable:
59
60 ~~~~~~~{.py}
61 #!/usr/bin/env gaudirun.py
62 from Configurables import JemallocProfileSvc
63 from Gaudi.Configuration import DEBUG
64 #...
65 jps = JemallocProfileSvc(StartFromEventN=3,
66 StopAtEventN=7,
67 OutputLevel=DEBUG)
68 ApplicationMgr().ExtSvc.append(jps)
69 ~~~~~~~
70
71 It is also possible to trigger the profiling using incidents:
72
73 ~~~~~~~{.py}
74 from Configurables import JemallocProfileSvc
75 jps = JemallocProfileSvc(StartFromIncidents=['MyStartIncident1',
76 'MyStartIncident2'],
77 StopAtIncidents=['MyStopIncident'])
78 ApplicationMgr().ExtSvc.append(jps)
79 ~~~~~~~
80
81 ### Run the job
82 This is identical as for the algorithm version.
83
84
85 Analyze
86 --------------------------------------------------------------------------------
87 ### With text output
88
89 The jeprof analysis tool from the Google performances tools (http://goog-perftools.sourceforge.net/)
90 is necessary to analyze the heap files.
91
92 It can be used to compare the memory in two heap files in the following way:
93
94 ~~~~~~~~{.sh}
95 $> jeprof -text --base=<firstheap>.heap <executable name> <comparewith>.heap
96 ~~~~~~~~
97
98 ### To produce a postscript file
99
100 ~~~~~~~~{.sh}
101 $> jeprof -gv --base=<firstheap>.heap <executable name> <comparewith>.heap
102 ~~~~~~~~