www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - valgrind

reply "simendsjo" <simendsjo gmail.com> writes:
I haven't used valgrind/cachegrind on C/C++ programs before, but 
I'm pretty sure it doesn't behave as expected on D code. I found 
this page to fix the mangling issue: 
http://wiki.dlang.org/Other_Dev_Tools, but all callgraphs is 
empty.
Mar 10 2013
next sibling parent reply "simendsjo" <simendsjo gmail.com> writes:
On Sunday, 10 March 2013 at 11:06:41 UTC, simendsjo wrote:
 I haven't used valgrind/cachegrind on C/C++ programs before, 
 but I'm pretty sure it doesn't behave as expected on D code. I 
 found this page to fix the mangling issue: 
 http://wiki.dlang.org/Other_Dev_Tools, but all callgraphs is 
 empty.
Ah, nevermind. Just found "callgrind"..
Mar 10 2013
parent reply Druzhinin Alexandr <news digitalmars.com> writes:
On 10.03.2013 18:11, simendsjo wrote:
 On Sunday, 10 March 2013 at 11:06:41 UTC, simendsjo wrote:
 I haven't used valgrind/cachegrind on C/C++ programs before, but I'm
 pretty sure it doesn't behave as expected on D code. I found this page
 to fix the mangling issue: http://wiki.dlang.org/Other_Dev_Tools, but
 all callgraphs is empty.
Ah, nevermind. Just found "callgrind"..
Why are you pretty sure? The difference is garbage collector only that scans memory and causes wrong read from valgrind POV and mangling makes work with it harder a little bit. But profiling, heap usage and memory leaks are the same I'm sure . I use it recently but I found one bug and it was simple and clear - I mean bug finding.
Mar 10 2013
parent "simendsjo" <simendsjo gmail.com> writes:
On Sunday, 10 March 2013 at 11:58:39 UTC, Druzhinin Alexandr 
wrote:
 On 10.03.2013 18:11, simendsjo wrote:
 On Sunday, 10 March 2013 at 11:06:41 UTC, simendsjo wrote:
 I haven't used valgrind/cachegrind on C/C++ programs before, 
 but I'm
 pretty sure it doesn't behave as expected on D code. I found 
 this page
 to fix the mangling issue: 
 http://wiki.dlang.org/Other_Dev_Tools, but
 all callgraphs is empty.
Ah, nevermind. Just found "callgrind"..
Why are you pretty sure? The difference is garbage collector only that scans memory and causes wrong read from valgrind POV and mangling makes work with it harder a little bit. But profiling, heap usage and memory leaks are the same I'm sure . I use it recently but I found one bug and it was simple and clear - I mean bug finding.
My "pretty sure" was referring to the fact that the callgraph only printed the function I was looking at. As I said, "--tool=callgrind" was the option I was looking for.
Mar 10 2013
prev sibling next sibling parent reply Dmitry Olshansky <dmitry.olsh gmail.com> writes:
10-Mar-2013 15:06, simendsjo пишет:
 I haven't used valgrind/cachegrind on C/C++ programs before, but I'm
 pretty sure it doesn't behave as expected on D code. I found this page
 to fix the mangling issue: http://wiki.dlang.org/Other_Dev_Tools, but
 all callgraphs is empty.
I've used it just yesterday with great success. At least callgrind and massif definitely work. -- Dmitry Olshansky
Mar 10 2013
parent reply Druzhinin Alexandr <news digitalmars.com> writes:
On 10.03.2013 19:45, Dmitry Olshansky wrote:
 10-Mar-2013 15:06, simendsjo пишет:
 I haven't used valgrind/cachegrind on C/C++ programs before, but I'm
 pretty sure it doesn't behave as expected on D code. I found this page
 to fix the mangling issue: http://wiki.dlang.org/Other_Dev_Tools, but
 all callgraphs is empty.
I've used it just yesterday with great success. At least callgrind and massif definitely work.
Dmitry, using massif I get tree like this (there are normal informative branches too, of course): | ->26.85% (10,364,525B) 0xD418247: ??? | ->09.86% (3,807,325B) 0x1442E08E: ??? | | ->02.99% (1,155,831B) 0x145188A6: ??? | | | ->02.99% (1,155,831B) 0x3E: ??? | | | ->02.99% (1,155,831B) 0xEB70BC7: ??? | | | ->02.99% (1,155,831B) 0x145187CE: ??? | | | ->02.99% (1,155,831B) 0x145188A6: ??? how to know who the hell is used my memory? who is Mr. '???'? can building phobos and druntime help with it?
Mar 10 2013
parent reply Dmitry Olshansky <dmitry.olsh gmail.com> writes:
10-Mar-2013 17:04, Druzhinin Alexandr пишет:
 On 10.03.2013 19:45, Dmitry Olshansky wrote:
 10-Mar-2013 15:06, simendsjo пишет:
 I haven't used valgrind/cachegrind on C/C++ programs before, but I'm
 pretty sure it doesn't behave as expected on D code. I found this page
 to fix the mangling issue: http://wiki.dlang.org/Other_Dev_Tools, but
 all callgraphs is empty.
