|
From: <sv...@va...> - 2005-12-14 05:33:37
|
Author: njn
Date: 2005-12-14 05:33:35 +0000 (Wed, 14 Dec 2005)
New Revision: 5341
Log:
Added a stress test which measures the cost of translation.
Added:
trunk/perf/bigcode.c
trunk/perf/bigcode1.vgperf
trunk/perf/bigcode2.vgperf
Modified:
trunk/perf/Makefile.am
trunk/perf/README
Modified: trunk/perf/Makefile.am
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/perf/Makefile.am 2005-12-14 05:33:17 UTC (rev 5340)
+++ trunk/perf/Makefile.am 2005-12-14 05:33:35 UTC (rev 5341)
@@ -2,13 +2,14 @@
noinst_SCRIPTS =3D vg_perf
=20
EXTRA_DIST =3D $(noinst_SCRIPTS) \
+ bigcode.vgperf \
bz2.vgperf \
fbench.vgperf \
ffbench.vgperf \
sarp.vgperf
=20
check_PROGRAMS =3D \
- bz2 fbench ffbench sarp
+ bigcode bz2 fbench ffbench sarp
=20
AM_CFLAGS =3D $(WERROR) -Winline -Wall -Wshadow -g -O
AM_CPPFLAGS =3D -I$(top_srcdir) -I$(top_srcdir)/include -I$(top_builddir=
)/include
Modified: trunk/perf/README
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/perf/README 2005-12-14 05:33:17 UTC (rev 5340)
+++ trunk/perf/README 2005-12-14 05:33:35 UTC (rev 5341)
@@ -1,9 +1,27 @@
-------------------------------------------------------------------------=
-----
+=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
Notes about performance benchmarks
+=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
+For each benchmark, here is a brief description and notes about its
+strengths and weaknesses.
+
------------------------------------------------------------------------=
-----
-For each benchmark, here is a brief description and notes about strength=
s
-and weaknesses of the benchmark.
+Artificial stress tests
+------------------------------------------------------------------------=
-----
+bigcode1, bigcode2:
+- Description: Executes a lot of (nonsensical) code.
+- Strengths: Demonstrates the cost of translation which is a large par=
t
+ of runtime, particularly on larger programs.
+- Weaknesses: Highly artificial.
=20
+sarp:
+- Description: Does a lot of stack allocation and deallocation.
+- Strengths: Tests for a specific performance bug that existed in 3.1.=
0 and
+ all earlier versions.
+- Weaknesses: Highly artificial.
+
+------------------------------------------------------------------------=
-----
+Real programs
+------------------------------------------------------------------------=
-----
bz2:
- Description: Burrows-Wheeler compression and decompression.
- Strengths: A real, widely used program, very similar to the 256.bzip=
2
@@ -26,9 +44,4 @@
- Weaknesses: Dominated by the inner loop, which is quite long and flat=
ters
Valgrind due to the small dispatcher overhead.
=20
-sarp:
-- Description: Does a lot of stack allocation and deallocation.
-- Strengths: Tests for a specific performance bug that existed in 3.1.=
0 and
- all earlier versions.
-- Weaknesses: Highly artificial.
=20
Added: trunk/perf/bigcode.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/perf/bigcode.c (rev 0)
+++ trunk/perf/bigcode.c 2005-12-14 05:33:35 UTC (rev 5341)
@@ -0,0 +1,73 @@
+// This artificial program runs a lot of code. The exact amount depends=
on
+// the command line -- if any command line args are given, it does exact=
ly
+// the same amount of work, but using four times as much code.
+//
+// It's a stress test for Valgrind's translation speed; natively the tw=
o
+// modes run in about the same time (the I-cache effects aren't big enou=
gh
+// to make a difference), but under Valgrind the one running more code i=
s
+// significantly slower due to the extra translation time.
+
+#include <stdio.h>
+#include <string.h>
+
+#define FN_SIZE 996 // Must be big enough to hold the compiled f(=
)
+#define N_LOOPS 20000 // Should be divisible by four
+#define RATIO 4 // Ratio of code sizes between the two modes
+
+int f(int x, int y)
+{
+ int i;
+ for (i =3D 0; i < 5000; i++) {
+ switch (x % 8) {
+ case 1: y +=3D 3;
+ case 2: y +=3D x;
+ case 3: y *=3D 2;
+ default: y--;
+ }
+ }
+ return y;
+}
+
+static char a[FN_SIZE * N_LOOPS];
+
+int main(int argc, char* argv[])
+{
+ int h, i, sum1 =3D 0, sum2 =3D 0, sum3 =3D 0, sum4 =3D 0;
+ int n_fns, n_reps;
+
+ if (argc <=3D 1) {
+ // Mode 1: not so much code
+ n_fns =3D N_LOOPS / RATIO;
+ n_reps =3D RATIO;
+ printf("mode 1: ");
+ } else {
+ // Mode 2: lots of code
+ n_fns =3D N_LOOPS;
+ n_reps =3D 1;
+ printf("mode 1: ");
+ }
+ printf("%d copies of f(), %d reps\n", n_fns, n_reps);
+ =20
+ // Make a whole lot of copies of f(). FN_SIZE is much bigger than f(=
)
+ // will ever be (we hope).
+ for (i =3D 0; i < n_fns; i++) {
+ memcpy(&a[FN_SIZE*i], f, FN_SIZE);
+ }
+ =20
+ for (h =3D 0; h < n_reps; h +=3D 1) {
+ for (i =3D 0; i < n_fns; i +=3D 4) {
+ int(*f1)(int,int) =3D (void*)&a[FN_SIZE*(i+0)];
+ int(*f2)(int,int) =3D (void*)&a[FN_SIZE*(i+1)];
+ int(*f3)(int,int) =3D (void*)&a[FN_SIZE*(i+2)];
+ int(*f4)(int,int) =3D (void*)&a[FN_SIZE*(i+3)];
+ sum1 +=3D f1(i+0, n_fns-i+0);
+ sum2 +=3D f2(i+1, n_fns-i+1);
+ sum3 +=3D f3(i+2, n_fns-i+2);
+ sum4 +=3D f4(i+3, n_fns-i+3);
+ if (i % 1000 =3D=3D 0)
+ printf(".");
+ }
+ }
+ printf("result =3D %d\n", sum1 + sum2 + sum3 + sum4);
+ return 0;
+}
Added: trunk/perf/bigcode1.vgperf
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/perf/bigcode1.vgperf (rev 0)
+++ trunk/perf/bigcode1.vgperf 2005-12-14 05:33:35 UTC (rev 5341)
@@ -0,0 +1,2 @@
+prog: bigcode
+tools: none memcheck
Added: trunk/perf/bigcode2.vgperf
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/perf/bigcode2.vgperf (rev 0)
+++ trunk/perf/bigcode2.vgperf 2005-12-14 05:33:35 UTC (rev 5341)
@@ -0,0 +1,3 @@
+prog: bigcode
+args: 0
+tools: none memcheck
|