From e72d66a658231b37d7dc1525ed5c2e5e9a3f0668 Mon Sep 17 00:00:00 2001 From: David Goulet Date: Tue, 27 Mar 2012 16:04:27 -0400 Subject: [PATCH] Add high-throughput test This tests high number of events being recorded with multiple concurrent instrumented applications. Signed-off-by: David Goulet --- .gitignore | 1 + configure.ac | 1 + tests/test_list.py | 6 ++ tests/ust/Makefile.am | 2 +- tests/ust/high-throughput/Makefile.am | 16 +++++ tests/ust/high-throughput/main.c | 89 ++++++++++++++++++++++++++ tests/ust/high-throughput/run | 91 +++++++++++++++++++++++++++ tests/ust/high-throughput/tp.c | 18 ++++++ tests/ust/high-throughput/tp.h | 61 ++++++++++++++++++ tests/ust/runall.sh | 3 +- 10 files changed, 286 insertions(+), 2 deletions(-) create mode 100644 tests/ust/high-throughput/Makefile.am create mode 100644 tests/ust/high-throughput/main.c create mode 100755 tests/ust/high-throughput/run create mode 100644 tests/ust/high-throughput/tp.c create mode 100644 tests/ust/high-throughput/tp.h diff --git a/.gitignore b/.gitignore index ac0b2f433..b63da96a3 100644 --- a/.gitignore +++ b/.gitignore @@ -45,5 +45,6 @@ ust_global_all_events_basic ust_global_event_basic gen-nevents gen-events-time +gen-events benchmark/ diff --git a/configure.ac b/configure.ac index f8518c568..b2dbe4268 100644 --- a/configure.ac +++ b/configure.ac @@ -199,6 +199,7 @@ AC_CONFIG_FILES([ tests/ust/Makefile tests/ust/nevents/Makefile tests/ust/nprocesses/Makefile + tests/ust/high-throughput/Makefile ]) AC_OUTPUT diff --git a/tests/test_list.py b/tests/test_list.py index bb9748afc..80e76491d 100644 --- a/tests/test_list.py +++ b/tests/test_list.py @@ -46,4 +46,10 @@ Tests = \ 'desc': "Test multiple events during tracing", 'success': 0, 'enabled': True }, + { + 'bin': "ust/high-throughput/run", 'daemon': True, 'kern': False, + 'name': "UST tracer - Testing high events throughput", + 'desc': "Test multiple large number of events with concurrent application", + 'success': 0, 'enabled': True + }, ] diff --git a/tests/ust/Makefile.am b/tests/ust/Makefile.am index 822e33c51..300ebf15e 100644 --- a/tests/ust/Makefile.am +++ b/tests/ust/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = nevents nprocesses +SUBDIRS = nevents nprocesses high-throughput AM_CFLAGS = -g -Wall -I../ AM_LDFLAGS = -lurcu -lurcu-cds diff --git a/tests/ust/high-throughput/Makefile.am b/tests/ust/high-throughput/Makefile.am new file mode 100644 index 000000000..01d5ad28c --- /dev/null +++ b/tests/ust/high-throughput/Makefile.am @@ -0,0 +1,16 @@ +AM_CFLAGS = -I. -O2 +AM_LDFLAGS = -llttng-ust + +if LTTNG_TOOLS_BUILD_WITH_LIBDL +AM_LDFLAGS += -ldl +endif +if LTTNG_TOOLS_BUILD_WITH_LIBC_DL +AM_LDFLAGS += -lc +endif + +noinst_PROGRAMS = gen-events +gen_events_SOURCES = main.c tp.c tp.h +gen_events_LDADD = -llttng-ust + +noinst_SCRIPTS = run +EXTRA_DIST = run diff --git a/tests/ust/high-throughput/main.c b/tests/ust/high-throughput/main.c new file mode 100644 index 000000000..dbd2998ac --- /dev/null +++ b/tests/ust/high-throughput/main.c @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2009 Pierre-Marc Fournier + * Copyright (C) 2011 Mathieu Desnoyers + * + * 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; version 2.1 of + * the License. + * + * 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 + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define TRACEPOINT_DEFINE +#include "tp.h" + +void inthandler(int sig) +{ +} + +int init_int_handler(void) +{ + int result; + struct sigaction act; + + memset(&act, 0, sizeof(act)); + result = sigemptyset(&act.sa_mask); + if (result == -1) { + perror("sigemptyset"); + return -1; + } + + act.sa_handler = inthandler; + act.sa_flags = SA_RESTART; + + /* Only defer ourselves. Also, try to restart interrupted + * syscalls to disturb the traced program as little as possible. + */ + result = sigaction(SIGUSR1, &act, NULL); + if (result == -1) { + perror("sigaction"); + return -1; + } + + return 0; +} + +int main(int argc, char **argv) +{ + int i, netint; + long values[] = { 1, 2, 3 }; + char text[10] = "test"; + double dbl = 2.0; + float flt = 2222.0; + int delay = 0; + + init_int_handler(); + + if (argc == 2) + delay = atoi(argv[1]); + + sleep(delay); + + for (i = 0; i < 1000000; i++) { + netint = htonl(i); + tracepoint(tp, tptest, i, netint, values, text, + strlen(text), dbl, flt); + } + + return 0; +} diff --git a/tests/ust/high-throughput/run b/tests/ust/high-throughput/run new file mode 100755 index 000000000..bc30c8399 --- /dev/null +++ b/tests/ust/high-throughput/run @@ -0,0 +1,91 @@ +#!/bin/bash +# +# Copyright (C) - 2012 David Goulet +# +# 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; version 2.1 of the License. +# +# 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 + +CURDIR=$(dirname $0)/ +TESTDIR=$CURDIR/../.. +NR_ITER=20 +BIN_NAME="gen-events" +SESSION_NAME="high-throughput" +EVENT_NAME="tp:tptest" + +source $TESTDIR/utils.sh + +echo -e "\n-------------------------------------------" +echo -e "UST tracer - Testing high events throughput" +echo -e "-------------------------------------------" + +if [ ! -e "$CURDIR/$BIN_NAME" ]; then + echo -e "No UST nevents binary detected. Passing." + exit 0 +fi + +TRACE_PATH=$(mktemp -d) + +# MUST set TESTDIR before calling those functions + +start_sessiond + +create_lttng_session $SESSION_NAME $TRACE_PATH + +enable_ust_lttng_event $SESSION_NAME $EVENT_NAME +start_tracing $SESSION_NAME + +for i in `seq 1 $NR_ITER`; do + ./$CURDIR/$BIN_NAME & >/dev/null 2>&1 +done + +echo "Waiting for all tracing to settle" +sleep 5 + +stop_tracing $SESSION_NAME +destroy_lttng_session $SESSION_NAME + +stop_sessiond + +# Validate test + +TEMP_FILE=$(mktemp) +TEMP_FILE_2=$(mktemp) + +traced=$(babeltrace $TRACE_PATH 2>/dev/null | wc -l) +babeltrace $TRACE_PATH >/dev/null 2>$TEMP_FILE_2 + +cat $TEMP_FILE_2 | cut -f4 -d " " >$TEMP_FILE + +dropped=0 +while read line; +do + let dropped=$dropped+$line +done < $TEMP_FILE + +let total=$dropped+$traced +let wanted=$NR_ITER*1000000 + +if [ $wanted -ne $total ]; then + echo -n "Expected $wanted. Dropped $dropped. Recorded $traced. Total $total... " + echo -e "\e[1;31mFAILED\e[0m" + out=1 +else + echo -n "Expected $wanted. Dropped $dropped. Recorded $traced. Total $total... " + echo -e "\e[1;32mOK\e[0m" + out=0 +fi + +rm -rf $TRACE_PATH +rm $TEMP_FILE $TEMP_FILE_2 + +exit $out diff --git a/tests/ust/high-throughput/tp.c b/tests/ust/high-throughput/tp.c new file mode 100644 index 000000000..1d6cbdaab --- /dev/null +++ b/tests/ust/high-throughput/tp.c @@ -0,0 +1,18 @@ +/* + * tp.c + * + * Copyright (c) 2011 Mathieu Desnoyers + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + */ + +#define TRACEPOINT_CREATE_PROBES +#include "tp.h" diff --git a/tests/ust/high-throughput/tp.h b/tests/ust/high-throughput/tp.h new file mode 100644 index 000000000..23d4d2508 --- /dev/null +++ b/tests/ust/high-throughput/tp.h @@ -0,0 +1,61 @@ +#undef TRACEPOINT_PROVIDER +#define TRACEPOINT_PROVIDER tp + +#if !defined(_TRACEPOINT_TP_H) || defined(TRACEPOINT_HEADER_MULTI_READ) +#define _TRACEPOINT_TP_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Copyright (C) 2011 Mathieu Desnoyers + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + */ + +#include + +TRACEPOINT_EVENT(tp, tptest, + TP_ARGS(int, anint, int, netint, long *, values, + char *, text, size_t, textlen, double, doublearg, float, floatarg), + TP_FIELDS( + ctf_integer(int, intfield, anint) + ctf_integer_hex(int, intfield2, anint) + ctf_integer(long, longfield, anint) + ctf_integer_network(int, netintfield, netint) + ctf_integer_network_hex(int, netintfieldhex, netint) + ctf_array(long, arrfield1, values, 3) + ctf_array_text(char, arrfield2, text, 10) + ctf_sequence(char, seqfield1, text, size_t, textlen) + ctf_sequence_text(char, seqfield2, text, size_t, textlen) + ctf_string(stringfield, text) + ctf_float(float, floatfield, floatarg) + ctf_float(double, doublefield, doublearg) + ) +) + +TRACEPOINT_EVENT(tp, tptest_sighandler, + TP_ARGS(), + TP_FIELDS() +) + +#endif /* _TRACEPOINT_TP_H */ + +#undef TRACEPOINT_INCLUDE_FILE +#define TRACEPOINT_INCLUDE_FILE ./tp.h + +/* This part must be outside ifdef protection */ +#include + +#ifdef __cplusplus +} +#endif diff --git a/tests/ust/runall.sh b/tests/ust/runall.sh index 78182cb92..514680b7a 100755 --- a/tests/ust/runall.sh +++ b/tests/ust/runall.sh @@ -2,7 +2,8 @@ DIR=$(dirname $0) -tests=( $DIR/run-ust-global-tests.sh $DIR/nevents/run $DIR/nprocesses/run ) +tests=( $DIR/run-ust-global-tests.sh $DIR/nevents/run $DIR/nprocesses/run \ + $DIR/high-throughput/run ) exit_code=0 function start_tests () -- 2.34.1