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 developped 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 Run
22 --------------------------------------------------------------------------------
23 
24 ### Change Options File
25 
26 Simple example of using the JemallocProfile algorithm in a Gaudi configurable:
27 
28 ~~~~~~~~{.py}
29 #!/usr/bin/env gaudirun.py
30 from Configurables import JemallocProfile
31 #...
32 jp = JemallocProfile()
33 jp.StartFromEventN = 49
34 jp.StopAtEventN = 99
35 jp.DumpPeriod = 10
36 
37 GaudiSequencer("PhysicsSeq").Members += [ jp ]
38 ~~~~~~~~
39 
40 ### Run the job
41 
42 ~~~~~~~~{.sh}
43 $> gaudirun.py --profilerName=jemalloc --run-info-file=runinfo.json myoptions.py
44 ~~~~~~~~
45 
46 Please note the the `--profilerName=jemalloc` to enbale the profiling, and the `--run-info-file` that produces
47 a file containing information useful to interpret the results (process id of the Gaudi job, and the absolute path
48 of the executable, necessary to run the pprof analysis tool).
49 
50 Analyze
51 --------------------------------------------------------------------------------
52 ### With text output
53 
54 The pprof analysis tool from the Google performances tools (http://goog-perftools.sourceforge.net/)
55 is necessary to analyze the heap files.
56 
57 It can be used to comapre the memory in two heap files in the following way:
58 
59 ~~~~~~~~{.sh}
60 $> pprof -text --base=<firstheap>.heap <executable name> <comparewith>.heap
61 ~~~~~~~~
62 
63 ### To produce a postscript file
64 
65 ~~~~~~~~{.sh}
66 $> pprof -gv --base=<firstheap>.heap <executable name> <comparewith>.heap
67 ~~~~~~~~