From: David Goulet Date: Wed, 11 Apr 2012 19:28:13 +0000 (-0400) Subject: Add benchmark points X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=902c99228fee6ff6b700ace9c4099f18edb56cf4;p=lttng-tools.git Add benchmark points Enable channel, event and start tracing (for UST) are now possible to measured. The run-ust-command.sh script measure those commands agains 100 applications. Change this script to mesure commands benchmark point. Signed-off-by: David Goulet --- diff --git a/benchmark/benchmark.c b/benchmark/benchmark.c index b8f8516ef..fea90afd5 100644 --- a/benchmark/benchmark.c +++ b/benchmark/benchmark.c @@ -29,7 +29,7 @@ static double g_freq; static double calibrate_cpu_freq(void) { int i, nb_calib = 10; - double freq; + double freq = 0; printf("CPU frequency calibration, this should take 10 seconds\n"); @@ -100,6 +100,58 @@ double bench_get_destroy_session(void) return get_bench_time(time_destroy_session_start, time_destroy_session_end); } +void bench_print_create_session(void) +{ + fprintf(fp, "Create session time:\n"); + fprintf(fp, " %.20f sec.\n", bench_get_create_session()); +} + +void bench_print_enable_ust_channel(void) +{ + double res; + + if ((time_enable_ust_channel_start == 0) && + (time_enable_ust_channel_end == 0)) { + fprintf(fp, "NO DATA\n"); + return; + } + + res = get_bench_time(time_enable_ust_channel_start, + time_enable_ust_channel_end); + fprintf(fp, "Enable lttng-ust channel time:\n"); + fprintf(fp, " %.20f sec.\n", res); +} + +void bench_print_enable_ust_event(void) +{ + double res; + + if ((time_enable_ust_event_start== 0) && + (time_enable_ust_event_end == 0)) { + fprintf(fp, "NO DATA\n"); + return; + } + + res = get_bench_time(time_enable_ust_event_start, + time_enable_ust_event_end); + fprintf(fp, "Enable lttng-ust event time:\n"); + fprintf(fp, " %.20f sec.\n", res); +} + +void bench_print_start_ust(void) +{ + double res; + + if ((time_start_ust_start== 0) && (time_start_ust_end == 0)) { + fprintf(fp, "NO DATA\n"); + return; + } + + res = get_bench_time(time_start_ust_start, time_start_ust_end); + fprintf(fp, "Start lttng-ust tracing time:\n"); + fprintf(fp, " %.20f sec.\n", res); +} + /* * Complete UST notification process time break down in different actions. */ diff --git a/benchmark/benchmark.h b/benchmark/benchmark.h index bbdadbbd8..eeac8180c 100644 --- a/benchmark/benchmark.h +++ b/benchmark/benchmark.h @@ -31,10 +31,17 @@ extern FILE *fp; void bench_init(void); void bench_close(void); + +void bench_print_create_session(void); +void bench_print_enable_ust_event(void); +void bench_print_enable_ust_channel(void); +void bench_print_start_ust(void); + void bench_print_boot_process(void); void bench_print_ust_register(void); void bench_print_ust_unregister(void); void bench_print_ust_notification(void); + double bench_get_create_session(void); double bench_get_destroy_session(void); diff --git a/benchmark/measures.h b/benchmark/measures.h index cbcac2204..b27ae6899 100644 --- a/benchmark/measures.h +++ b/benchmark/measures.h @@ -55,6 +55,18 @@ cycles_t time_create_session_end; cycles_t time_destroy_session_start; cycles_t time_destroy_session_end; +/* Enable an UST channel values */ +cycles_t time_enable_ust_channel_start; +cycles_t time_enable_ust_channel_end; + +/* Enable an UST event values */ +cycles_t time_enable_ust_event_start; +cycles_t time_enable_ust_event_end; + +/* Start UST tracing */ +cycles_t time_start_ust_start; +cycles_t time_start_ust_end; + /* * UST registration time * diff --git a/benchmark/run-ust-commands.sh b/benchmark/run-ust-commands.sh new file mode 100755 index 000000000..daea715f7 --- /dev/null +++ b/benchmark/run-ust-commands.sh @@ -0,0 +1,91 @@ +#!/bin/bash +# +# Copyright (C) 2011 - David Goulet +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; only version 2 +# of the License. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# + +SESSIOND_BIN="lttng-sessiond" +RESULTS_PATH="/tmp/lttng-bench-results.txt" +BASEDIR=`dirname $0` + +echo "Session daemon boot" +#BENCH_COMMANDS=1 $BASEDIR/../src/bin/lttng-sessiond/$SESSIOND_BIN -v >/dev/null 2>&1 & + +#PID_SESSIOND=$! +#if [ -z $PID_SESSIOND ]; then +# echo -e '\e[1;31mFAILED\e[0m' +# exit 1 +#else +# echo -e "\e[1;32mOK\e[0m" +# echo "PID session daemon: $PID_SESSIOND" +#fi + +# Session daemon need to boot up and run benchmark +echo -n "Waiting." +sleep 1 +echo -n "." +sleep 1 +echo "." +sleep 1 + +# Start libust instrumented application to register. +for i in `seq 100`; do + echo -n "." + ./$BASEDIR/hello & +done +echo "" + +echo "Input when ready" +read -n 1 + +# We measure these commands +lttng create test1 +lttng create test2 +lttng create test3 +lttng create test4 +lttng enable-channel chan1 -u -s test1 +lttng enable-channel chan1 -u -s test2 +lttng enable-channel chan1 -u -s test3 +lttng enable-channel chan1 -u -s test4 +lttng enable-channel chan2 -u -s test1 +lttng enable-channel chan2 -u -s test2 +lttng enable-channel chan2 -u -s test3 +lttng enable-channel chan2 -u -s test4 +lttng enable-channel chan3 -u -s test1 +lttng enable-channel chan3 -u -s test2 +lttng enable-channel chan3 -u -s test3 +lttng enable-channel chan3 -u -s test4 +lttng enable-channel chan4 -u -s test1 +lttng enable-channel chan4 -u -s test2 +lttng enable-channel chan4 -u -s test3 +lttng enable-channel chan4 -u -s test4 +lttng enable-event -a -u -c chan1 -s test1 +lttng enable-event -a -u -c chan1 -s test2 +lttng enable-event -a -u -c chan1 -s test3 +lttng enable-event -a -u -c chan1 -s test4 +lttng start test1 +lttng start test2 +lttng start test3 +lttng start test4 + +#kill $PID_SESSIOND +#wait $PID_SESSIOND + +killall hello + +echo "Benchmarks done in $RESULTS_PATH" + +exit 0 diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index f065f2124..e1783cd8e 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -452,7 +452,7 @@ static void cleanup(void) if (ret) { PERROR("close"); } - + } } for (i = 0; i < 2; i++) { @@ -473,7 +473,7 @@ static void cleanup(void) } /* OUTPUT BENCHMARK RESULTS */ - bench_init(); + //bench_init(); if (getenv("BENCH_UST_NOTIFY")) { bench_print_ust_notification(); @@ -488,6 +488,10 @@ static void cleanup(void) bench_print_boot_process(); } + if (getenv("BENCH_COMMANDS")) { + bench_print_enable_ust_event(); + } + bench_close(); /* END BENCHMARK */ @@ -3547,24 +3551,31 @@ skip_domain: } case LTTNG_ENABLE_CHANNEL: { + tracepoint(enable_ust_channel_start); ret = cmd_enable_channel(cmd_ctx->session, cmd_ctx->lsm->domain.type, &cmd_ctx->lsm->u.channel.chan); + tracepoint(enable_ust_channel_end); + bench_print_enable_ust_channel(); break; } case LTTNG_ENABLE_EVENT: { + tracepoint(enable_ust_event_start); ret = cmd_enable_event(cmd_ctx->session, cmd_ctx->lsm->domain.type, cmd_ctx->lsm->u.enable.channel_name, &cmd_ctx->lsm->u.enable.event); + tracepoint(enable_ust_event_end); break; } case LTTNG_ENABLE_ALL_EVENT: { DBG("Enabling all events"); + tracepoint(enable_ust_event_start); ret = cmd_enable_event_all(cmd_ctx->session, cmd_ctx->lsm->domain.type, cmd_ctx->lsm->u.enable.channel_name, cmd_ctx->lsm->u.enable.event.type); + tracepoint(enable_ust_event_end); break; } case LTTNG_LIST_TRACEPOINTS: @@ -3599,7 +3610,10 @@ skip_domain: } case LTTNG_START_TRACE: { + tracepoint(start_ust_start); ret = cmd_start_trace(cmd_ctx->session); + tracepoint(start_ust_end); + bench_print_start_ust(); break; } case LTTNG_STOP_TRACE: @@ -3613,6 +3627,7 @@ skip_domain: ret = cmd_create_session(cmd_ctx->lsm->session.name, cmd_ctx->lsm->session.path, &cmd_ctx->creds); tracepoint(create_session_end); + bench_print_create_session(); break; } case LTTNG_DESTROY_SESSION: @@ -4698,6 +4713,8 @@ int main(int argc, char **argv) /* Set up max poll set size */ lttng_poll_set_max_size(); + bench_init(); + /* Create thread to manage the client socket */ ret = pthread_create(&client_thread, NULL, thread_manage_clients, (void *) NULL);