I've used it just yesterday with great success. At least callgrind and massif definitely work.
Dmitry, using massif I get tree like this (there are normal informative branches too, of course): | ->26.85% (10,364,525B) 0xD418247: ??? | ->09.86% (3,807,325B) 0x1442E08E: ??? | | ->02.99% (1,155,831B) 0x145188A6: ??? | | | ->02.99% (1,155,831B) 0x3E: ??? | | | ->02.99% (1,155,831B) 0xEB70BC7: ??? | | | ->02.99% (1,155,831B) 0x145187CE: ??? | | | ->02.99% (1,155,831B) 0x145188A6: ??? how to know who the hell is used my memory? who is Mr. '???'? can building phobos and druntime help with it?
Here is what I see when I run it on optimized binary compiled with ldc: http://sdrv.ms/ZrFgh9 Same compiled with gdc: http://sdrv.ms/12FPPF3 And dmd also optimized: http://sdrv.ms/15Gj7RF And it looks good. I didn't bother to check the text dump in depth but here is one slice: n6: 41816 (heap allocation functions) malloc/new/new[], --alloc-fns, etc. n1: 8208 0x540209: _D2gc3gcx4Pool10initializeMFmbZv (in /home/dmitry/Dscanner/dscanner-dmd) n1: 8208 0x53EBEB: _D2gc3gcx3Gcx7newPoolMFmbZPS2gc3gcx4Pool (in /home/dmitry/Dscanner/dscanner-dmd) n1: 8208 0x53C33B: _D2gc3gcx2GC12mallocNoSyncMFmkPmZPv (in /home/dmitry/Dscanner/dscanner-dmd) n1: 8208 0x53C1F1: _D2gc3gcx2GC6mallocMFmkPmZPv (in /home/dmitry/Dscanner/dscanner-dmd) n1: 8208 0x51CABB: gc_malloc (in /home/dmitry/Dscanner/dscanner-dmd) n1: 8208 0x51E7A6: _d_newclass (in /home/dmitry/Dscanner/dscanner-dmd) n1: 8208 0x545123: thread_attachThis (in /home/dmitry/Dscanner/dscanner-dmd) n1: 8208 0x5450B5: thread_init (in /home/dmitry/Dscanner/dscanner-dmd) n1: 8208 0x53B72B: gc_init (in /home/dmitry/Dscanner/dscanner-dmd) n1: 8208 0x51E710: _ .... So I guess your Mr. X is D's GC that reserves about 1Mb at start. -- Dmitry Olshansky
Mar 10 2013
parent reply Druzhinin Alexandr <news digitalmars.com> writes:
On 11.03.2013 02:32, Dmitry Olshansky wrote:
 I didn't bother to check the text dump in depth but here is one slice:

 n6: 41816 (heap allocation functions) malloc/new/new[], --alloc-fns, etc.
   n1: 8208 0x540209: _D2gc3gcx4Pool10initializeMFmbZv (in
 /home/dmitry/Dscanner/dscanner-dmd)
    n1: 8208 0x53EBEB: _D2gc3gcx3Gcx7newPoolMFmbZPS2gc3gcx4Pool (in
 /home/dmitry/Dscanner/dscanner-dmd)
     n1: 8208 0x53C33B: _D2gc3gcx2GC12mallocNoSyncMFmkPmZPv (in
 /home/dmitry/Dscanner/dscanner-dmd)
      n1: 8208 0x53C1F1: _D2gc3gcx2GC6mallocMFmkPmZPv (in
 /home/dmitry/Dscanner/dscanner-dmd)
       n1: 8208 0x51CABB: gc_malloc (in /home/dmitry/Dscanner/dscanner-dmd)
        n1: 8208 0x51E7A6: _d_newclass (in
 /home/dmitry/Dscanner/dscanner-dmd)
         n1: 8208 0x545123: thread_attachThis (in
 /home/dmitry/Dscanner/dscanner-dmd)
          n1: 8208 0x5450B5: thread_init (in
 /home/dmitry/Dscanner/dscanner-dmd)
           n1: 8208 0x53B72B: gc_init (in
 /home/dmitry/Dscanner/dscanner-dmd)
            n1: 8208 0x51E710: _

 ....

 So I guess your Mr. X is D's GC that reserves about 1Mb at start.
