Commit b805a4a5 authored by Rich Prohaska's avatar Rich Prohaska

add a in memory trace log with processor timestamps. closes #1042

git-svn-id: file:///svn/tokudb@5318 c7de825b-a66e-492c-adef-691d508d4ae1
parent d245cafe
......@@ -72,6 +72,7 @@ BRT_SOURCES = \
roll \
toku_assert \
ybt \
trace_mem \
# keep this line so I can ha vea \ on the previous line
OFILES = newbrt.o
......
#include <stdio.h>
#include "../include/rdtsc.h"
// customize this as required
#define NTRACE 1000
#if NTRACE
static struct toku_trace {
const char *str;
int n;
unsigned long long ts;
} toku_trace[NTRACE];
static int toku_next_trace = 0;
#endif
void toku_add_trace_mem(const char *str, int n) __attribute__((__visibility__("default")));
void toku_add_trace_mem(const char *str __attribute__((unused)),
int n __attribute__((unused))) {
#if USE_RDTSC && NTRACE
int i = toku_next_trace++;
if (toku_next_trace >= NTRACE) toku_next_trace = 0;
toku_trace[i].ts = rdtsc();
toku_trace[i].str = str;
toku_trace[i].n = n;
#endif
}
void toku_print_trace_mem() __attribute__((__visibility__("default")));
void toku_print_trace_mem() {
#if NTRACE
int i = toku_next_trace;
do {
if (toku_trace[i].str)
printf("%llu %s:%d\n", toku_trace[i].ts, toku_trace[i].str, toku_trace[i].n);
i++;
if (i >= NTRACE) i = 0;
} while (i != toku_next_trace);
#endif
}
// a circular log of trace entries is maintained in memory. the trace
// entry consists of a string pointer, an integer, and the processor
// timestamp. there are functions to add an entry to the end of the
// trace log, and to print the trace log.
// example: one can use the __FUNCTION__ and __LINE__ macros as
// the arguments to the toku_add_trace function.
// performance: we trade speed for size by not compressing the trace
// entries.
void toku_add_trace_mem(const char *str, int n);
// add an entry to the end of the trace which consists of a string
// pointer, a number, and the processor timestamp
void toku_print_trace_mem();
// print the trace
......@@ -13,6 +13,9 @@
toku_set_trace_file;
toku_close_trace_file;
toku_add_trace_mem;
toku_print_trace_mem;
local: *;
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment