Add UST vs SystemTAP scalability test
authorMathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Tue, 25 Jan 2011 17:26:51 +0000 (12:26 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Tue, 25 Jan 2011 17:26:51 +0000 (12:26 -0500)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
configure.ac
tests/tracepoint/Makefile.am
tests/tracepoint/benchmark/Makefile.am [new file with mode: 0644]
tests/tracepoint/benchmark/runstap.sh [new file with mode: 0644]
tests/tracepoint/benchmark/runtest.sh [new file with mode: 0644]
tests/tracepoint/benchmark/testutrace.stp [new file with mode: 0644]
tests/tracepoint/benchmark/tracepoint_benchmark.c [new file with mode: 0644]
tests/tracepoint/benchmark/tracepoint_benchmark.h [new file with mode: 0644]

index bdd6795f6ce9eaea9d2f91d6373f726354524ac1..c7d966b91d1eedea78c5ce143705a30b19757cfc 100644 (file)
@@ -128,6 +128,7 @@ AC_CONFIG_FILES([
        tests/same_line_marker/Makefile
        tests/trace_event/Makefile
        tests/tracepoint/Makefile
+       tests/tracepoint/benchmark/Makefile
        tests/register_test/Makefile
        tests/ustcmd_function_tests/Makefile
        libustinstr-malloc/Makefile
index 37c8f200e19fe87a98f3a5954d05e74e435806f7..90ff28761642b32fc1d5b3c866abee5943def50e 100644 (file)
@@ -1,3 +1,5 @@
+SUBDIRS = benchmark
+
 AM_CPPFLAGS = -I$(top_srcdir)/include
 
 noinst_PROGRAMS = tracepoint_test
diff --git a/tests/tracepoint/benchmark/Makefile.am b/tests/tracepoint/benchmark/Makefile.am
new file mode 100644 (file)
index 0000000..50f7bf5
--- /dev/null
@@ -0,0 +1,7 @@
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
+noinst_PROGRAMS = tracepoint_benchmark
+tracepoint_benchmark_SOURCES = tracepoint_benchmark.c tracepoint_benchmark.h
+tracepoint_benchmark_LDADD = $(top_builddir)/libust/libust.la $(top_builddir)/libust-initializer.o
+
+CFLAGS_tracepoint_benchmark.o = -I$(src) -g
diff --git a/tests/tracepoint/benchmark/runstap.sh b/tests/tracepoint/benchmark/runstap.sh
new file mode 100644 (file)
index 0000000..3a3f4c4
--- /dev/null
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+#SystemTAP benchmark
+
+REPORT=/tmp/testreport
+
+rm $REPORT
+
+echo "Userspace tracing scalability test report" |tee >> $REPORT
+
+for nr_threads in 1 2 4 8; do
+       echo "" | tee >> $REPORT
+       echo Number of threads: $nr_threads | tee >> $REPORT
+       echo "* Baseline" | tee >> $REPORT
+
+       killall stapio
+       sleep 3
+
+       sync
+       /usr/bin/time -o /tmp/testlog ./.libs/tracepoint_benchmark ${nr_threads}
+       cat /tmp/testlog >> $REPORT
+
+       echo "* Flight recorder" | tee >> $REPORT
+       #For flight recorder
+       #stap testutrace.stp -F
+
+       #Writing to disk
+       stap testutrace.stp -o /tmp/stapconsole-$nr_threads &
+
+       sleep 2
+       sync
+       /usr/bin/time -o /tmp/testlog ./.libs/tracepoint_benchmark ${nr_threads}
+       cat /tmp/testlog >> $REPORT
+done
+
+cat /tmp/testreport
diff --git a/tests/tracepoint/benchmark/runtest.sh b/tests/tracepoint/benchmark/runtest.sh
new file mode 100644 (file)
index 0000000..bd80384
--- /dev/null
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+#UST scalability test
+
+REPORT=/tmp/testreport
+
+rm $REPORT
+
+echo "Userspace tracing scalability test report" |tee >> $REPORT
+
+for nr_threads in 1 2 4 8; do
+       echo "" | tee >> $REPORT
+       echo Number of threads: $nr_threads | tee >> $REPORT
+       echo "* Baseline" | tee >> $REPORT
+
+       sync
+       /usr/bin/time -o /tmp/testlog ./.libs/tracepoint_benchmark ${nr_threads}
+       cat /tmp/testlog >> $REPORT
+
+       #flight recorder, don't record trace to disk.
+       export UST_AUTOCOLLECT=0
+       export UST_OVERWRITE=1
+       export UST_SUBBUF_NUM=16
+       #default buffer size is 4k
+
+       #Collect traces to disk
+       #export UST_AUTOCOLLECT=1
+       #export UST_OVERWRITE=0
+       #export UST_SUBBUF_NUM=16
+       #default buffer size is 4k
+
+       echo "* Flight recorder" | tee >> $REPORT
+       sync
+       /usr/bin/time -o /tmp/testlog usttrace ./.libs/tracepoint_benchmark ${nr_threads}
+       cat /tmp/testlog >> $REPORT
+done
+
+cat /tmp/testreport
diff --git a/tests/tracepoint/benchmark/testutrace.stp b/tests/tracepoint/benchmark/testutrace.stp
new file mode 100644 (file)
index 0000000..ad8ed68
--- /dev/null
@@ -0,0 +1,4 @@
+probe process("./.libs/tracepoint_benchmark").function("single_trace") { 
+       printf("%d : %s\n", gettimeofday_ns(), $$parms); 
+}
+
diff --git a/tests/tracepoint/benchmark/tracepoint_benchmark.c b/tests/tracepoint/benchmark/tracepoint_benchmark.c
new file mode 100644 (file)
index 0000000..8af4b84
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2010 David Goulet <david.goulet@polymtl.ca>
+ * Copyright (C) 2010 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
+ */
+
+/*
+ * This test is aimed at testing tracepoint *with* trace_mark :
+ *
+ * 1) tracepoint named : "ust_event"
+ *     -) Probe 1 registered and recording the value 42
+ */
+
+#include <stdio.h>
+#include "tracepoint_benchmark.h"
+#include <ust/type-serializer.h>
+
+#define NR_EVENTS      10000000
+
+DEFINE_TRACE(ust_event);
+
+void tp_probe(void *data, unsigned int p1);
+
+DEFINE_MARKER_TP(ust, event, ust_event, tp_probe, "p1 %u");
+
+/*
+ * Probe 1 --> ust_event
+ */
+void tp_probe(void *data, unsigned int p1)
+{
+       struct marker *marker;
+
+       marker = &GET_MARKER(ust, event);
+       ltt_specialized_trace(marker, data, &p1, sizeof(p1), sizeof(p1));
+}
+
+static void __attribute__((constructor)) init()
+{
+       register_trace_ust_event(tp_probe, NULL);
+}
+
+void single_trace(unsigned int v)
+{
+       trace_ust_event(v);
+}
+
+void do_trace(void)
+{
+       long i;
+
+       for (i = 0; i < NR_EVENTS; i++)
+               single_trace(42);
+}
+
+void *thr1(void *arg)
+{
+       do_trace();
+       return ((void*)1);
+}
+
+int main(int argc, char **argv)
+{
+       int err, i;
+       void *tret;
+       pthread_t *tid;
+       int nr_threads;
+
+       if (argc > 1)
+               nr_threads = atoi(argv[1]);
+       else
+               nr_threads = 1;
+       printf("Starting test for %d threads\n", nr_threads);
+
+       tid = malloc(sizeof(*tid) * nr_threads);
+
+       for (i = 0; i < nr_threads; i++) {
+               err = pthread_create(&tid[i], NULL, thr1, NULL);
+               if (err != 0)
+                       exit(1);
+       }
+
+       for (i = 0; i < nr_threads; i++) {
+               err = pthread_join(tid[i], &tret);
+               if (err != 0)
+                       exit(1);
+       }
+       free(tid);
+       return 0;
+}
diff --git a/tests/tracepoint/benchmark/tracepoint_benchmark.h b/tests/tracepoint/benchmark/tracepoint_benchmark.h
new file mode 100644 (file)
index 0000000..a9fcb19
--- /dev/null
@@ -0,0 +1,3 @@
+#include <ust/tracepoint.h>
+
+DECLARE_TRACE(ust_event, TP_PROTO(unsigned int v), TP_ARGS(v));
This page took 0.026472 seconds and 4 git commands to generate.