Thanks for answer, Dmitry! My Mr.X was opengl driver - I just checked my code that using 3rd libs without debug symbols and found who it was. Massif shows me gc the same way as you, I just didn't show it. What visualizer do you use?
Mar 10 2013
parent reply Dmitry Olshansky <dmitry.olsh gmail.com> writes:
11-Mar-2013 04:43, Druzhinin Alexandr пишет:
 On 11.03.2013 02:32, Dmitry Olshansky wrote:
 I didn't bother to check the text dump in depth but here is one slice:

 n6: 41816 (heap allocation functions) malloc/new/new[], --alloc-fns, etc.
   n1: 8208 0x540209: _D2gc3gcx4Pool10initializeMFmbZv (in
 /home/dmitry/Dscanner/dscanner-dmd)
    n1: 8208 0x53EBEB: _D2gc3gcx3Gcx7newPoolMFmbZPS2gc3gcx4Pool (in
 /home/dmitry/Dscanner/dscanner-dmd)
     n1: 8208 0x53C33B: _D2gc3gcx2GC12mallocNoSyncMFmkPmZPv (in
 /home/dmitry/Dscanner/dscanner-dmd)
      n1: 8208 0x53C1F1: _D2gc3gcx2GC6mallocMFmkPmZPv (in
 /home/dmitry/Dscanner/dscanner-dmd)
       n1: 8208 0x51CABB: gc_malloc (in
 /home/dmitry/Dscanner/dscanner-dmd)
        n1: 8208 0x51E7A6: _d_newclass (in
 /home/dmitry/Dscanner/dscanner-dmd)
         n1: 8208 0x545123: thread_attachThis (in
 /home/dmitry/Dscanner/dscanner-dmd)
          n1: 8208 0x5450B5: thread_init (in
 /home/dmitry/Dscanner/dscanner-dmd)
           n1: 8208 0x53B72B: gc_init (in
 /home/dmitry/Dscanner/dscanner-dmd)
            n1: 8208 0x51E710: _

 ....

 So I guess your Mr. X is D's GC that reserves about 1Mb at start.
Thanks for answer, Dmitry! My Mr.X was opengl driver - I just checked my code that using 3rd libs without debug symbols and found who it was. Massif shows me gc the same way as you, I just didn't show it. What visualizer do you use?
I think it's deceptively called massif-visualizer :) -- Dmitry Olshansky
Mar 11 2013
parent Druzhinin Alexandr <news digitalmars.com> writes:
On 12.03.2013 01:28, Dmitry Olshansky wrote:
 Thanks for answer, Dmitry! My Mr.X was opengl driver - I just checked my
 code that using 3rd libs without debug symbols and found who it was.
 Massif shows me gc the same way as you, I just didn't show it.
 What visualizer do you use?
I think it's deceptively called massif-visualizer :)
very, very amazing and so unexpected! :)
Mar 11 2013
prev sibling parent reply "Brian Schott" <briancschott gmail.com> writes:
On Sunday, 10 March 2013 at 11:06:41 UTC, simendsjo wrote:
 I haven't used valgrind/cachegrind on C/C++ programs before, 
 but I'm pretty sure it doesn't behave as expected on D code. I 
 found this page to fix the mangling issue: 
 http://wiki.dlang.org/Other_Dev_Tools, but all callgraphs is 
 empty.
If you're on Linux I'd recommend that you also look at Perf[1], as Valgrind is sometimes wrong about where your code is slow. [1] https://perf.wiki.kernel.org/index.php/Tutorial
Mar 11 2013
parent Druzhinin Alexandr <news digitalmars.com> writes:
On 12.03.2013 01:39, Brian Schott wrote:
 On Sunday, 10 March 2013 at 11:06:41 UTC, simendsjo wrote:
 I haven't used valgrind/cachegrind on C/C++ programs before, but I'm
 pretty sure it doesn't behave as expected on D code. I found this page
 to fix the mangling issue: http://wiki.dlang.org/Other_Dev_Tools, but
 all callgraphs is empty.
If you're on Linux I'd recommend that you also look at Perf[1], as Valgrind is sometimes wrong about where your code is slow. [1] https://perf.wiki.kernel.org/index.php/Tutorial
Thanks for link!
Mar 11 2013