Merge branch 'master' into benchmark
authorDavid Goulet <david.goulet@polymtl.ca>
Thu, 25 Aug 2011 19:23:11 +0000 (15:23 -0400)
committerDavid Goulet <david.goulet@polymtl.ca>
Thu, 25 Aug 2011 19:23:32 +0000 (15:23 -0400)
17 files changed:
.gitignore
Makefile.am
benchmark/Makefile.am [new file with mode: 0644]
benchmark/bench-sessions.c [new file with mode: 0644]
benchmark/benchmark.c [new file with mode: 0644]
benchmark/benchmark.h [new file with mode: 0644]
benchmark/cpu.c [new file with mode: 0644]
benchmark/cpu.h [new file with mode: 0644]
benchmark/main.c [new file with mode: 0644]
benchmark/measures.h [new file with mode: 0644]
benchmark/run-boot-time.sh [new file with mode: 0755]
benchmark/run-sessions.sh [new file with mode: 0755]
benchmark/runall.sh [new file with mode: 0755]
benchmark/utils.h [new file with mode: 0644]
configure.ac
ltt-sessiond/Makefile.am
ltt-sessiond/main.c

index 08d44e8e8fcbc53c0f94776e2efd896e3605a5f8..37f95a4022dcf35e6b384a1bbdedc2c5495b9bbb 100644 (file)
@@ -34,3 +34,5 @@ tests/test_sessions
 tests/test_kernel_data_trace
 tests/kernel_all_events_basic
 tests/kernel_event_basic
+
+benchmark/bench_sessions
index ec8b7fe95ac0a24e471a81a7024d4305a84ef161..8815acebe02ce2924cab22e45a231caa0175723e 100644 (file)
@@ -1,6 +1,7 @@
 ACLOCAL_AMFLAGS = -I config
 
-SUBDIRS = liblttng-sessiond-comm \
+SUBDIRS = benchmark \
+                 liblttng-sessiond-comm \
                  libkernelctl \
                  liblttngkconsumerd \
                  liblttngctl \
@@ -12,3 +13,6 @@ SUBDIRS = liblttng-sessiond-comm \
                  tests \
                  include \
                  doc
