Author: njn Date: 2007-10-11 09:46:56 +0100 (Thu, 11 Oct 2007) New Revision: 6983
Log: - Make alloc-fn handling more efficient. - Correct times for prior invocations of 'many-xpts'. Removed: branches/MASSIF2/massif/tests/deep-E.post.exp branches/MASSIF2/massif/tests/deep-E.stderr.exp branches/MASSIF2/massif/tests/deep-E.vgtest Modified: branches/MASSIF2/massif/ms_main.c branches/MASSIF2/massif/tests/Makefile.am branches/MASSIF2/massif/tests/alloc-fns-B.post.exp branches/MASSIF2/massif/tests/alloc-fns-B.vgtest branches/MASSIF2/massif/tests/deep-B.post.exp branches/MASSIF2/massif/tests/deep-B.stderr.exp branches/MASSIF2/massif/tests/deep-B.vgtest branches/MASSIF2/massif/tests/deep-C.post.exp branches/MASSIF2/massif/tests/deep-C.stderr.exp branches/MASSIF2/massif/tests/deep-C.vgtest branches/MASSIF2/massif/tests/deep-D.post.exp branches/MASSIF2/massif/tests/deep-D.vgtest branches/MASSIF2/massif/tests/deep.c Modified: branches/MASSIF2/massif/ms_main.c =================================================================== --- branches/MASSIF2/massif/ms_main.c 2007-10-11 07:42:18 UTC (rev 6982) +++ branches/MASSIF2/massif/ms_main.c 2007-10-11 08:46:56 UTC (rev 6983) @@ -30,6 +30,30 @@ //--------------------------------------------------------------------------- // XXX: //--------------------------------------------------------------------------- +// Performance: +// +// perl perf/vg_perf --tools=massif --reps=3 perf/{heap,tinycc} massif +// +// The other benchmarks don't do much allocation, and so give similar speeds +// to Nulgrind. +// +// Initial slowdown (r6976 + r6979): +// heap 0.24s ma:26.7s (111.4x, -----) +// tinycc 0.44s ma:10.7s (24.4x, -----) +// many-xpts 0.11s ma:32.8s (298.0x, -----) +// +// Changed alloc_fns from an OSet to an XArray (r6981): +// heap 0.24s ma:19.4s (80.6x, -----) +// tinycc 0.49s ma: 7.8s (16.0x, -----) +// many-xpts 0.12s ma:26.8s (223.4x, -----) +// +// Changed get_IPs so that all alloc_fns in a chain must be mentioned, not +// just the bottom one, greatly reducing the number of calls to is_alloc_fn +// (r6983): +// heap 0.24s ma:18.8s (78.5x, -----) +// tinycc 0.45s ma: 7.4s (16.4x, -----) +// many-xpts 0.05s ma:23.5s (470.6x, -----) +// // Todo: // - do snapshots on client requests // - C++ tests -- for each of the allocators, and overloaded versions of @@ -121,12 +145,6 @@ // - allow the output file name to be changed // // Docs: -// - need to explain that --alloc-fn changed slightly -- now if an entry -// matches an alloc-fn, that entry *and all above it* are removed. So you -// can cut out allc-fn chains at the bottom, rather than having to name -// all of them, which is better. -// - Mention that the C++ overloadable new/new[] operators aren't include in -// alloc-fns by default. // - Mention that complex functions names are best protected with single // quotes, eg: // --alloc-fn='operator new(unsigned, std::nothrow_t const&)' @@ -143,25 +161,6 @@ // Tests: // - tests/overloaded_new.cpp is there // -// Performance: -// -// perl perf/vg_perf --tools=massif --reps=3 perf/{bz2,heap,tinycc} massif -// -// The other benchmarks don't do much allocation, and so give similar speeds -// to Nulgrind. -// -// Initial slowdown: -// bz2 1.18s ma: 5.3s ( 4.5x, -----) -// heap 0.24s ma:26.7s (111.4x, -----) -// tinycc 0.44s ma:10.7s (24.4x, -----) -// many-xpts 0.11s ma:32.8s (298.0x, -----) -// -// Changed alloc_fns from an OSet to an XArray: -// bz2 1.20s ma: 5.4s ( 4.5x, -----) -// heap 0.24s ma:19.4s (80.6x, -----) -// tinycc 0.49s ma: 7.8s (16.0x, -----) -// many-xpts 0.12s ma:11.2s (93.3x, -----) -// //--------------------------------------------------------------------------- #include "pub_tool_basics.h" @@ -686,7 +685,7 @@ { #define BUF_LEN 1024 Char buf[BUF_LEN]; - Int n_ips, i, n_alloc_fns_removed = 0; + Int n_ips, i, n_alloc_fns_removed; Int overestimate; Bool fewer_IPs_than_asked_for = False; Bool removed_below_main = False; @@ -730,30 +729,35 @@ fewer_IPs_than_asked_for = True; } - // Filter uninteresting entries out of the stack trace. n_ips is - // updated accordingly. - for (i = n_ips-1; i >= 0; i--) { - if (VG_(get_fnname)(ips[i], buf, BUF_LEN)) { - - // If it's a main-or-below-main function, we (may) want to - // ignore everything after it. - // If we see one of these functions, redo=False. - if (should_hide_below_main && is_main_or_below_main(buf)) { - n_ips = i+1; // Ignore everything below here. - removed_below_main = True; + // Filter out entries that are below main, if necessary. + // XXX: stats -- should record how often this happens. + if (should_hide_below_main) { + for (i = n_ips-1; i >= 0; i--) { + if (VG_(get_fnname)(ips[i], buf, BUF_LEN)) { + if (VG_STREQ(buf, "main")) { + // We found main. Ignore everything below it, and stop + // looking. redo=False. + n_ips = i+1; + removed_below_main = True; + break; + } else if (VG_STREQ(buf, "(below main)")) { + // We found "(below main)". Ignore everything below it, + // but keep looking. redo=False. + n_ips = i+1; + removed_below_main = True; + } } + } + } - // If it's an alloc-fn, we want to delete it and everything - // before it. + // Filter out alloc fns. + n_alloc_fns_removed = 0; + for (i = 0; i < n_ips; i++) { + if (VG_(get_fnname)(ips[i], buf, BUF_LEN)) { + // If it's an alloc-fn, we ignore it. if (is_alloc_fn(buf)) { - Int j; - n_alloc_fns_removed = i+1; - - // Shuffle the rest down. - for (j = 0; j < n_ips; j++) { - ips[j] = ips[j + n_alloc_fns_removed]; - } - n_ips -= n_alloc_fns_removed; + n_alloc_fns_removed++; + } else { break; } } @@ -775,6 +779,12 @@ } } + // Ignore the alloc fns; shuffle the rest down. + n_ips -= n_alloc_fns_removed; + for (i = 0; i < n_ips; i++) { + ips[i] = ips[i + n_alloc_fns_removed]; + } + // Did we get enough IPs after filtering? If so, redo=False. if (n_ips >= clo_depth) { n_ips = clo_depth; // Ignore any IPs below --depth. Modified: branches/MASSIF2/massif/tests/Makefile.am =================================================================== --- branches/MASSIF2/massif/tests/Makefile.am 2007-10-11 07:42:18 UTC (rev 6982) +++ branches/MASSIF2/massif/tests/Makefile.am 2007-10-11 08:46:56 UTC (rev 6983) @@ -13,7 +13,6 @@ deep-B.post.exp deep-B.stderr.exp deep-B.vgtest \ deep-C.post.exp deep-C.stderr.exp deep-C.vgtest \ deep-D.post.exp deep-D.stderr.exp deep-D.vgtest \ - deep-E.post.exp deep-E.stderr.exp deep-E.vgtest \ culling1.stderr.exp culling1.vgtest \ culling2.stderr.exp culling2.vgtest \ custom_alloc.post.exp custom_alloc.stderr.exp custom_alloc.vgtest Modified: branches/MASSIF2/massif/tests/alloc-fns-B.post.exp =================================================================== --- branches/MASSIF2/massif/tests/alloc-fns-B.post.exp 2007-10-11 07:42:18 UTC (rev 6982) +++ branches/MASSIF2/massif/tests/alloc-fns-B.post.exp 2007-10-11 08:46:56 UTC (rev 6983) @@ -1,6 +1,6 @@ -------------------------------------------------------------------------------- Command: ./alloc-fns -Massif arguments: --stacks=no --time-unit=B --heap-admin=0 --alloc-fn=a4 --alloc-fn=b3 --alloc-fn=c2 --alloc-fn=d1 --alloc-fn=d3 +Massif arguments: --stacks=no --time-unit=B --heap-admin=0 --alloc-fn=a4 --alloc-fn=b4 --alloc-fn=b3 --alloc-fn=c4 --alloc-fn=c3 --alloc-fn=c2 --alloc-fn=d4 --alloc-fn=d3 --alloc-fn=d2 --alloc-fn=d1 ms_print arguments: massif.out -------------------------------------------------------------------------------- @@ -63,11 +63,9 @@ | ->11.11% (100B) 0x8048546: main (alloc-fns.c:30) | -->11.11% (100B) 0x80484C4: d2 (alloc-fns.c:20) -| ->11.11% (100B) 0x8048553: main (alloc-fns.c:31) -| +->11.11% (100B) 0x8048553: main (alloc-fns.c:31) +| ->11.11% (100B) 0x8048560: main (alloc-fns.c:32) | -->11.11% (100B) 0x8048498: d4 (alloc-fns.c:18) - ->11.11% (100B) 0x804856D: main (alloc-fns.c:33) - +->11.11% (100B) 0x804856D: main (alloc-fns.c:33) + Modified: branches/MASSIF2/massif/tests/alloc-fns-B.vgtest =================================================================== --- branches/MASSIF2/massif/tests/alloc-fns-B.vgtest 2007-10-11 07:42:18 UTC (rev 6982) +++ branches/MASSIF2/massif/tests/alloc-fns-B.vgtest 2007-10-11 08:46:56 UTC (rev 6983) @@ -1,6 +1,4 @@ prog: alloc-fns -# We deliberately do d1 and d3 as alloc-fns, so we can test calling into the -# middle of a chain of functions above and below some alloc-fns. -vgopts: --stacks=no --time-unit=B --heap-admin=0 --alloc-fn=a4 --alloc-fn=b3 --alloc-fn=c2 --alloc-fn=d1 --alloc-fn=d3 +vgopts: --stacks=no --time-unit=B --heap-admin=0 --alloc-fn=a4 --alloc-fn=b4 --alloc-fn=b3 --alloc-fn=c4 --alloc-fn=c3 --alloc-fn=c2 --alloc-fn=d4 --alloc-fn=d3 --alloc-fn=d2 --alloc-fn=d1 post: perl ../../massif/ms_print massif.out cleanup: rm massif.out Modified: branches/MASSIF2/massif/tests/deep-B.post.exp =================================================================== --- branches/MASSIF2/massif/tests/deep-B.post.exp 2007-10-11 07:42:18 UTC (rev 6982) +++ branches/MASSIF2/massif/tests/deep-B.post.exp 2007-10-11 08:46:56 UTC (rev 6983) @@ -1,6 +1,6 @@ -------------------------------------------------------------------------------- Command: ./deep -Massif arguments: --stacks=no --time-unit=B --alloc-fn=a6 +Massif arguments: --stacks=no --time-unit=B --alloc-fn=a6 --alloc-fn=a7 --alloc-fn=a8 --alloc-fn=a9 --alloc-fn=a10 --alloc-fn=a11 --alloc-fn=a12 ms_print arguments: massif.out -------------------------------------------------------------------------------- Modified: branches/MASSIF2/massif/tests/deep-B.stderr.exp =================================================================== --- branches/MASSIF2/massif/tests/deep-B.stderr.exp 2007-10-11 07:42:18 UTC (rev 6982) +++ branches/MASSIF2/massif/tests/deep-B.stderr.exp 2007-10-11 08:46:56 UTC (rev 6983) @@ -14,6 +14,12 @@ Massif: 12: operator new(unsigned long, std::nothrow_t const&) Massif: 13: operator new[](unsigned long, std::nothrow_t const&) Massif: 14: a6 +Massif: 15: a7 +Massif: 16: a8 +Massif: 17: a9 +Massif: 18: a10 +Massif: 19: a11 +Massif: 20: a12 Massif: startup S. 0 (t:0, hp:0, ad:0, st:0) Massif: alloc S. 1 (t:108, hp:100, ad:8, st:0) Massif: alloc S. 2 (t:216, hp:200, ad:16, st:0) Modified: branches/MASSIF2/massif/tests/deep-B.vgtest =================================================================== --- branches/MASSIF2/massif/tests/deep-B.vgtest 2007-10-11 07:42:18 UTC (rev 6982) +++ branches/MASSIF2/massif/tests/deep-B.vgtest 2007-10-11 08:46:56 UTC (rev 6983) @@ -1,5 +1,5 @@ prog: deep -vgopts: --stacks=no --time-unit=B --alloc-fn=a6 -v +vgopts: --stacks=no --time-unit=B --alloc-fn=a6 --alloc-fn=a7 --alloc-fn=a8 --alloc-fn=a9 --alloc-fn=a10 --alloc-fn=a11 --alloc-fn=a12 -v stderr_filter: filter_verbose post: perl ../../massif/ms_print massif.out cleanup: rm massif.out Modified: branches/MASSIF2/massif/tests/deep-C.post.exp =================================================================== --- branches/MASSIF2/massif/tests/deep-C.post.exp 2007-10-11 07:42:18 UTC (rev 6982) +++ branches/MASSIF2/massif/tests/deep-C.post.exp 2007-10-11 08:46:56 UTC (rev 6983) @@ -1,6 +1,6 @@ -------------------------------------------------------------------------------- Command: ./deep -Massif arguments: --stacks=no --time-unit=B --alloc-fn=a3 +Massif arguments: --stacks=no --time-unit=B --alloc-fn=a3 --alloc-fn=a4 --alloc-fn=a5 --alloc-fn=a6 --alloc-fn=a7 --alloc-fn=a8 --alloc-fn=a9 --alloc-fn=a10 --alloc-fn=a11 --alloc-fn=a12 ms_print arguments: massif.out -------------------------------------------------------------------------------- Modified: branches/MASSIF2/massif/tests/deep-C.stderr.exp =================================================================== --- branches/MASSIF2/massif/tests/deep-C.stderr.exp 2007-10-11 07:42:18 UTC (rev 6982) +++ branches/MASSIF2/massif/tests/deep-C.stderr.exp 2007-10-11 08:46:56 UTC (rev 6983) @@ -14,6 +14,15 @@ Massif: 12: operator new(unsigned long, std::nothrow_t const&) Massif: 13: operator new[](unsigned long, std::nothrow_t const&) Massif: 14: a3 +Massif: 15: a4 +Massif: 16: a5 +Massif: 17: a6 +Massif: 18: a7 +Massif: 19: a8 +Massif: 20: a9 +Massif: 21: a10 +Massif: 22: a11 +Massif: 23: a12 Massif: startup S. 0 (t:0, hp:0, ad:0, st:0) Massif: alloc S. 1 (t:108, hp:100, ad:8, st:0) Massif: alloc S. 2 (t:216, hp:200, ad:16, st:0) Modified: branches/MASSIF2/massif/tests/deep-C.vgtest =================================================================== --- branches/MASSIF2/massif/tests/deep-C.vgtest 2007-10-11 07:42:18 UTC (rev 6982) +++ branches/MASSIF2/massif/tests/deep-C.vgtest 2007-10-11 08:46:56 UTC (rev 6983) @@ -1,5 +1,5 @@ prog: deep -vgopts: --stacks=no --time-unit=B --alloc-fn=a3 -v +vgopts: --stacks=no --time-unit=B --alloc-fn=a3 --alloc-fn=a4 --alloc-fn=a5 --alloc-fn=a6 --alloc-fn=a7 --alloc-fn=a8 --alloc-fn=a9 --alloc-fn=a10 --alloc-fn=a11 --alloc-fn=a12 -v stderr_filter: filter_verbose post: perl ../../massif/ms_print massif.out cleanup: rm massif.out Modified: branches/MASSIF2/massif/tests/deep-D.post.exp =================================================================== --- branches/MASSIF2/massif/tests/deep-D.post.exp 2007-10-11 07:42:18 UTC (rev 6982) +++ branches/MASSIF2/massif/tests/deep-D.post.exp 2007-10-11 08:46:56 UTC (rev 6983) @@ -1,6 +1,6 @@ -------------------------------------------------------------------------------- Command: ./deep -Massif arguments: --stacks=no --time-unit=B --alloc-fn=main +Massif arguments: --stacks=no --time-unit=B --alloc-fn=a1 --alloc-fn=a2 --alloc-fn=a3 --alloc-fn=a4 --alloc-fn=a5 --alloc-fn=a6 --alloc-fn=a7 --alloc-fn=a8 --alloc-fn=a9 --alloc-fn=a10 --alloc-fn=a11 --alloc-fn=a12 --alloc-fn=main --depth=20 ms_print arguments: massif.out -------------------------------------------------------------------------------- @@ -45,15 +45,7 @@ 8 864 864 800 64 0 9 972 972 900 72 0 92.59% (900B) (heap allocation functions) malloc/new/new[], --alloc-fns, etc. -->92.59% (900B) 0x804838D: a12 (deep.c:18) - ->92.59% (900B) 0x80483A3: a11 (deep.c:19) - ->92.59% (900B) 0x80483B9: a10 (deep.c:20) - ->92.59% (900B) 0x80483CF: a9 (deep.c:21) - ->92.59% (900B) 0x80483E5: a8 (deep.c:22) - ->92.59% (900B) 0x80483FB: a7 (deep.c:23) - ->92.59% (900B) 0x8048411: a6 (deep.c:24) - ->92.59% (900B) 0x8048427: a5 (deep.c:25) - + -------------------------------------------------------------------------------- n time(B) total(B) useful-heap(B) admin-heap(B) stacks(B) -------------------------------------------------------------------------------- Modified: branches/MASSIF2/massif/tests/deep-D.vgtest =================================================================== --- branches/MASSIF2/massif/tests/deep-D.vgtest 2007-10-11 07:42:18 UTC (rev 6982) +++ branches/MASSIF2/massif/tests/deep-D.vgtest 2007-10-11 08:46:56 UTC (rev 6983) @@ -1,4 +1,4 @@ prog: deep -vgopts: --stacks=no --time-unit=B --alloc-fn=main +vgopts: --stacks=no --time-unit=B --alloc-fn=a1 --alloc-fn=a2 --alloc-fn=a3 --alloc-fn=a4 --alloc-fn=a5 --alloc-fn=a6 --alloc-fn=a7 --alloc-fn=a8 --alloc-fn=a9 --alloc-fn=a10 --alloc-fn=a11 --alloc-fn=a12 --alloc-fn=main --depth=20 post: perl ../../massif/ms_print massif.out cleanup: rm massif.out Deleted: branches/MASSIF2/massif/tests/deep-E.post.exp =================================================================== --- branches/MASSIF2/massif/tests/deep-E.post.exp 2007-10-11 07:42:18 UTC (rev 6982) +++ branches/MASSIF2/massif/tests/deep-E.post.exp 2007-10-11 08:46:56 UTC (rev 6983) @@ -1,52 +0,0 @@ --------------------------------------------------------------------------------- -Command: ./deep -Massif arguments: --stacks=no --time-unit=B --alloc-fn=main --depth=20 -ms_print arguments: massif.out --------------------------------------------------------------------------------- - - - KB -1.055^ : - | : - | @ : - | @ : - | : @ : - | : @ : - | : : @ : - | : : @ : - | : : : @ : - | : : : @ : - | : : : : @ : - | : : : : @ : - | : : : : : @ : - | : : : : : @ : - | : : : : : : @ : - | : : : : : : @ : - | : : : : : : : @ : - | : : : : : : : @ : - | : : : : : : : : @ : - | : : : : : : : : @ : - 0 [EMAIL PROTECTED]>KB - 0 1.055 - -Number of snapshots: 11 - Detailed snapshots: [9] --------------------------------------------------------------------------------- - n time(B) total(B) useful-heap(B) admin-heap(B) stacks(B) --------------------------------------------------------------------------------- - 0 0 0 0 0 0 - 1 108 108 100 8 0 - 2 216 216 200 16 0 - 3 324 324 300 24 0 - 4 432 432 400 32 0 - 5 540 540 500 40 0 - 6 648 648 600 48 0 - 7 756 756 700 56 0 - 8 864 864 800 64 0 - 9 972 972 900 72 0 -92.59% (900B) (heap allocation functions) malloc/new/new[], --alloc-fns, etc. - --------------------------------------------------------------------------------- - n time(B) total(B) useful-heap(B) admin-heap(B) stacks(B) --------------------------------------------------------------------------------- - 10 1,080 1,080 1,000 80 0 Deleted: branches/MASSIF2/massif/tests/deep-E.stderr.exp =================================================================== --- branches/MASSIF2/massif/tests/deep-E.stderr.exp 2007-10-11 07:42:18 UTC (rev 6982) +++ branches/MASSIF2/massif/tests/deep-E.stderr.exp 2007-10-11 08:46:56 UTC (rev 6983) @@ -1,2 +0,0 @@ - - Deleted: branches/MASSIF2/massif/tests/deep-E.vgtest =================================================================== --- branches/MASSIF2/massif/tests/deep-E.vgtest 2007-10-11 07:42:18 UTC (rev 6982) +++ branches/MASSIF2/massif/tests/deep-E.vgtest 2007-10-11 08:46:56 UTC (rev 6983) @@ -1,4 +0,0 @@ -prog: deep -vgopts: --stacks=no --time-unit=B --alloc-fn=main --depth=20 -post: perl ../../massif/ms_print massif.out -cleanup: rm massif.out Modified: branches/MASSIF2/massif/tests/deep.c =================================================================== --- branches/MASSIF2/massif/tests/deep.c 2007-10-11 07:42:18 UTC (rev 6982) +++ branches/MASSIF2/massif/tests/deep.c 2007-10-11 08:46:56 UTC (rev 6983) @@ -2,16 +2,14 @@ // // - In deep-A.vgtest, the stack trace is larger than the asked-for depth // (12 vs. 8) so not all of the trace is shown. -// - In deep-B.vgtest, we have --alloc-fn=a6, which means that get_XCon +// - In deep-B.vgtest, we have --alloc-fn=a6..a12, which means that get_XCon // needs to redo the IP getting, because 7 functions get removed from the // trace, which is more than the initial overestimate of 3. -// - In deep-C.vgtest, we have --alloc-fn=a3, which means that get_XCon +// - In deep-C.vgtest, we have --alloc-fn=a3..a12, which means that get_XCon // ends up with an empty stack trace after removing all the alloc-fns. // It then redoes it. -// - In deep-D.vgtest, we have --alloc-fn=main. It would be an empty stack -// trace, except the default depth doesn't get us down to 'main'. -// - In deep-E.vgtest, we have --alloc-fn=main --depth=20, which means that -// we have an empty stack trace. That's ok. +// - In deep-D.vgtest, we have --alloc-fn=main..a12, which means we have an empty +// stack trace. That's ok. #include <stdlib.h> ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Valgrind-developers mailing list Valgrind-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/valgrind-developers