mirror of
https://github.com/MariaDB/server.git
synced 2025-01-22 06:44:16 +01:00
closes #5758 add --translation-table and --fragmentation as cli args to ftdump, use TSV for output for both commands
git-svn-id: file:///svn/toku/tokudb@50827 c7de825b-a66e-492c-adef-691d508d4ae1
This commit is contained in:
parent
e04dfafca1
commit
71bbfc5f03
3 changed files with 50 additions and 16 deletions
|
@ -732,6 +732,19 @@ dump_translation(FILE *f, struct translation *t) {
|
||||||
else fprintf(f, " does not exist\n");
|
else fprintf(f, " does not exist\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Only used by toku_ft_dump which is only for debugging purposes
|
||||||
|
// "pretty" just means we use tabs so we can parse output easier later
|
||||||
|
void
|
||||||
|
toku_dump_translation_table_pretty(FILE *f, BLOCK_TABLE bt) {
|
||||||
|
lock_for_blocktable(bt);
|
||||||
|
struct translation *t = &bt->checkpointed;
|
||||||
|
assert(t->block_translation != nullptr);
|
||||||
|
for (int64_t i = 0; i < t->length_of_array; ++i) {
|
||||||
|
fprintf(f, "%" PRId64 "\t%" PRId64 "\t%" PRId64 "\n", i, t->block_translation[i].u.diskoff, t->block_translation[i].size);
|
||||||
|
}
|
||||||
|
unlock_for_blocktable(bt);
|
||||||
|
}
|
||||||
|
|
||||||
//Only used by toku_ft_dump which is only for debugging purposes
|
//Only used by toku_ft_dump which is only for debugging purposes
|
||||||
void
|
void
|
||||||
toku_dump_translation_table(FILE *f, BLOCK_TABLE bt) {
|
toku_dump_translation_table(FILE *f, BLOCK_TABLE bt) {
|
||||||
|
|
|
@ -56,6 +56,7 @@ void toku_block_table_swap_for_redirect(BLOCK_TABLE old_bt, BLOCK_TABLE new_bt);
|
||||||
|
|
||||||
//DEBUG ONLY (ftdump included), tests included
|
//DEBUG ONLY (ftdump included), tests included
|
||||||
void toku_blocknum_dump_translation(BLOCK_TABLE bt, BLOCKNUM b);
|
void toku_blocknum_dump_translation(BLOCK_TABLE bt, BLOCKNUM b);
|
||||||
|
void toku_dump_translation_table_pretty(FILE *f, BLOCK_TABLE bt);
|
||||||
void toku_dump_translation_table(FILE *f, BLOCK_TABLE bt);
|
void toku_dump_translation_table(FILE *f, BLOCK_TABLE bt);
|
||||||
void toku_block_free(BLOCK_TABLE bt, uint64_t offset);
|
void toku_block_free(BLOCK_TABLE bt, uint64_t offset);
|
||||||
typedef int(*BLOCKTABLE_CALLBACK)(BLOCKNUM b, int64_t size, int64_t address, void *extra);
|
typedef int(*BLOCKTABLE_CALLBACK)(BLOCKNUM b, int64_t size, int64_t address, void *extra);
|
||||||
|
|
52
ft/ftdump.cc
52
ft/ftdump.cc
|
@ -92,13 +92,18 @@ dump_descriptor(DESCRIPTOR d) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dump_header (int f, FT *header, CACHEFILE cf) {
|
open_header (int f, FT *header, CACHEFILE cf) {
|
||||||
FT ft = NULL;
|
FT ft = NULL;
|
||||||
int r;
|
int r;
|
||||||
char timestr[26];
|
|
||||||
r = toku_deserialize_ft_from (f, MAX_LSN, &ft);
|
r = toku_deserialize_ft_from (f, MAX_LSN, &ft);
|
||||||
assert(r==0);
|
assert(r==0);
|
||||||
ft->cf = cf;
|
ft->cf = cf;
|
||||||
|
*header = ft;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
dump_header(FT ft) {
|
||||||
|
char timestr[26];
|
||||||
printf("ft:\n");
|
printf("ft:\n");
|
||||||
printf(" layout_version=%d\n", ft->h->layout_version);
|
printf(" layout_version=%d\n", ft->h->layout_version);
|
||||||
printf(" layout_version_original=%d\n", ft->h->layout_version_original);
|
printf(" layout_version_original=%d\n", ft->h->layout_version_original);
|
||||||
|
@ -120,7 +125,6 @@ dump_header (int f, FT *header, CACHEFILE cf) {
|
||||||
dump_descriptor(&ft->descriptor);
|
dump_descriptor(&ft->descriptor);
|
||||||
printf(" estimated numrows=%" PRId64 "\n", ft->in_memory_stats.numrows);
|
printf(" estimated numrows=%" PRId64 "\n", ft->in_memory_stats.numrows);
|
||||||
printf(" estimated numbytes=%" PRId64 "\n", ft->in_memory_stats.numbytes);
|
printf(" estimated numbytes=%" PRId64 "\n", ft->in_memory_stats.numbytes);
|
||||||
*header = ft;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -233,10 +237,10 @@ dump_fragmentation(int UU(f), FT h) {
|
||||||
toku_blocktable_internal_fragmentation(h->blocktable, &total_space, &used_space);
|
toku_blocktable_internal_fragmentation(h->blocktable, &total_space, &used_space);
|
||||||
int64_t fragsizes = total_space - used_space;
|
int64_t fragsizes = total_space - used_space;
|
||||||
|
|
||||||
printf("used size: %" PRId64 "\n", used_space);
|
printf("used_size\t%" PRId64 "\n", used_space);
|
||||||
printf("total size: %" PRId64 "\n", total_space);
|
printf("total_size\t%" PRId64 "\n", total_space);
|
||||||
printf("fragsizes: %" PRId64 "\n", fragsizes);
|
printf("fragsizes\t%" PRId64 "\n", fragsizes);
|
||||||
printf("fragmentation: %.1f%%\n", 100. * ((double)fragsizes / (double)(total_space)));
|
printf("fragmentation\t%.1f\n", 100. * ((double)fragsizes / (double)(total_space)));
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -275,9 +279,9 @@ dump_nodesizes(int f, FT h) {
|
||||||
info.h = h;
|
info.h = h;
|
||||||
toku_blocktable_iterate(h->blocktable, TRANSLATION_CHECKPOINTED,
|
toku_blocktable_iterate(h->blocktable, TRANSLATION_CHECKPOINTED,
|
||||||
nodesizes_helper, &info, true, true);
|
nodesizes_helper, &info, true, true);
|
||||||
printf("leafblocks: %" PRIu64 "\n", info.leafblocks);
|
printf("leafblocks\t%" PRIu64 "\n", info.leafblocks);
|
||||||
printf("blocksizes: %" PRIu64 "\n", info.blocksizes);
|
printf("blocksizes\t%" PRIu64 "\n", info.blocksizes);
|
||||||
printf("leafsizes: %" PRIu64 "\n", info.leafsizes);
|
printf("leafsizes\t%" PRIu64 "\n", info.leafsizes);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -286,8 +290,8 @@ dump_garbage_stats(int f, FT ft) {
|
||||||
uint64_t total_space = 0;
|
uint64_t total_space = 0;
|
||||||
uint64_t used_space = 0;
|
uint64_t used_space = 0;
|
||||||
toku_ft_get_garbage(ft, &total_space, &used_space);
|
toku_ft_get_garbage(ft, &total_space, &used_space);
|
||||||
printf("total_size: %zu\n", total_space);
|
printf("total_size\t%zu\n", total_space);
|
||||||
printf("used_size: %zu\n", used_space);
|
printf("used_size\t%zu\n", used_space);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t
|
static uint32_t
|
||||||
|
@ -411,7 +415,7 @@ split_fields (char *line, char *fields[], int maxfields) {
|
||||||
|
|
||||||
static int
|
static int
|
||||||
usage(const char *arg0) {
|
usage(const char *arg0) {
|
||||||
printf("Usage: %s [--nodata] [--interactive] [--rootnode] ftfilename\n", arg0);
|
printf("Usage: %s [--nodata] [--i[nteractive]|--fragmentation|--translation-table|--rootnode] ftfilename\n", arg0);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -454,6 +458,8 @@ getuint64(const char *f) {
|
||||||
int
|
int
|
||||||
main (int argc, const char *const argv[]) {
|
main (int argc, const char *const argv[]) {
|
||||||
int interactive = 0;
|
int interactive = 0;
|
||||||
|
int fragmentation = 0;
|
||||||
|
int translation_table = 0;
|
||||||
int rootnode = 0;
|
int rootnode = 0;
|
||||||
|
|
||||||
const char *arg0 = argv[0];
|
const char *arg0 = argv[0];
|
||||||
|
@ -463,12 +469,17 @@ main (int argc, const char *const argv[]) {
|
||||||
dump_data = 0;
|
dump_data = 0;
|
||||||
} else if (strcmp(argv[0], "--interactive") == 0 || strcmp(argv[0], "--i") == 0) {
|
} else if (strcmp(argv[0], "--interactive") == 0 || strcmp(argv[0], "--i") == 0) {
|
||||||
interactive = 1;
|
interactive = 1;
|
||||||
|
} else if (strcmp(argv[0], "--fragmentation") == 0) {
|
||||||
|
fragmentation = 1;
|
||||||
|
} else if (strcmp(argv[0], "--translation-table") == 0) {
|
||||||
|
translation_table = 1;
|
||||||
} else if (strcmp(argv[0], "--rootnode") == 0) {
|
} else if (strcmp(argv[0], "--rootnode") == 0) {
|
||||||
rootnode = 1;
|
rootnode = 1;
|
||||||
} else if (strcmp(argv[0], "--help") == 0) {
|
} else if (strcmp(argv[0], "--help") == 0) {
|
||||||
return usage(arg0);
|
return usage(arg0);
|
||||||
} else
|
} else {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
argc--; argv++;
|
argc--; argv++;
|
||||||
}
|
}
|
||||||
if (argc != 1) return usage(arg0);
|
if (argc != 1) return usage(arg0);
|
||||||
|
@ -484,7 +495,11 @@ main (int argc, const char *const argv[]) {
|
||||||
CACHEFILE cf = NULL;
|
CACHEFILE cf = NULL;
|
||||||
r = toku_cachetable_openfd (&cf, ct, f, n);
|
r = toku_cachetable_openfd (&cf, ct, f, n);
|
||||||
assert(r==0);
|
assert(r==0);
|
||||||
dump_header(f, &ft, cf);
|
open_header(f, &ft, cf);
|
||||||
|
if (!fragmentation && !translation_table) {
|
||||||
|
// quick fix for now, we want those two to have clean output
|
||||||
|
dump_header(ft);
|
||||||
|
}
|
||||||
if (interactive) {
|
if (interactive) {
|
||||||
while (1) {
|
while (1) {
|
||||||
printf("ftdump>"); fflush(stdout);
|
printf("ftdump>"); fflush(stdout);
|
||||||
|
@ -502,7 +517,8 @@ main (int argc, const char *const argv[]) {
|
||||||
interactive_help();
|
interactive_help();
|
||||||
} else if (strcmp(fields[0], "header") == 0) {
|
} else if (strcmp(fields[0], "header") == 0) {
|
||||||
toku_ft_free(ft);
|
toku_ft_free(ft);
|
||||||
dump_header(f, &ft, cf);
|
open_header(f, &ft, cf);
|
||||||
|
dump_header(ft);
|
||||||
} else if (strcmp(fields[0], "block") == 0 && nfields == 2) {
|
} else if (strcmp(fields[0], "block") == 0 && nfields == 2) {
|
||||||
BLOCKNUM blocknum = make_blocknum(getuint64(fields[1]));
|
BLOCKNUM blocknum = make_blocknum(getuint64(fields[1]));
|
||||||
dump_block(f, blocknum, ft);
|
dump_block(f, blocknum, ft);
|
||||||
|
@ -539,6 +555,10 @@ main (int argc, const char *const argv[]) {
|
||||||
}
|
}
|
||||||
} else if (rootnode) {
|
} else if (rootnode) {
|
||||||
dump_node(f, ft->h->root_blocknum, ft);
|
dump_node(f, ft->h->root_blocknum, ft);
|
||||||
|
} else if (fragmentation) {
|
||||||
|
dump_fragmentation(f, ft);
|
||||||
|
} else if (translation_table) {
|
||||||
|
toku_dump_translation_table_pretty(stdout, ft->blocktable);
|
||||||
} else {
|
} else {
|
||||||
printf("Block translation:");
|
printf("Block translation:");
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue