Commit c4e34527 authored by Leif Walsh's avatar Leif Walsh Committed by Yoni Fogel

refs #5666 fix filesize.tdb


git-svn-id: file:///svn/toku/tokudb@49988 c7de825b-a66e-492c-adef-691d508d4ae1
parent 4b5043ea
...@@ -581,7 +581,7 @@ if(BUILD_TESTING OR BUILD_SRC_TESTS) ...@@ -581,7 +581,7 @@ if(BUILD_TESTING OR BUILD_SRC_TESTS)
add_test(ydb/keyrange-random-get1.tdb keyrange.tdb --get 1 --random_keys 1 --envdir dir.keyrange-random-get1.tdb) add_test(ydb/keyrange-random-get1.tdb keyrange.tdb --get 1 --random_keys 1 --envdir dir.keyrange-random-get1.tdb)
else () else ()
message(WARNING "TODO(leif): re-enable keyrange tests, see #5666") message(WARNING "TODO(leif): re-enable keyrange tests, see #5666")
declare_custom_tests(filesize.tdb keyrange-merge.tdb) declare_custom_tests(keyrange-merge.tdb)
list(REMOVE_ITEM abortrecover_tests recover-flt1.abortrecover) list(REMOVE_ITEM abortrecover_tests recover-flt1.abortrecover)
endif () endif ()
add_test(ydb/keyrange-loader-get0.tdb keyrange.tdb --get 0 --loader 1 --envdir dir.keyrange-loader-get0.tdb) add_test(ydb/keyrange-loader-get0.tdb keyrange.tdb --get 0 --loader 1 --envdir dir.keyrange-loader-get0.tdb)
......
...@@ -143,11 +143,11 @@ get_file_pathname(void) { ...@@ -143,11 +143,11 @@ get_file_pathname(void) {
} }
static int static int
getsizeM(void) { getsizeM(void) {
toku_struct_stat buf; toku_struct_stat buf;
int r = toku_stat(path, &buf); int r = toku_stat(path, &buf);
CKERR(r); CKERR(r);
int sizeM = (int)buf.st_size >> 20; int sizeM = (int)buf.st_size >> 20;
check_fragmentation(); check_fragmentation();
if (verbose>1) if (verbose>1)
...@@ -156,52 +156,64 @@ getsizeM(void) { ...@@ -156,52 +156,64 @@ getsizeM(void) {
} }
static void static void
test_filesize (void) test_filesize (bool sequential)
{ {
int N=1<<14; int N=1<<14;
int r, i, sizeM; int r, i, sizeM;
get_file_pathname(); get_file_pathname();
for (int iter = 0; iter < 3; iter++) { for (int iter = 0; iter < 3; iter++) {
int offset = N * iter; int offset = N * iter;
for (i=0; i<N; i++) { if (sequential) {
insert_n(i + offset, INSERT_BIG); for (i=0; i<N; i++) {
} insert_n(i + offset, INSERT_BIG);
}
r = env->txn_checkpoint(env, 0, 0, 0); } else {
CKERR(r); for (i=N-1; i>=0; --i) {
int sizefirst = sizeM = getsizeM(); insert_n(i + offset, INSERT_BIG);
if (verbose) printf("Filesize after iteration %d insertion and checkpoint = %dM\n", iter, sizeM); }
}
int preserve = 2;
for (i = preserve; i<(N); i++) { // leave a little at the beginning r = env->txn_checkpoint(env, 0, 0, 0);
delete_n(i + offset); CKERR(r);
} int sizefirst = sizeM = getsizeM();
optimize(); if (verbose) printf("Filesize after iteration %d insertion and checkpoint = %dM\n", iter, sizeM);
r = env->txn_checkpoint(env, 0, 0, 0); int preserve = 2;
CKERR(r); for (i = preserve; i<(N); i++) { // leave a little at the beginning
sizeM = getsizeM(); delete_n(i + offset);
if (verbose) printf("Filesize after iteration %d deletion and checkpoint 1 = %dM\n", iter, sizeM); }
optimize();
for (i=0; i<N; i++) {
insert_n(i + offset, INSERT_SMALL); r = env->txn_checkpoint(env, 0, 0, 0);
} CKERR(r);
for (i = preserve; i<(N); i++) { // leave a little at the beginning sizeM = getsizeM();
delete_n(i + offset); if (verbose) printf("Filesize after iteration %d deletion and checkpoint 1 = %dM\n", iter, sizeM);
}
optimize(); if (sequential) {
r = env->txn_checkpoint(env, 0, 0, 0); for (i=0; i<N; i++) {
CKERR(r); insert_n(i + offset, INSERT_SMALL);
sizeM = getsizeM(); }
if (verbose) printf("Filesize after iteration %d deletion and checkpoint 2 = %dM\n", iter, sizeM); } else {
assert(sizeM < sizefirst); for (i=N-1; i>=0; --i) {
insert_n(i + offset, INSERT_SMALL);
if (verbose) printf("ninsert = %d\n", ninsert); }
if (verbose) printf("nread = %d, nread_notfound = %d, nread_failed = %d\n", nread, nread_notfound, nread_failed); }
if (verbose) printf("ndelete = %d, ndelete_notfound = %d, ndelete_failed = %d\n", ndelete, ndelete_notfound, ndelete_failed); for (i = preserve; i<(N); i++) { // leave a little at the beginning
delete_n(i + offset);
}
optimize();
r = env->txn_checkpoint(env, 0, 0, 0);
CKERR(r);
sizeM = getsizeM();
if (verbose) printf("Filesize after iteration %d deletion and checkpoint 2 = %dM\n", iter, sizeM);
assert(sizeM <= sizefirst);
if (verbose) printf("ninsert = %d\n", ninsert);
if (verbose) printf("nread = %d, nread_notfound = %d, nread_failed = %d\n", nread, nread_notfound, nread_failed);
if (verbose) printf("ndelete = %d, ndelete_notfound = %d, ndelete_failed = %d\n", ndelete, ndelete_notfound, ndelete_failed);
} }
} }
...@@ -209,7 +221,16 @@ int test_main (int argc __attribute__((__unused__)), char * const argv[] __attri ...@@ -209,7 +221,16 @@ int test_main (int argc __attribute__((__unused__)), char * const argv[] __attri
parse_args(argc, argv); parse_args(argc, argv);
setup(); setup();
if (verbose) print_engine_status(env); if (verbose) print_engine_status(env);
test_filesize(); test_filesize(true);
if (verbose) {
print_engine_status(env);
}
check_fragmentation();
if (verbose) print_fragmentation();
close_em();
setup();
if (verbose) print_engine_status(env);
test_filesize(false);
if (verbose) { if (verbose) {
print_engine_status(env); print_engine_status(env);
} }
......
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