(New) Root Memory checker Marian Ivanov (New) Root Memory checker
Outlook Motivation New memory checker AliRoot observations Implementation User interface Examples AliRoot observations
Motivation The AliRoot use to much memory Memory checker needed Valgrind and vtune – too slow – difficult to run realistic simulation reconstruction ( factor 50 slow down) We need some automatic procedure to check the quality of code – Optimally done during the nightly builds + Sending message to the top violators Number of new – deletes Total and current allocated space – development in time Selective queries – per libraries – per functions
Implementation – Classes - Information TinfoStamp memory alocation information – TotalCount, CurrentCount, TotalSize, CurrentSize Code ID, StampNumber TcodeInfo Code information – address of the code TinfoStamps – current, last, max memory stamp, max alloc count Integrated from all called function TstackInfo Array of code information – stack
Containers MemStatManager Information dumped to the output tree std vector of CodeInfos std vector of StackInfos std vector of StampInfos – (evolving in time) Information dumped to the output tree 1. On demand 2. Automatic dump after reaching the predefined size
Principles Hook for alloc and free Possibility to enable and disable Alloc hook: Get the stack trace Register the new stack trace if not registered yet Register memory for given stack (increase counters) Free hook Unregister memory for stack created given pointer (decrease counters)
User interface – acquiring data Start TMemStatDraw draw(100000,1000); User specify the auto stamp size - Allocated size, Number of allocation Make stamps – (inside the code - macro) draw.AddStamp("Start"); funF(); draw.AddStamp("funF"); Destructor Close the file with stamps
User interface – quering of information Initialization from file - TMemStatDraw draw("memstat.root") Select code information draw.SelectCode("testMemstat","fun",TMemStatDraw::kOR) draw.SortCode(TMemStatDraw::kAllocSize,TMemStatDraw::kCurrent); draw.PrintCode(10,10) Select stack information draw.SelectStack(TMemStatDraw::kOR) draw.SortStack(TMemStatDraw::kAllocSize,TMemStatDraw::kCurrent); draw.PrintStack(10,10)
User interface – quering of information - output 58 /home/miranov/root6/HEAD/memstat/src/testMemstat2_C.so(_Z9funObjectv+0x60) [0x6037dc] 58 (nil) /home/miranov/root6/HEAD/memstat/src/testMemstat2_C.so funObject() 60 58 2000.000000 56000.000000 1000 28000 59 58 2000.000000 56000.000000 2000 56000 62 /home/miranov/root6/HEAD/memstat/src/testMemstat2_C.so(_Z9funObjectv+0x7b) [0x6037f7] 62 (nil) /home/miranov/root6/HEAD/memstat/src/testMemstat2_C.so funObject() 60 62 4000.000000 88890.000000 2000 44445 59 62 4000.000000 88890.000000 4000 88890 35 /home/miranov/root6/HEAD/memstat/src/testMemstat2_C.so(_Z4funDv+0x91) [0x6034df] 35 (nil) /home/miranov/root6/HEAD/memstat/src/testMemstat2_C.so funD() 35 35 2000.000000 471088.000000 200 46224 32 35 1992.000000 469304.000000 201 46440 32 35 1998.000000 470672.000000 201 46512
User interface – quering of information - output 34 39 - code trace 60 34 2000.000000 56000.000000 1000 28000 59 34 2000.000000 56000.000000 2000 56000 1 /home/miranov/root6/HEAD/lib/libCore.so TStorage::ObjectAlloc(unsigned int) 3 /home/miranov/root6/HEAD/memstat/src/testMemstat2_C.so funObject() 4 /home/miranov/root6/HEAD/memstat/src/testMemstat2_C.so testMemstat2() 5 /home/miranov/root6/HEAD/memstat/src/testMemstat2_C.so [0x603a7e] 6 /home/miranov/root6/HEAD/lib/libCint.so Cint::G__ExceptionWrapper(int (*)(G__value*, char const*, G__param*, int), G__value*, char*, G__param*, int) 7 /home/miranov/root6/HEAD/lib/libCint.so G__call_cppfunc 8 /home/miranov/root6/HEAD/lib/libCint.so G__interpret_func 9 /home/miranov/root6/HEAD/lib/libCint.so G__getfunction 10 /home/miranov/root6/HEAD/lib/libCint.so G__getitem 11 /home/miranov/root6/HEAD/lib/libCint.so G__getexpr Summary for selected: 0 0 22001.000000 1311756.000000 4600 188599
Time development
AliRoot observation All Summary for selected: 0 0 25382175.000000 77381358317.000000 1269965 226342517 CDB 0 0 464091.000000 303540208.000000 46530 102131007 libGeom 0 0 2346765.000000 214681572.000000 855006 74312716 ITS 0 0 10809874.000000 32580849816.000000 44414 69761886 MUON 0 0 7189011.000000 473414840.000000 495789 52071527 TRD 0 0 2090102.000000 8151845194.000000 67925 15438047 TPC 0 0 1573721.000000 35063547002.000000 20326 12634261 TOF 0 0 171168.000000 32524767.000000 20399 8060014
AliRoot observation draw.SortStack(TMemStatDraw::kTotalAllocCount,TMemStatDraw::kCurrent); draw.PrintStack(10,10) !!!!!!!!!!!!!!!!!!!!!!!!!! 475078 561163 - code trace 319594 0 2608128.000000 8012169216.000000 0 0 0 0 1.000000 3072.000000 1 3072 2 /home/miranov/root6/HEAD/lib/libCore.so TArrayF::Set(int, float const*) 3 /home/miranov/root6/HEAD/lib/libCore.so TArrayF::TArrayF(TArrayF const&) 4 /home/miranov/AliRoot7/HEAD/lib/tgt_linux/libITSbase.so AliITSCalibrationSSD::GetNoiseN() const 5 /home/miranov/AliRoot7/HEAD/lib/tgt_linux/libITSsim.so AliITSsimulationSSD::ApplyNoise(AliITSpList* CODE ???????????????????????????????? TArrayF GetNoiseN() const {return fNoisN; } TArrayF GetNoiseP() const {return fNoisN; } TArrayF GetGainP() const {return fGainP; } TArrayF GetGainN() const {return fGainN
Future plans Commit memstat package to ROOT Still some aspects of user interface to be discussed Work on graphic interface – inside of ROOT Make set of automatic procedure Triggered during nightly builds Possible already now