Commit bc7a6ba9 authored by Rich Prohaska's avatar Rich Prohaska Committed by Yoni Fogel

#4869 remove trace_mem since it is not used and it can easily be resurrected if needed refs[t:4869]

git-svn-id: file:///svn/toku/tokudb@43536 c7de825b-a66e-492c-adef-691d508d4ae1
parent 6b0c64e3
......@@ -61,7 +61,6 @@ set(BRT_SOURCES
sub_block.c
ule.c
threadpool.c
trace_mem.c
txn.c
workqueue.c
x1764.c
......
......@@ -21,18 +21,11 @@
#include "sub_block.h"
#include "sub_block_map.h"
#include "pqueue.h"
#include "trace_mem.h"
#include "dbufio.h"
#include "leafentry.h"
#include "log-internal.h"
#include "brt_header.h"
// to turn on tracing,
// cd .../newbrt
// edit trace_mem.h, set #define BL_DO_TRACE 1
// make local
// cd ../src;make local
#if defined(__cilkplusplus)
#error DISABLING CILK ARTS CILK
#endif
......@@ -498,12 +491,6 @@ int toku_brt_loader_internal_init (/* out */ BRTLOADER *blp,
BRTLOADER CALLOC(bl); // initialized to all zeros (hence CALLOC)
if (!bl) return errno;
#if BL_DO_TRACE
BL_TRACE(blt_calibrate_begin);
sleep(1);
BL_TRACE(blt_calibrate_done);
#endif
bl->generate_row_for_put = g;
bl->cachetable = cachetable;
if (bl->cachetable)
......@@ -634,7 +621,6 @@ int toku_brt_loader_open (/* out */ BRTLOADER *blp,
(void) toku_brtloader_internal_destroy(bl, TRUE);
}
}
BL_TRACE(blt_open);
return result;
}
......@@ -966,15 +952,12 @@ static int finish_primary_rows (BRTLOADER bl) {
}
static void* extractor_thread (void *blv) {
BL_TRACE(blt_extractor_init);
BRTLOADER bl = (BRTLOADER)blv;
int r = 0;
while (1) {
void *item;
{
BL_TRACE(blt_extractor);
int rq = queue_deq(bl->primary_rowset_queue, &item, NULL, NULL);
BL_TRACE(blt_extract_deq);
if (rq==EOF) break;
invariant(rq==0); // other errors are arbitrarily bad.
}
......@@ -997,7 +980,6 @@ static void* extractor_thread (void *blv) {
brt_loader_set_panic(bl, r, FALSE);
}
BL_TRACE(blt_extractor);
return NULL;
}
......@@ -1019,9 +1001,7 @@ static int loader_do_put(BRTLOADER bl,
if (result == 0 && row_wont_fit(&bl->primary_rowset, 0)) {
// queue the rows for further processing by the extractor thread.
//printf("%s:%d please extract %ld\n", __FILE__, __LINE__, bl->primary_rowset.n_rows);
BL_TRACE(blt_do_put);
enqueue_for_extraction(bl);
BL_TRACE(blt_extract_enq);
{
int r = init_rowset(&bl->primary_rowset, memory_per_rowset_during_extract(bl));
// bl->primary_rowset will get destroyed by toku_brt_loader_abort
......@@ -1038,10 +1018,8 @@ finish_extractor (BRTLOADER bl) {
int rval;
BL_TRACE(blt_do_put);
if (bl->primary_rowset.n_rows>0) {
enqueue_for_extraction(bl);
BL_TRACE(blt_extract_enq);
} else {
destroy_rowset(&bl->primary_rowset);
}
......@@ -1057,7 +1035,6 @@ finish_extractor (BRTLOADER bl) {
resource_assert_zero(r);
invariant(toku_pthread_retval == NULL);
bl->extractor_live = FALSE;
BL_TRACE(blt_join_on_extractor);
}
{
int r = queue_destroy(bl->primary_rowset_queue);
......@@ -1161,10 +1138,8 @@ static int process_primary_rows_internal (BRTLOADER bl, struct rowset *primary_r
if (row_wont_fit(rows, skey.size + sval.size)) {
//printf("%s:%d rows.n_rows=%ld rows.n_bytes=%ld\n", __FILE__, __LINE__, rows->n_rows, rows->n_bytes);
BL_TRACE(blt_extractor);
int r = sort_and_write_rows(*rows, fs, bl, i, bl->dbs[i], compare); // cannot spawn this because of the race on rows. If we were to create a new rows, and if sort_and_write_rows were to destroy the rows it is passed, we could spawn it, however.
// If we do spawn this, then we must account for the additional storage in the memory_per_rowset() function.
BL_TRACE(blt_sort_and_write_rows);
init_rowset(rows, memory_per_rowset_during_extract(bl)); // we passed the contents of rows to sort_and_write_rows.
if (r != 0) {
error_codes[i] = r;
......@@ -1213,14 +1188,11 @@ static int process_primary_rows_internal (BRTLOADER bl, struct rowset *primary_r
invariant(r); // found the error
}
toku_free(error_codes);
BL_TRACE(blt_extractor);
return r;
}
static int process_primary_rows (BRTLOADER bl, struct rowset *primary_rowset) {
BL_TRACE(blt_extractor);
int r = process_primary_rows_internal (bl, primary_rowset);
BL_TRACE(blt_extractor);
return r;
}
......@@ -1648,9 +1620,7 @@ int toku_merge_some_files_using_dbufio (const BOOL to_q, FIDX dest_data, QUEUE q
if (result==0) {
// load pqueue with first value from each source
for (int i=0; i<n_sources; i++) {
BL_TRACE_QUIET(blt_do_i);
int r = loader_read_row_from_dbufio(bfs, i, &keys[i], &vals[i]);
BL_TRACE_QUIET(blt_read_row);
if (r==EOF) continue; // if the file is empty, don't initialize the pqueue.
if (r!=0) {
result = r;
......@@ -1699,10 +1669,8 @@ int toku_merge_some_files_using_dbufio (const BOOL to_q, FIDX dest_data, QUEUE q
}
if (to_q) {
if (row_wont_fit(output_rowset, keys[mini].size + vals[mini].size)) {
BL_TRACE(blt_do_i);
{
int r = queue_enq(q, (void*)output_rowset, 1, NULL);
BL_TRACE(blt_fractal_enq);
if (r!=0) {
result = r;
break;
......@@ -1735,9 +1703,7 @@ int toku_merge_some_files_using_dbufio (const BOOL to_q, FIDX dest_data, QUEUE q
{
// read next row from file that just sourced min value
BL_TRACE_QUIET(blt_do_i);
int r = loader_read_row_from_dbufio(bfs, mini, &keys[mini], &vals[mini]);
BL_TRACE_QUIET(blt_read_row);
if (r!=0) {
if (r==EOF) {
// on feof, queue size permanently smaller
......@@ -1776,9 +1742,7 @@ int toku_merge_some_files_using_dbufio (const BOOL to_q, FIDX dest_data, QUEUE q
}
}
if (result==0 && to_q) {
BL_TRACE(blt_do_i);
int r = queue_enq(q, (void*)output_rowset, 1, NULL);
BL_TRACE(blt_fractal_enq);
if (r!=0)
result = r;
else
......@@ -2308,9 +2272,7 @@ static int toku_loader_write_brt_from_q (BRTLOADER bl,
while (result == 0) {
void *item;
{
BL_TRACE(blt_fractal_thread);
int rr = queue_deq(q, &item, NULL, NULL);
BL_TRACE(blt_fractal_deq);
if (rr == EOF) break;
if (rr != 0) {
brt_loader_set_panic(bl, rr, TRUE); // error after cilk sync
......@@ -2482,7 +2444,6 @@ static int toku_loader_write_brt_from_q (BRTLOADER bl,
subtrees_info_destroy(&sts);
dbout_destroy(&out);
drain_writer_q(q);
BL_TRACE(blt_fractal_thread);
return result;
}
......@@ -2506,7 +2467,6 @@ int toku_loader_write_brt_from_q_in_C (BRTLOADER bl,
static void* fractal_thread (void *ftav) {
BL_TRACE(blt_start_fractal_thread);
struct fractal_thread_args *fta = (struct fractal_thread_args *)ftav;
int r = toku_loader_write_brt_from_q (fta->bl, fta->descriptor, fta->fd, fta->progress_allocation, fta->q, fta->total_disksize_estimate, fta->which_db, fta->target_nodesize, fta->target_basementnodesize, fta->target_compression_method);
fta->errno_result = r;
......@@ -2580,10 +2540,8 @@ static int loader_do_i (BRTLOADER bl,
{
void *toku_pthread_retval;
BL_TRACE(blt_do_i);
int r2 = toku_pthread_join(bl->fractal_threads[which_db], &toku_pthread_retval);
invariant(fta.bl==bl); // this is a gratuitous assertion to make sure that the fta struct is still live here. A previous bug but that struct into a C block statement.
BL_TRACE(blt_join_on_fractal);
resource_assert_zero(r2);
invariant(toku_pthread_retval==NULL);
invariant(bl->fractal_threads_live[which_db]);
......@@ -2603,7 +2561,6 @@ static int loader_do_i (BRTLOADER bl,
toku_free(rows->data); rows->data = NULL;
toku_free(rows->rows); rows->rows = NULL;
toku_free(fs->data_fidxs); fs->data_fidxs = NULL;
BL_TRACE(blt_do_i);
return r;
}
......@@ -2611,7 +2568,6 @@ static int toku_brt_loader_close_internal (BRTLOADER bl)
/* Effect: Close the bulk loader.
* Return all the file descriptors in the array fds. */
{
BL_TRACE(blt_do_put);
int result = 0;
if (bl->N == 0)
result = update_progress(PROGRESS_MAX, bl, "done");
......@@ -2622,7 +2578,6 @@ static int toku_brt_loader_close_internal (BRTLOADER bl)
// This calculation allocates all of the PROGRESS_MAX bits of progress to some job.
int allocate_here = remaining_progress/(bl->N - i);
remaining_progress -= allocate_here;
BL_TRACE(blt_close);
char *fname_in_cwd = toku_cachetable_get_fname_in_cwd(bl->cachetable, bl->new_fnames_in_env[i]);
result = loader_do_i(bl, i, bl->dbs[i], bl->bt_compare_funs[i], bl->descriptors[i], fname_in_cwd, allocate_here);
toku_free(fname_in_cwd);
......@@ -2645,8 +2600,6 @@ static int toku_brt_loader_close_internal (BRTLOADER bl)
invariant(bl->progress == PROGRESS_MAX);
error:
toku_brtloader_internal_destroy(bl, (BOOL)(result!=0));
BL_TRACE(blt_close);
BL_TRACE_END;
return result;
}
......
......@@ -4,7 +4,6 @@
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."
#include "includes.h"
#include "trace_mem.h"
static const int log_format_version=TOKU_LOG_VERSION;
......@@ -781,13 +780,11 @@ int toku_logger_maybe_fsync (TOKULOGGER logger, LSN lsn, int do_fsync)
write_outbuf_to_logfile(logger, &fsynced_lsn);
if (fsynced_lsn.lsn < lsn.lsn) {
// it may have gotten fsynced by the write_outbuf_to_logfile.
toku_add_trace_mem("fsync", __LINE__);
r = toku_file_fsync_without_accounting(logger->fd);
if (r!=0) {
toku_logger_panic(logger, r);
return r;
}
toku_add_trace_mem("fsyncdone", __LINE__);
assert(fsynced_lsn.lsn <= logger->written_lsn.lsn);
fsynced_lsn = logger->written_lsn;
}
......
#ident "$Id$"
#ident "Copyright (c) 2007-2010 Tokutek Inc. All rights reserved."
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."
#include <toku_portability.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include "rdtsc.h"
#include "trace_mem.h"
// customize this as required
#define NTRACE 0
#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 *UU(str), int UU(n)) {
#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(FILE *UU(out)) {
#if NTRACE
int i = toku_next_trace;
do {
if (toku_trace[i].str)
fprintf(out, "%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
}
#if BL_DO_TRACE && BL_SIMPLE_TRACE
static double saved_scale_factor = 1e-9; // approximate until we get the actual scale factor
static unsigned long long first_time = 0;
static __thread unsigned long long prev_time = 0;
static unsigned long long trace_hist[BLT_LIMIT];
unsigned long long bl_trace (const BL_TRACE_ENUM l, const int quiet) {
assert(l<BLT_LIMIT);
unsigned long long t = rdtsc();
if (first_time==0) {
first_time = t;
}
if (prev_time != 0) {
unsigned long long diff = t-prev_time;
if (l==blt_calibrate_done) {
saved_scale_factor = 1/(double)diff;
}
if (!quiet)
printf("-> %30s %21llu %21llu %13.6fs\n", blt_to_string(l), trace_hist[l], t, (t-first_time)*saved_scale_factor);
trace_hist[l] += diff;
}
prev_time = t;
return t;
}
bl_time_t bl_time_now(void) {
return rdtsc();
}
double bl_time_diff(const bl_time_t a, const bl_time_t b) {
return (a-b)*saved_scale_factor;
}
void bl_trace_end(void) {
double scale_factor = trace_hist[blt_calibrate_done];
unsigned long long total = 0;
for (BL_TRACE_ENUM i=0; i<BLT_LIMIT; i++) {
total+=trace_hist[i];
}
for (BL_TRACE_ENUM i=0; i<BLT_LIMIT; i++) {
printf("%25s %20lld %8.3fs %5.1f%%\n", blt_to_string(i), trace_hist[i], trace_hist[i]/scale_factor, 100.0*trace_hist[i]/(double)total);
}
}
#elif BL_DO_TRACE && !BL_SIMPLE_TRACE
/*
* Some trace functions (similar) added for the bulk loader
*/
#define BL_TRACE_MAX_ENTRIES 1000000
#if BL_DO_TRACE
static struct bl_trace_s {
const char *str;
const char *func;
int line;
int tid;
unsigned long long ts;
} bl_traces[BL_TRACE_MAX_ENTRIES];
static int bl_next_trace = 0;
static FILE* bltrace_fp = NULL;
#endif
void bl_trace(const char *func __attribute__((unused)),
int line __attribute__((unused)),
const char *str __attribute__((unused)))
{
#if BL_DO_TRACE
if ( bl_next_trace < BL_TRACE_MAX_ENTRIES ) {
bl_traces[bl_next_trace].ts = rdtsc();
bl_traces[bl_next_trace].str = str;
bl_traces[bl_next_trace].func = func;
bl_traces[bl_next_trace].line = line;
bl_traces[bl_next_trace].tid = toku_os_gettid();
bl_next_trace++;
}
#if BL_TRACE_PRINT
{
int i=bl_next_trace - 1;
printf("%10d %5d %20llu %s:%d %s\n",
i,
bl_traces[i].tid,
bl_traces[i].ts,
bl_traces[i].func,
bl_traces[i].line,
bl_traces[i].str);
}
#endif
#endif
}
void bl_trace_end(void)
{
#error
#if BL_DO_TRACE
char bltracefile[128];
sprintf(bltracefile, "brtloader_%d.trace", toku_os_getpid());;
printf("brtloader_%d.trace", toku_os_getpid());
bltrace_fp = fopen(bltracefile, "w");
assert(bltrace_fp != NULL);
for (int i=0;i<bl_next_trace;i++) {
fprintf(bltrace_fp, "%10d %5d %20llu %s:%d %s\n",
i,
bl_traces[i].tid,
bl_traces[i].ts,
bl_traces[i].func,
bl_traces[i].line,
bl_traces[i].str);
}
fclose(bltrace_fp);
#endif
}
#endif
#ifndef _TOKU_TRACE_MEM_H
#define _TOKU_TRACE_MEM_H
#ident "$Id$"
#ident "Copyright (c) 2007-2010 Tokutek Inc. All rights reserved."
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."
#if defined(__cplusplus) || defined(__cilkplusplus)
extern "C" {
#endif
// Define this even when traces are compiled out so we don't have to recompile things like scanscan.c
// print the trace
void toku_print_trace_mem(FILE *) __attribute__((__visibility__("default")));
// add an entry to the end of the trace which consists of a string pointer, a number, and the processor timestamp
void toku_add_trace_mem(const char *str, int n) __attribute__((__visibility__("default")));
#define BL_DO_TRACE 0
// BL_SIMPLE_TRACE 1 is Bradley's in-memory trace analysis.
// BL_SIMPLE_TRACE 0 is Dave's post-processing analysis.
#define BL_SIMPLE_TRACE 1
#define BL_TRACE_PRINT 0
#if BL_DO_TRACE && !BL_SIMPLE_TRACE
// 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.
// some trace functions added for the bulk loader
void bl_trace(const char *func __attribute__((unused)),
int line __attribute__ ((unused)),
const char *str __attribute__((unused)))
__attribute__((unused));
void bl_trace_end(void) __attribute__((unused));
#define BL_TRACE(sym) bl_trace(__FUNCTION__, __LINE__, #sym)
#define BL_TRACE_END bl_trace_end()
#elif BL_DO_TRACE && BL_SIMPLE_TRACE
typedef enum bl_trace_enum {BLT_START,
blt_calibrate_begin,
blt_calibrate_done,
blt_open,
// Time spent in the extractor
blt_extractor_init,
blt_extractor,
blt_extract_deq,
blt_sort_and_write_rows,
// Time spent by the main thread in parallel to the extractor
blt_do_put,
blt_extract_enq,
blt_join_on_extractor,
// Time spent in the fractal thread
blt_fractal_thread,
blt_fractal_deq,
// Time spent by the main thread in parallel to the fractal thread
blt_start_fractal_thread,
blt_do_i,
blt_read_row,
blt_fractal_enq,
blt_join_on_fractal,
blt_close,
//
BLT_LIMIT}
BL_TRACE_ENUM;
static const char * blt_to_string (BL_TRACE_ENUM) __attribute__((__unused__));
#define BLSCASE(s) case s: return #s
static const char * blt_to_string (BL_TRACE_ENUM i) {
switch(i) {
BLSCASE(BLT_START);
BLSCASE(blt_calibrate_begin);
BLSCASE(blt_calibrate_done);
BLSCASE(blt_close);
BLSCASE(blt_do_i);
BLSCASE(blt_do_put);
BLSCASE(blt_extract_deq);
BLSCASE(blt_extract_enq);
BLSCASE(blt_extractor);
BLSCASE(blt_extractor_init);
BLSCASE(blt_fractal_deq);
BLSCASE(blt_fractal_enq);
BLSCASE(blt_fractal_thread);
BLSCASE(blt_join_on_extractor);
BLSCASE(blt_join_on_fractal);
BLSCASE(blt_open);
BLSCASE(blt_read_row);
BLSCASE(blt_sort_and_write_rows);
BLSCASE(blt_start_fractal_thread);
BLSCASE(BLT_LIMIT);
}
return NULL;
}
typedef unsigned long long bl_time_t;
bl_time_t bl_trace(const BL_TRACE_ENUM, const int quiet);
bl_time_t bl_time_now(void);
double bl_time_diff(const bl_time_t a, const bl_time_t b);
void bl_trace_end(void);
#define BL_TRACE(sym) bl_trace(sym, 0)
#if 0
#define BL_TRACE_QUIET(sym) bl_trace(sym, 1)
#else
#define BL_TRACE_QUIET(sym)
#endif
#define BL_TRACE_END bl_trace_end()
#else
#define BL_TRACE(sym)
#define BL_TRACE_FROM(sym,q,t)
#define BL_TRACE_QUIET(sym)
#define BL_TRACE_FROM_QUIET(sym,q,t)
#define BL_TRACE_END
#endif
#if defined(__cplusplus) || defined(__cilkplusplus)
};
#endif
#endif
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