Comparing the scaling of UST and SystemTap
authorJulien Desfossez <julien.desfossez@polymtl.ca>
Wed, 16 Feb 2011 20:20:55 +0000 (15:20 -0500)
committerJulien Desfossez <julien.desfossez@polymtl.ca>
Wed, 16 Feb 2011 20:20:55 +0000 (15:20 -0500)
Signed-off-by: Julien Desfossez <julien.desfossez@polymtl.ca>
ust-systemtap-tracepoints/Makefile [new file with mode: 0644]
ust-systemtap-tracepoints/probes.d [new file with mode: 0644]
ust-systemtap-tracepoints/runtest.sh [new file with mode: 0644]
ust-systemtap-tracepoints/testutrace.stp [new file with mode: 0644]
ust-systemtap-tracepoints/trace.h [new file with mode: 0644]
ust-systemtap-tracepoints/tracepoint_benchmark.c [new file with mode: 0644]
ust-systemtap-tracepoints/tracepoint_benchmark.h [new file with mode: 0644]

diff --git a/ust-systemtap-tracepoints/Makefile b/ust-systemtap-tracepoints/Makefile
new file mode 100644 (file)
index 0000000..1818977
--- /dev/null
@@ -0,0 +1,23 @@
+CC=gcc
+CFLAGS=-g -Wall -DHAVE_SYSTEMTAP
+LDFLAGS=-lust
+DTRACE=dtrace
+STAP=stap
+
+TARGETS=probes.h probes.o tracepoint_benchmark testutrace
+
+all: $(TARGETS)
+
+clean:
+       rm $(TARGETS)
+
+tracepoint_benchmark:
+       $(CC) $(CFLAGS) $(LDFLAGS) tracepoint_benchmark.c probes.o -o tracepoint_benchmark
+
+probes.h: probes.d
+       $(DTRACE) -C -h -s $< -o $@
+probes.o: probes.d
+       $(DTRACE) -C -G -s $< -o $@
+testutrace:
+       $(STAP) -p4 testutrace.stp
+
diff --git a/ust-systemtap-tracepoints/probes.d b/ust-systemtap-tracepoints/probes.d
new file mode 100644 (file)
index 0000000..37b8846
--- /dev/null
@@ -0,0 +1,3 @@
+provider tracepoint_benchmark {
+           probe single_trace(int);
+};
diff --git a/ust-systemtap-tracepoints/runtest.sh b/ust-systemtap-tracepoints/runtest.sh
new file mode 100644 (file)
index 0000000..752916b
--- /dev/null
@@ -0,0 +1,89 @@
+#!/bin/sh
+
+#UST scalability test
+
+BINARY=tracepoint_benchmark
+REPORT=/tmp/testreport
+TMPLOG=/tmp/testlog
+WRAPPER=""
+STAP=stap
+STAPTMP=/tmp/stapconsole
+STAPPROBE=testutrace.stp
+
+rm $REPORT 2>/dev/null
+
+ust_flight_recorder() {
+       # flight recorder, don't record trace to disk.
+       # default buffer size is 4k
+       echo -n "* UST Flight recorder : " | tee >> $REPORT
+       export UST_AUTOCOLLECT=0
+       export UST_OVERWRITE=1
+       export UST_SUBBUF_NUM=16
+       WRAPPER=usttrace
+}
+
+ust_disk() {
+       # Collect traces to disk
+       # default buffer size is 4k
+       echo -n "* UST Write to disk : " | tee >> $REPORT
+       export UST_AUTOCOLLECT=1
+       export UST_OVERWRITE=0
+       export UST_SUBBUF_NUM=16
+       WRAPPER=usttrace
+}
+
+stap_flight_recorder() {
+       echo -n "* SystemTap Flight recorder : " | tee >> $REPORT
+       WRAPPER=""
+       $STAP $STAPPROBE -F -m $BINARY
+}
+
+stap_disk() {
+       echo -n "* SystemTap Write to disk : " | tee >> $REPORT
+       WRAPPER=""
+       $STAP $STAPPROBE -o $STAPTMP -m $BINARY &
+       sleep 5
+}
+
+echo "Userspace tracing scalability test report" |tee >> $REPORT
+case "$1" in
+       ust_flight_recorder)
+               TEST=ust_flight_recorder
+               ;;
+       ust_disk)
+               TEST=ust_disk
+               ;;
+       stap_flight_recorder)
+               TEST=stap_flight_recorder
+               ;;
+       stap_disk)
+               TEST=stap_disk
+               ;;
+       *)
+               echo "Usage : $0 {ust_flight_recorder|ust_disk|stap_flight_recorder|stap_disk}"
+               exit 1
+               ;;
+esac
+
+for nr_threads in 1 2 4 8; do
+       echo "" | tee >> $REPORT
+       echo Number of threads: $nr_threads | tee >> $REPORT
+       echo -n "* Baseline : " | tee >> $REPORT
+
+       # just some cleanup
+       killall stapio 2>/dev/null
+       rmmod $BINARY 2>/dev/null
+
+       sync
+       /usr/bin/time -f "%E" -o $TMPLOG ./$BINARY ${nr_threads}
+       cat $TMPLOG >> $REPORT
+
+       $TEST
+
+       sync
+       /usr/bin/time -f "%E" -o $TMPLOG $WRAPPER ./$BINARY ${nr_threads}
+       cat $TMPLOG >> $REPORT
+done
+
+cat $REPORT
+
diff --git a/ust-systemtap-tracepoints/testutrace.stp b/ust-systemtap-tracepoints/testutrace.stp
new file mode 100644 (file)
index 0000000..797b0c0
--- /dev/null
@@ -0,0 +1,4 @@
+probe process("tracepoint_benchmark").function("single_trace") { 
+       printf("%d : %s\n", gettimeofday_ns(), $$parms); 
+}
+
diff --git a/ust-systemtap-tracepoints/trace.h b/ust-systemtap-tracepoints/trace.h
new file mode 100644 (file)
index 0000000..ba9d267
--- /dev/null
@@ -0,0 +1,8 @@
+#ifdef HAVE_SYSTEMTAP
+// include the generated probes header and put markers in code
+#include "probes.h"
+#define TRACE(probe) probe
+#else
+// Wrap the probe to allow it to be removed when no systemtap available
+#define TRACE(probe)
+#endif
diff --git a/ust-systemtap-tracepoints/tracepoint_benchmark.c b/ust-systemtap-tracepoints/tracepoint_benchmark.c
new file mode 100644 (file)
index 0000000..7e443c2
--- /dev/null
@@ -0,0 +1,104 @@
+/*
+ * 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>
+#include "trace.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(TRACEPOINT_BENCHMARK_SINGLE_TRACE(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/ust-systemtap-tracepoints/tracepoint_benchmark.h b/ust-systemtap-tracepoints/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.043966 seconds and 4 git commands to generate.