|
From: <sv...@va...> - 2011-12-23 11:47:09
|
Author: philippe
Date: 2011-12-23 11:42:20 +0000 (Fri, 23 Dec 2011)
New Revision: 12315
Log:
Fix 247386 make perf does not run all performance tests :
* move memcheck/perf/many-loss-records test to perf directory
massif/perf/many-xpts test to perf directory
* modified many-loss-records.vgperf and many-xpts.vgperf,
so as to have tool specific options prefixed with their tool
* remove directory memcheck/perf and massif/perf (containing no test anymore)
Added:
trunk/perf/many-loss-records.c
trunk/perf/many-loss-records.vgperf
trunk/perf/many-xpts.c
trunk/perf/many-xpts.vgperf
Removed:
trunk/massif/perf/
trunk/memcheck/perf/
Modified:
trunk/NEWS
trunk/configure.in
trunk/massif/Makefile.am
trunk/memcheck/Makefile.am
trunk/perf/Makefile.am
Modified: trunk/NEWS
===================================================================
--- trunk/NEWS 2011-12-22 13:25:58 UTC (rev 12314)
+++ trunk/NEWS 2011-12-23 11:42:20 UTC (rev 12315)
@@ -23,6 +23,7 @@
https://bugs.kde.org/show_bug.cgi?id=XXXXXX
where XXXXXX is the bug number as listed below.
+247386 make perf does not run all performance tests
276993 fix mremap 'no thrash checks'
283413 Fix wrong sanity check
286270 vgpreload is not friendly to 64->32 bit execs, gives ld.so warnings
Modified: trunk/configure.in
===================================================================
--- trunk/configure.in 2011-12-22 13:25:58 UTC (rev 12314)
+++ trunk/configure.in 2011-12-23 11:42:20 UTC (rev 12315)
@@ -2081,7 +2081,6 @@
memcheck/tests/x86-linux/Makefile
memcheck/tests/ppc32/Makefile
memcheck/tests/ppc64/Makefile
- memcheck/perf/Makefile
cachegrind/Makefile
cachegrind/tests/Makefile
cachegrind/tests/x86/Makefile
@@ -2095,7 +2094,6 @@
helgrind/tests/Makefile
massif/Makefile
massif/tests/Makefile
- massif/perf/Makefile
massif/ms_print
lackey/Makefile
lackey/tests/Makefile
Modified: trunk/massif/Makefile.am
===================================================================
--- trunk/massif/Makefile.am 2011-12-22 13:25:58 UTC (rev 12314)
+++ trunk/massif/Makefile.am 2011-12-23 11:42:20 UTC (rev 12315)
@@ -1,7 +1,5 @@
include $(top_srcdir)/Makefile.tool.am
-SUBDIRS += perf
-
EXTRA_DIST = \
docs/ms-manual.xml \
docs/ms_print-manpage.xml
Modified: trunk/memcheck/Makefile.am
===================================================================
--- trunk/memcheck/Makefile.am 2011-12-22 13:25:58 UTC (rev 12314)
+++ trunk/memcheck/Makefile.am 2011-12-23 11:42:20 UTC (rev 12315)
@@ -1,7 +1,5 @@
include $(top_srcdir)/Makefile.tool.am
-SUBDIRS += perf
-
EXTRA_DIST = docs/mc-manual.xml docs/mc-tech-docs.xml
#----------------------------------------------------------------------------
Modified: trunk/perf/Makefile.am
===================================================================
--- trunk/perf/Makefile.am 2011-12-22 13:25:58 UTC (rev 12314)
+++ trunk/perf/Makefile.am 2011-12-23 11:42:20 UTC (rev 12315)
@@ -10,12 +10,14 @@
fbench.vgperf \
ffbench.vgperf \
heap.vgperf \
+ many-loss-records.vgperf \
+ many-xpts.vgperf \
sarp.vgperf \
tinycc.vgperf \
test_input_for_tinycc.c
check_PROGRAMS = \
- bigcode bz2 fbench ffbench heap sarp tinycc
+ bigcode bz2 fbench ffbench heap many-loss-records many-xpts sarp tinycc
AM_CFLAGS += -O $(AM_FLAG_M3264_PRI)
AM_CXXFLAGS += -O $(AM_FLAG_M3264_PRI)
Copied: trunk/perf/many-loss-records.c (from rev 12312, trunk/memcheck/perf/many-loss-records.c)
===================================================================
--- trunk/perf/many-loss-records.c (rev 0)
+++ trunk/perf/many-loss-records.c 2011-12-23 11:42:20 UTC (rev 12315)
@@ -0,0 +1,214 @@
+// Performance test for the leak checker from bug #191182.
+// Nb: it must be run with --leak-resolution=high to show the quadratic
+// behaviour caused by the large number of loss records.
+// By Philippe Waroquiers.
+//
+// On my machine, before being fixed, building the loss record list took about
+// 36 seconds, and sorting + printing it took about 20 seconds. After being
+// fixed it took about 2 seconds, and the leak checking was only a small
+// fraction of that. --njn
+
+#include <stdlib.h>
+#include <strings.h>
+#include <stdio.h>
+#include <math.h>
+
+/* parameters */
+
+/* we will create stack_fan_out ^ stack_depth different call stacks */
+int stack_fan_out = 15;
+int stack_depth = 4;
+
+/* for each call stack, allocate malloc_fan blocks */
+int malloc_fan = 4;
+
+/* for each call stack, allocate data structures having malloc_depth
+ indirection at each malloc-ed level */
+int malloc_depth = 2;
+
+/* in addition to the pointer needed to maintain the levels; some more
+ bytes are allocated simulating the data stored in the data structure */
+int malloc_data = 5;
+
+/* every n top blocks, 1 block and all its children will be freed instead of
+ being kept */
+int free_every_n = 2;
+
+/* every n release block operation, 1 block and its children will be leaked */
+int leak_every_n = 250;
+
+
+
+struct Chunk {
+ struct Chunk* child;
+ char s[];
+};
+
+struct Chunk** topblocks;
+int freetop = 0;
+
+/* statistics */
+long total_malloced = 0;
+int blocknr = 0;
+int blockfreed = 0;
+int blockleaked = 0;
+int total_stacks = 0;
+int releaseop = 0;
+
+void free_chunks (struct Chunk ** mem)
+{
+ if (*mem == 0)
+ return;
+
+ free_chunks ((&(*mem)->child));
+
+ blockfreed++;
+ free (*mem);
+ *mem = 0;
+}
+
+void release (struct Chunk ** mem)
+{
+ releaseop++;
+
+ if (releaseop % leak_every_n == 0) {
+ blockleaked++;
+ *mem = 0; // lose the pointer without free-ing the blocks
+ } else {
+ free_chunks (mem);
+ }
+}
+
+void call_stack (int level)
+{
+ int call_fan_out = 1;
+
+ if (level == stack_depth) {
+ int sz = sizeof(struct Chunk*) + malloc_data;
+ int d;
+ int f;
+
+ for (f = 0; f < malloc_fan; f++) {
+ struct Chunk *new = NULL; // shut gcc up
+ struct Chunk *prev = NULL;
+
+ for (d = 0; d < malloc_depth; d++) {
+ new = malloc (sz);
+ total_malloced += sz;
+ blocknr++;
+ new->child = prev;
+ prev = new;
+ }
+ topblocks[freetop] = new;
+
+ if (freetop % free_every_n == 0) {
+ release (&topblocks[freetop]);
+ }
+ freetop++;
+ }
+
+ total_stacks++;
+
+ } else {
+ /* Nb: don't common these up into a loop! We need different code
+ locations to exercise the problem. */
+ call_stack (level + 1);
+ if (call_fan_out == stack_fan_out) return;
+ call_fan_out++;
+
+ call_stack (level + 1);
+ if (call_fan_out == stack_fan_out) return;
+ call_fan_out++;
+
+ call_stack (level + 1);
+ if (call_fan_out == stack_fan_out) return;
+ call_fan_out++;
+
+ call_stack (level + 1);
+ if (call_fan_out == stack_fan_out) return;
+ call_fan_out++;
+
+ call_stack (level + 1);
+ if (call_fan_out == stack_fan_out) return;
+ call_fan_out++;
+
+ call_stack (level + 1);
+ if (call_fan_out == stack_fan_out) return;
+ call_fan_out++;
+
+ call_stack (level + 1);
+ if (call_fan_out == stack_fan_out) return;
+ call_fan_out++;
+
+ call_stack (level + 1);
+ if (call_fan_out == stack_fan_out) return;
+ call_fan_out++;
+
+ call_stack (level + 1);
+ if (call_fan_out == stack_fan_out) return;
+ call_fan_out++;
+
+ call_stack (level + 1);
+ if (call_fan_out == stack_fan_out) return;
+ call_fan_out++;
+
+ call_stack (level + 1);
+ if (call_fan_out == stack_fan_out) return;
+ call_fan_out++;
+
+ call_stack (level + 1);
+ if (call_fan_out == stack_fan_out) return;
+ call_fan_out++;
+
+ call_stack (level + 1);
+ if (call_fan_out == stack_fan_out) return;
+ call_fan_out++;
+
+ call_stack (level + 1);
+ if (call_fan_out == stack_fan_out) return;
+ call_fan_out++;
+
+ call_stack (level + 1);
+ if (call_fan_out == stack_fan_out) return;
+ call_fan_out++;
+
+ call_stack (level + 1);
+ if (call_fan_out == stack_fan_out) return;
+ call_fan_out++;
+
+ call_stack (level + 1);
+ if (call_fan_out == stack_fan_out) return;
+ call_fan_out++;
+
+ call_stack (level + 1);
+ if (call_fan_out == stack_fan_out) return;
+ call_fan_out++;
+
+ call_stack (level + 1);
+ if (call_fan_out == stack_fan_out) return;
+ call_fan_out++;
+
+ call_stack (level + 1);
+ if (call_fan_out == stack_fan_out) return;
+ call_fan_out++;
+
+ printf ("maximum stack_fan_out exceeded\n");
+ }
+}
+
+int main()
+{
+ int d;
+ int stacks = 1;
+ for (d = 0; d < stack_depth; d++)
+ stacks *= stack_fan_out;
+ printf ("will generate %d different stacks\n", stacks);
+ topblocks = malloc(sizeof(struct Chunk*) * stacks * malloc_fan);
+ call_stack (0);
+ printf ("total stacks %d\n", total_stacks);
+ printf ("total bytes malloc-ed: %ld\n", total_malloced);
+ printf ("total blocks malloc-ed: %d\n", blocknr);
+ printf ("total blocks free-ed: %d\n", blockfreed);
+ printf ("total blocks leak-ed: %d\n", blockleaked);
+ return 0;
+}
Copied: trunk/perf/many-loss-records.vgperf (from rev 12312, trunk/memcheck/perf/many-loss-records.vgperf)
===================================================================
--- trunk/perf/many-loss-records.vgperf (rev 0)
+++ trunk/perf/many-loss-records.vgperf 2011-12-23 11:42:20 UTC (rev 12315)
@@ -0,0 +1,2 @@
+prog: many-loss-records
+vgopts: --memcheck:leak-check=yes --memcheck:leak-resolution=high
Copied: trunk/perf/many-xpts.c (from rev 12312, trunk/massif/perf/many-xpts.c)
===================================================================
--- trunk/perf/many-xpts.c (rev 0)
+++ trunk/perf/many-xpts.c 2011-12-23 11:42:20 UTC (rev 12315)
@@ -0,0 +1,52 @@
+#include <stdlib.h>
+
+#define nth_bit(x, n) ((x >> n) & 1)
+#define Fn(N, Np1) \
+ void* a##N(int x) { return ( nth_bit(x, N) ? a##Np1(x) : a##Np1(x) ); }
+
+// This test allocates a lot of heap memory, and every allocation features a
+// different stack trace -- the stack traces are effectively a
+// representation of the number 'i', where each function represents a bit in
+// 'i', and if it's a 1 the first function is called, and if it's a 0 the
+// second function is called.
+
+void* a999(int x)
+{
+ return malloc(100);
+}
+
+Fn(17, 999)
+Fn(16, 17)
+Fn(15, 16)
+Fn(14, 15)
+Fn(13, 14)
+Fn(12, 13)
+Fn(11, 12)
+Fn(10, 11)
+Fn( 9, 10)
+Fn( 8, 9)
+Fn( 7, 8)
+Fn( 6, 7)
+Fn( 5, 6)
+Fn( 4, 5)
+Fn( 3, 4)
+Fn( 2, 3)
+Fn( 1, 2)
+Fn( 0, 1)
+
+int main(void)
+{
+ int i;
+
+ // Create a large XTree.
+ for (i = 0; i < (1 << 18); i++)
+ a0(i);
+
+ // Do a lot of allocations so it gets dup'd a lot of times.
+ for (i = 0; i < 100000; i++) {
+ free(a1(234));
+ free(a2(111));
+ }
+
+ return 0;
+}
Copied: trunk/perf/many-xpts.vgperf (from rev 12312, trunk/massif/perf/many-xpts.vgperf)
===================================================================
--- trunk/perf/many-xpts.vgperf (rev 0)
+++ trunk/perf/many-xpts.vgperf 2011-12-23 11:42:20 UTC (rev 12315)
@@ -0,0 +1,2 @@
+prog: many-xpts
+vgopts: --massif:time-unit=B --massif:depth=100
|