+
+bench:
+       ./benchmark/runall.sh
diff --git a/benchmark/Makefile.am b/benchmark/Makefile.am
new file mode 100644 (file)
index 0000000..59c88fe
--- /dev/null
@@ -0,0 +1,16 @@
+AM_CPPFLAGS = -I$(top_srcdir)/include
+
+noinst_LTLIBRARIES = liblttng-benchmark.la
+
+noinst_PROGRAMS = bench_sessions
+
+UTILS=utils.h
+SESSIONS=$(top_srcdir)/ltt-sessiond/session.c
+
+liblttng_benchmark_la_SOURCES = benchmark.c benchmark.h cpu.c cpu.h
+
+bench_sessions_SOURCES = bench-sessions.c $(SESSIONS) $(UTILS)
+bench_sessions_LDADD = $(top_builddir)/benchmark/liblttng-benchmark.la
+
+bench:
+       ./runall.sh
diff --git a/benchmark/bench-sessions.c b/benchmark/bench-sessions.c
new file mode 100644 (file)
index 0000000..872b596
--- /dev/null
@@ -0,0 +1,131 @@
+/*
+ * Copyright (c)  2011 David Goulet <david.goulet@polymtl.ca>
+ *
+ * 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
+ * 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#define _GNU_SOURCE
+#include <assert.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <time.h>
+
+#include "ltt-sessiond/session.h"
+#include "utils.h"
+#include "benchmark.h"
+
+#define SESSION1 "test1"
+
+/* This path will NEVER be created in this test */
+#define PATH1 "/tmp/.test-junk-lttng"
+
+/* For lttngerr.h */
+int opt_quiet = 1;
+int opt_verbose = 0;
+
+static const char alphanum[] =
+       "0123456789"
+       "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+       "abcdefghijklmnopqrstuvwxyz";
+
+/*
+ * Return random string of 10 characters.
+ */
+static char *get_random_string(void)
+{
+       int i;
+       char *str = malloc(11);
+
+       for (i = 0; i < 10; i++) {
+               str[i] = alphanum[rand() % (sizeof(alphanum) - 1)];
+       }
+
+       str[10] = '\0';
+
+       return str;
+}
+
+int main(int argc, char **argv)
+{
+       int ret, i, nb_iter;
+       char **names;
+       double value, total = 0;
+
+       if (getuid() != 0) {
+               printf("Aborting test. Must be uid 0 to drop_caches\n");
+               return 1;
+       }
+
+       if (argc < 2) {
+               printf("Missing arguments\n");
+               return 1;
+       }
+
+       nb_iter = atoi(argv[1]);
+
+       names = malloc(sizeof(char*) * nb_iter);
+
+       srand(time(NULL));
+       bench_init();
+
+       fprintf(fp, "--- Create tracing session ---\n");
+       for (i = 0; i < nb_iter; i++) {
+               names[i] = get_random_string();
+               ret = system("echo 3 >/proc/sys/vm/drop_caches");
+               tracepoint(create_session_start);
+               ret = create_session(names[i], PATH1);
+               tracepoint(create_session_end);
+               if (ret < 0) {
+                       printf("Create session went wrong. Aborting\n");
+                       goto error;
+               }
+               value = bench_get_create_session();
+               fprintf(fp, "%.20f\n", value);
+               total += value;
+       }
+
+       fprintf(fp, "--> Average: %.20f\n\n", total/nb_iter);
+       total = 0;
+
+       fprintf(fp, "--- Destroy tracing session ---\n");
+       for (i = 0; i < nb_iter; i++) {
+               ret = system("echo 3 >/proc/sys/vm/drop_caches");
+               tracepoint(destroy_session_start);
+               ret = destroy_session(names[i]);
+               tracepoint(destroy_session_end);
+               if (ret < 0) {
+                       printf("Destroy session went wrong. Aborting\n");
+                       goto error;
+               }
+               value = bench_get_destroy_session();
+               fprintf(fp, "%.20f\n", value);
+               total += value;
+               free(names[i]);
+       }
+       fprintf(fp, "--> Average: %.20f\n\n", total/nb_iter);
+
+       /* Success */
+       bench_close();
+       return 0;
+
+error:
+       bench_close();
+       free(names);
+
+       return 1;
+}
diff --git a/benchmark/benchmark.c b/benchmark/benchmark.c
new file mode 100644 (file)
index 0000000..eda40b2
--- /dev/null
@@ -0,0 +1,143 @@
+/*
+ * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
+ *
+ * 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.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <sys/time.h>
+#include <unistd.h>
+
+#include "benchmark.h"
+
+FILE *fp;
+static double g_freq;
+
+static double calibrate_cpu_freq(void)
+{
+       int i, nb_calib = 10;
+       double freq;
+
+       printf("CPU frequency calibration, this should take 10 seconds\n");
+
+       /* CPU Frequency calibration */
+       for (i = 0; i < nb_calib; i++) {
+               freq += (double) get_cpu_freq();
+       }
+       return (freq / (double)nb_calib);
+}
+
+static void close_logs(void)
+{
+       fclose(fp);
+}
+
+static void open_logs(void)
+{
+       fp = fopen(RESULTS_FILE_NAME, "a");
+       if (fp == NULL) {
+               perror("fopen benchmark");
+       }
+}
+
+static double get_bench_time(cycles_t before, cycles_t after)
+{
+       double ret;
+
+       ret = (((double)(after - before) / (g_freq / 1000.0)) / 1000000000.0);
+
+       return ret;
+}
+
+void bench_init(void)
+{
+       open_logs();
+       if (g_freq == 0) {
+               g_freq = calibrate_cpu_freq();
+               //fprintf(fp, "CPU frequency %f Ghz\n\n", g_freq);
+       }
+}
+
+void bench_close(void)
+{
+       close_logs();
+       printf("Benchmark results in %s\n", RESULTS_FILE_NAME);
+}
+
+double bench_get_create_session(void)
+{
+       if ((time_create_session_start == 0) &&
+                       (time_create_session_end == 0)) {
+               fprintf(fp, "NO DATA\n");
+               return 0;
+       }
+
+       return get_bench_time(time_create_session_start, time_create_session_end);
+}
+
+double bench_get_destroy_session(void)
+{
+       if ((time_destroy_session_start == 0) &&
+                       (time_destroy_session_end == 0)) {
+               fprintf(fp, "NO DATA\n");
+               return 0;
+       }
+
+       return get_bench_time(time_destroy_session_start, time_destroy_session_end);
+}
+
+/*
+ * Log results of the sessiond boot process.
+ *
+ * Uses all time_sessiond_* values (see measures.h)
+ */
+void bench_print_boot_process(void)
+{
+       double res;
+       double global_boot_time = 0.0;
+
+       fprintf(fp, "--- Session daemon boot process ---\n");
+
+       res = get_bench_time(time_sessiond_boot_start, time_sessiond_boot_end);
+
+       fprintf(fp, "Boot time inside main() from start to first pthread_join (blocking state)\n");
+       fprintf(fp, "Time: %.20f sec.\n", res);
+
+       global_boot_time += res;
+
+       res = get_bench_time(time_sessiond_th_kern_start, time_sessiond_th_kern_poll);
+
+       fprintf(fp, "Boot time of the kernel thread from start to poll() (ready state)\n");
+       fprintf(fp, "Time: %.20f sec.\n", res);
+
+       global_boot_time += res;
+
+       res = get_bench_time(time_sessiond_th_apps_start, time_sessiond_th_apps_poll);
+
+       fprintf(fp, "Boot time of the application thread from start to poll() (ready state)\n");
+       fprintf(fp, "Time: %.20f sec.\n", res);
+
+       global_boot_time += res;
+
+       res = get_bench_time(time_sessiond_th_cli_start, time_sessiond_th_cli_poll);
+
+       fprintf(fp, "Boot time of the client thread from start to poll() (ready state)\n");
+       fprintf(fp, "Time: %.20f sec.\n", res);
+
+       global_boot_time += res;
+
+       fprintf(fp, "Global Boot Time of ltt-sessiond: %0.20f sec.\n", global_boot_time);
+}
diff --git a/benchmark/benchmark.h b/benchmark/benchmark.h
new file mode 100644 (file)
index 0000000..c02822e
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
+ *
+ * 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.
+ */
+
+#ifndef _BENCHMARK_H
+#define _BENCHMARK_H
+
+#include <stdint.h>
+#include <urcu/arch.h>
+
+#include "cpu.h"
+#include "measures.h"
+
+#define RESULTS_FILE_NAME "/tmp/lttng-bench-results.txt"
+
+extern FILE *fp;
+
+void bench_init(void);
+void bench_close(void);
+void bench_print_boot_process(void);
+double bench_get_create_session(void);
+double bench_get_destroy_session(void);
+
+#define record_cycles(name)             \
+       do {                                \
+               time_##name = get_cycles();     \
+       } while (0)
+
+#define tracepoint(name, args...)       \
+       do {                                \
+               record_cycles(name);            \
+       } while (0)
+
+#endif /* _BENCHMARK_H */
diff --git a/benchmark/cpu.c b/benchmark/cpu.c
new file mode 100644 (file)
index 0000000..02a8d99
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
+ *
+ * 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.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <sys/time.h>
+#include <unistd.h>
+
+#include "cpu.h"
+
+/*
+ * Return cpu cycle counter
+ */
+cycles_t get_cycles(void)
+{
+       return caa_get_cycles();
+}
+
+/*
+ * Calculate CPU frequency.
+ */
+uint64_t get_cpu_freq(void)
+{
+       struct timezone tz;
+       struct timeval tvstart, tvstop;
+       cycles_t c_before, c_after;
+       unsigned long microseconds;
+
+       memset(&tz, 0, sizeof(tz));
+
+       gettimeofday(&tvstart, &tz);
+       c_before = get_cycles();
+       gettimeofday(&tvstart, &tz);
+
+       sleep(1);
+
+       gettimeofday(&tvstop, &tz);
+       c_after = get_cycles();
+       gettimeofday(&tvstop, &tz);
+
+       microseconds = ((tvstop.tv_sec - tvstart.tv_sec) * 1000000) +
+               (tvstop.tv_usec - tvstart.tv_usec);
+
+       return (uint64_t) ((c_after - c_before) / microseconds);
+}
diff --git a/benchmark/cpu.h b/benchmark/cpu.h
new file mode 100644 (file)
index 0000000..799ccdf
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
+ *
+ * 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.
+ */
+
+#ifndef _CPU_H
+#define _CPU_H
+
+#include <stdint.h>
+#include <urcu/arch.h>
+
+uint64_t get_cpu_freq(void);
+cycles_t get_cycles(void);
+
+#endif /* _CPU_H */
diff --git a/benchmark/main.c b/benchmark/main.c
new file mode 100644 (file)
index 0000000..1c176f8
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
+ *
+ * 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.
+ */
+
+#include <string.h>
+#include <sys/time.h>
+#include <unistd.h>
+
+#include "benchmark.h"
+
+int main(int argc, char **argv)
+{
+       return 0;
+}
diff --git a/benchmark/measures.h b/benchmark/measures.h
new file mode 100644 (file)
index 0000000..f67f1c4
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
+ *
+ * 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.
+ */
+
+#ifndef _MEASURES_H
+#define _MEASURES_H
+
+/* Session daemon main() time */
+cycles_t time_sessiond_boot_start;
+cycles_t time_sessiond_boot_end;
+
+/* Session daemon thread manage kconsumerd time */
+cycles_t time_sessiond_th_kcon_start;
+cycles_t time_sessiond_th_kcon_poll;
+
+/* Session daemon thread manage kernel time */
+cycles_t time_sessiond_th_kern_start;
+cycles_t time_sessiond_th_kern_poll;
+
+/* Session daemon thread manage apps time */
+cycles_t time_sessiond_th_apps_start;
+cycles_t time_sessiond_th_apps_poll;
+
+/* Session daemon thread manage client time */
+cycles_t time_sessiond_th_cli_start;
+cycles_t time_sessiond_th_cli_poll;
+
+/* Create tracing session values */
+cycles_t time_create_session_start;
+cycles_t time_create_session_end;
+
+/* Destroy tracing session values */
+cycles_t time_destroy_session_start;
+cycles_t time_destroy_session_end;
+
+#endif /* _MEASURES_H */
diff --git a/benchmark/run-boot-time.sh b/benchmark/run-boot-time.sh
new file mode 100755 (executable)
index 0000000..dabb707
--- /dev/null
@@ -0,0 +1,51 @@
+#!/bin/bash
+#
+# Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
+#
+# 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="ltt-sessiond"
+RESULTS_PATH="/tmp/lttng-bench-results.txt"
+BASEDIR=`dirname $0`
+
+echo "Session daemon boot process benchmark"
+
+$BASEDIR/../ltt-sessiond/$SESSIOND_BIN --daemonize --quiet
+if [ $? -ne 0 ]; then
+       echo -e '\e[1;31mFAILED\e[0m'
+       exit 1
+else
+       echo -e "\e[1;32mOK\e[0m"
+fi
+
+PID_SESSIOND=`pidof lt-$SESSIOND_BIN`
+
+# Wait for the benchmark to run
+echo -n "Waiting."
+sleep 1
+echo -n "."
+sleep 1
+echo -n "."
+sleep 1
+
+kill $PID_SESSIOND
+
+echo -e "\nResults will be available shortly in $RESULTS_PATH"
+echo ""
+
+tail -F $RESULTS_PATH --pid $PID_SESSIOND 2>/dev/null
+
+exit 0
diff --git a/benchmark/run-sessions.sh b/benchmark/run-sessions.sh
new file mode 100755 (executable)
index 0000000..6db0c85
--- /dev/null
@@ -0,0 +1,28 @@
+#!/bin/bash
+#
+# Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
+#
+# 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.
+#
+
+RESULTS_PATH="/tmp/lttng-bench-results.txt"
+BASEDIR=`dirname $0`
+NR_ITER=100
+
+echo "Create/Destroy benchmarking..."
+
+$BASEDIR/bench_sessions $NR_ITER
+
+exit 0
diff --git a/benchmark/runall.sh b/benchmark/runall.sh
new file mode 100755 (executable)
index 0000000..eaf4980
--- /dev/null
@@ -0,0 +1,49 @@
+#!/bin/bash
+#
+# Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
+#
+# 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.
+#
+
+#### ADD TESTS HERE ####
+
+test_suite=( "run-boot-time.sh" "run-sessions.sh" )
+
+#### END TESTS HERE ####
+
+RESULTS_PATH="/tmp/lttng-bench-results.txt"
+BASEDIR=`dirname $0`
+
+if [ -e $RESULTS_PATH ]; then
+       mv -v $RESULTS_PATH $RESULTS_PATH.`date +%s`
+fi
+
+echo ""
+
+for bin in ${test_suite[@]};
+do
+       $BASEDIR/$bin
+       # Test must return 0 to pass.
+       if [ $? -ne 0 ]; then
+               echo -e '\e[1;31mFAIL\e[0m'
+               echo ""
+               exit 1
+       fi
+       echo ""
+done
+
+mv -v $RESULTS_PATH results-`date +%d%m%Y.%H%M%S`.txt
+
+exit 0
diff --git a/benchmark/utils.h b/benchmark/utils.h
new file mode 100644 (file)
index 0000000..52893b2
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c)  2011 David Goulet <david.goulet@polymtl.ca>
+ *
+ * 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
+ * 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <stdio.h>
+
+#define BRIGHT 1
+#define GREEN 32
+#define RED 31
+
+#define PRINT_OK() printf("%c[%d;%dmOK%c[%dm\n", 0x1B, BRIGHT, GREEN, 0x1B, 0);
+#define PRINT_FAIL() printf("%c[%d;%dmFAIL%c[%dm\n", 0x1B, BRIGHT, RED, 0x1B, 0);
index 066c4e20e3cc5ed293ca631428f86683c4294a78..7af39997a47de01d8e0488757da01b23bcbd9fc1 100644 (file)
@@ -27,6 +27,11 @@ AC_CHECK_DECL([cds_list_add], [],
        [AC_MSG_ERROR([liburcu 0.5.4 or newer is needed])], [[#include <urcu/list.h>]]
 )
 
+# Check liburcu
+AC_CHECK_DECL([caa_get_cycles], [],
+       [AC_MSG_ERROR([liburcu 0.5.4 or newer is needed])], [[#include <urcu/arch.h>]]
+)
+
 AC_PROG_CC
 AC_PROG_LIBTOOL
 
@@ -42,6 +47,7 @@ AC_SUBST(DEFAULT_INCLUDES)
 AC_CONFIG_FILES([
        Makefile
        include/Makefile
+       benchmark/Makefile
        libkernelctl/Makefile
        liblttngkconsumerd/Makefile
        liblttngctl/Makefile
index 80c6b81e287a3135aea47cddab3029f392b866e3..93af21fa30eb84d5e9dd70661c34dd7ce4283da3 100644 (file)
@@ -1,5 +1,5 @@
-AM_CPPFLAGS = -I$(top_srcdir)/include \
-                         -DINSTALL_BIN_PATH=\""$(bindir)"\"
+AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/benchmark \
+                         -DINSTALL_BIN_PATH=\"$(bindir)\"
 
 AM_CFLAGS = -fno-strict-aliasing
 
@@ -15,4 +15,5 @@ ltt_sessiond_LDADD = \
                 $(top_builddir)/liblttng-sessiond-comm/liblttng-sessiond-comm.la \
                 $(top_builddir)/libkernelctl/libkernelctl.la \
                 $(top_builddir)/libustctl/libustctl.la \
-                $(top_builddir)/liblttngctl/liblttngctl.la
+                $(top_builddir)/liblttngctl/liblttngctl.la \
+                $(top_builddir)/benchmark/liblttng-benchmark.la
index dd9f221de58b9d53c111f2729d50c9317af00e2d..78682f3a4eeeb27d318e5ad931b1c0f79b8e4bc6 100644 (file)
@@ -48,6 +48,8 @@
 #include "ust-ctl.h"
 #include "utils.h"
 
+#include "benchmark.h"
+
 /* Const values */
 const char default_home_dir[] = DEFAULT_HOME_DIR;
 const char default_tracing_group[] = LTTNG_DEFAULT_TRACING_GROUP;
@@ -225,6 +227,14 @@ static void cleanup(void)
 
        DBG("Unloading kernel modules");
        modprobe_remove_kernel_modules();
+
+       /* OUTPUT BENCHMARK RESULTS */
+       bench_init();
+
+       bench_print_boot_process();
+
+       bench_close();
+       /* END BENCHMARK */
 }
 
 /*
@@ -610,6 +620,8 @@ static void *thread_manage_kernel(void *data)
        char tmp;
        int update_poll_flag = 1;
 
+       tracepoint(sessiond_th_kern_start);
+
        DBG("Thread manage kernel started");
 
        while (1) {
@@ -623,6 +635,8 @@ static void *thread_manage_kernel(void *data)
 
                DBG("Polling on %d fds", nb_fd);
 
+               tracepoint(sessiond_th_kern_poll);
+
                /* Poll infinite value of time */
                ret = poll(kernel_pollfd, nb_fd, -1);
                if (ret < 0) {
@@ -691,6 +705,8 @@ static void *thread_manage_kconsumerd(void *data)
        enum lttcomm_return_code code;
        struct pollfd pollfd[2];
 
+       tracepoint(sessiond_th_kcon_start);
+
        DBG("[thread] Manage kconsumerd started");
 
        ret = lttcomm_listen_unix_sock(kconsumerd_err_sock);
@@ -705,6 +721,8 @@ static void *thread_manage_kconsumerd(void *data)
        pollfd[1].fd = kconsumerd_err_sock;
        pollfd[1].events = POLLIN;
 
+       tracepoint(sessiond_th_kcon_poll);
+
        /* Inifinite blocking call, waiting for transmission */
        ret = poll(pollfd, 2, -1);
        if (ret < 0) {
@@ -802,6 +820,8 @@ static void *thread_manage_apps(void *data)
        int sock = 0, ret;
        struct pollfd pollfd[2];
 
+       tracepoint(sessiond_th_apps_start);
+
        /* TODO: Something more elegant is needed but fine for now */
        /* FIXME: change all types to either uint8_t, uint32_t, uint64_t
         * for 32-bit vs 64-bit compat processes. */
@@ -832,6 +852,8 @@ static void *thread_manage_apps(void *data)
        while (1) {
                DBG("Accepting application registration");
 
+               tracepoint(sessiond_th_apps_poll);
+
                /* Inifinite blocking call, waiting for transmission */
                ret = poll(pollfd, 2, -1);
                if (ret < 0) {
@@ -2051,7 +2073,9 @@ static int process_client_msg(struct command_ctx *cmd_ctx)
                        goto setup_error;
                }
 
+               tracepoint(create_session_start);
                ret = create_session(cmd_ctx->lsm->session.name, cmd_ctx->lsm->session.path);
+               tracepoint(create_session_end);
                if (ret < 0) {
                        if (ret == -EEXIST) {
                                ret = LTTCOMM_EXIST_SESS;
@@ -2075,7 +2099,9 @@ static int process_client_msg(struct command_ctx *cmd_ctx)
                /* Clean kernel session teardown */
                teardown_kernel_session(cmd_ctx->session);
 
+               tracepoint(destroy_session_start);
                ret = destroy_session(cmd_ctx->lsm->session.name);
+               tracepoint(destroy_session_end);
                if (ret < 0) {
                        ret = LTTCOMM_FATAL;
                        goto error;
@@ -2311,6 +2337,8 @@ static void *thread_manage_clients(void *data)
        struct command_ctx *cmd_ctx = NULL;
        struct pollfd pollfd[2];
 
+       tracepoint(sessiond_th_cli_start);
+
        DBG("[thread] Manage client started");
 
        ret = lttcomm_listen_unix_sock(client_sock);
@@ -2335,6 +2363,8 @@ static void *thread_manage_clients(void *data)
        while (1) {
                DBG("Accepting client command ...");
 
+               tracepoint(sessiond_th_cli_poll);
+
                /* Inifinite blocking call, waiting for transmission */
                ret = poll(pollfd, 2, -1);
                if (ret < 0) {
@@ -2804,6 +2834,8 @@ int main(int argc, char **argv)
        void *status;
        const char *home_path;
 
+       tracepoint(sessiond_boot_start);
+
        /* Create thread quit pipe */
        if ((ret = init_thread_quit_pipe()) < 0) {
                goto error;
@@ -2950,6 +2982,8 @@ int main(int argc, char **argv)
                goto exit_kernel;
        }
 
+       tracepoint(sessiond_boot_end);
+
        ret = pthread_join(kernel_thread, &status);
        if (ret != 0) {
                perror("pthread_join");
This page took 0.037103 seconds and 4 git commands to generate.