Commit b5d8ed60 authored by zkasheff's avatar zkasheff

refs Tokutek/mongo#645, change signature of hot_optimize to have output variable

of number of loops run
parent 293a684e
...@@ -529,7 +529,7 @@ static void print_db_struct (void) { ...@@ -529,7 +529,7 @@ static void print_db_struct (void) {
"int (*change_descriptor) (DB*, DB_TXN*, const DBT* descriptor, uint32_t) /* change row/dictionary descriptor for a db. Available only while db is open */", "int (*change_descriptor) (DB*, DB_TXN*, const DBT* descriptor, uint32_t) /* change row/dictionary descriptor for a db. Available only while db is open */",
"int (*getf_set)(DB*, DB_TXN*, uint32_t, DBT*, YDB_CALLBACK_FUNCTION, void*) /* same as DBC->c_getf_set without a persistent cursor) */", "int (*getf_set)(DB*, DB_TXN*, uint32_t, DBT*, YDB_CALLBACK_FUNCTION, void*) /* same as DBC->c_getf_set without a persistent cursor) */",
"int (*optimize)(DB*) /* Run garbage collecion and promote all transactions older than oldest. Amortized (happens during flattening) */", "int (*optimize)(DB*) /* Run garbage collecion and promote all transactions older than oldest. Amortized (happens during flattening) */",
"int (*hot_optimize)(DB*, DBT*, DBT*, int (*progress_callback)(void *progress_extra, float progress), void *progress_extra)", "int (*hot_optimize)(DB*, DBT*, DBT*, int (*progress_callback)(void *progress_extra, float progress), void *progress_extra, uint64_t* loops_run)",
"int (*get_fragmentation)(DB*,TOKU_DB_FRAGMENTATION)", "int (*get_fragmentation)(DB*,TOKU_DB_FRAGMENTATION)",
"int (*change_pagesize)(DB*,uint32_t)", "int (*change_pagesize)(DB*,uint32_t)",
"int (*change_readpagesize)(DB*,uint32_t)", "int (*change_readpagesize)(DB*,uint32_t)",
......
...@@ -232,6 +232,6 @@ void toku_ft_hot_get_status(FT_HOT_STATUS); ...@@ -232,6 +232,6 @@ void toku_ft_hot_get_status(FT_HOT_STATUS);
int int
toku_ft_hot_optimize(FT_HANDLE brt, DBT* left, DBT* right, toku_ft_hot_optimize(FT_HANDLE brt, DBT* left, DBT* right,
int (*progress_callback)(void *extra, float progress), int (*progress_callback)(void *extra, float progress),
void *progress_extra); void *progress_extra, uint64_t* loops_run);
#endif // End of header guardian. #endif // End of header guardian.
...@@ -299,7 +299,7 @@ hot_flusher_destroy(struct hot_flusher_extra *flusher) ...@@ -299,7 +299,7 @@ hot_flusher_destroy(struct hot_flusher_extra *flusher)
int int
toku_ft_hot_optimize(FT_HANDLE brt, DBT* left, DBT* right, toku_ft_hot_optimize(FT_HANDLE brt, DBT* left, DBT* right,
int (*progress_callback)(void *extra, float progress), int (*progress_callback)(void *extra, float progress),
void *progress_extra) void *progress_extra, uint64_t* loops_run)
{ {
int r = 0; int r = 0;
struct hot_flusher_extra flusher; struct hot_flusher_extra flusher;
...@@ -403,6 +403,7 @@ toku_ft_hot_optimize(FT_HANDLE brt, DBT* left, DBT* right, ...@@ -403,6 +403,7 @@ toku_ft_hot_optimize(FT_HANDLE brt, DBT* left, DBT* right,
// Loop until the max key has been updated to positive // Loop until the max key has been updated to positive
// infinity. // infinity.
} while (!flusher.rightmost_leaf_seen); } while (!flusher.rightmost_leaf_seen);
*loops_run = loop_count;
// Cleanup. // Cleanup.
hot_flusher_destroy(&flusher); hot_flusher_destroy(&flusher);
......
...@@ -205,7 +205,8 @@ doit (void) { ...@@ -205,7 +205,8 @@ doit (void) {
toku_fill_dbt(&left, "g", 2); toku_fill_dbt(&left, "g", 2);
DBT right; DBT right;
toku_fill_dbt(&right, "n", 2); toku_fill_dbt(&right, "n", 2);
r = toku_ft_hot_optimize(t, &left, &right, NULL, NULL); uint64_t loops_run = 0;
r = toku_ft_hot_optimize(t, &left, &right, NULL, NULL, &loops_run);
assert(r==0); assert(r==0);
// at this point, we have should have flushed // at this point, we have should have flushed
......
...@@ -144,7 +144,8 @@ static int ...@@ -144,7 +144,8 @@ static int
do_hot_optimize(FT_HANDLE t, CACHETABLE UU(ct), void *extra) do_hot_optimize(FT_HANDLE t, CACHETABLE UU(ct), void *extra)
{ {
float *CAST_FROM_VOIDP(fraction, extra); float *CAST_FROM_VOIDP(fraction, extra);
int r = toku_ft_hot_optimize(t, NULL, NULL, progress, extra); uint64_t loops_run = 0;
int r = toku_ft_hot_optimize(t, NULL, NULL, progress, extra, &loops_run);
if (*fraction < 1.0) { if (*fraction < 1.0) {
CKERR2(r, 1); CKERR2(r, 1);
} else { } else {
......
...@@ -206,7 +206,8 @@ delete_n (uint32_t ah) ...@@ -206,7 +206,8 @@ delete_n (uint32_t ah)
static void static void
optimize(void) { optimize(void) {
if (verbose) printf("Filesize: begin optimize dictionary\n"); if (verbose) printf("Filesize: begin optimize dictionary\n");
int r = db->hot_optimize(db, NULL, NULL, NULL, NULL); uint64_t loops_run;
int r = db->hot_optimize(db, NULL, NULL, NULL, NULL, &loops_run);
CKERR(r); CKERR(r);
if (verbose) printf("Filesize: end optimize dictionary\n"); if (verbose) printf("Filesize: end optimize dictionary\n");
} }
......
...@@ -247,7 +247,8 @@ hot_test(DB* db, unsigned int size) ...@@ -247,7 +247,8 @@ hot_test(DB* db, unsigned int size)
// Flatten the tree. // Flatten the tree.
verbose ? printf("Calling hot optimize...\n") : 0; verbose ? printf("Calling hot optimize...\n") : 0;
r = db->hot_optimize(db, NULL, NULL, NULL, NULL); uint64_t loops_run;
r = db->hot_optimize(db, NULL, NULL, NULL, NULL, &loops_run);
assert(r == 0); assert(r == 0);
verbose ? printf("HOT Finished!\n") : 0; verbose ? printf("HOT Finished!\n") : 0;
for (unsigned int i = 0; i < size; ++i) { for (unsigned int i = 0; i < size; ++i) {
......
...@@ -113,7 +113,8 @@ test_main (int UU(argc), char UU(*const argv[])) { ...@@ -113,7 +113,8 @@ test_main (int UU(argc), char UU(*const argv[])) {
r = db->open(db, NULL, "test.db", 0, DB_BTREE, DB_CREATE, S_IRWXU+S_IRWXG+S_IRWXO); assert(r == 0); r = db->open(db, NULL, "test.db", 0, DB_BTREE, DB_CREATE, S_IRWXU+S_IRWXG+S_IRWXO); assert(r == 0);
// call hot_optimize on an empty db. The empty db should have only a root node, which should invoke the bug // call hot_optimize on an empty db. The empty db should have only a root node, which should invoke the bug
r = db->hot_optimize(db, NULL, NULL, NULL, NULL); assert_zero(r); uint64_t loops_run;
r = db->hot_optimize(db, NULL, NULL, NULL, NULL, &loops_run); assert_zero(r);
r=db->close(db, 0); assert(r==0); r=db->close(db, 0); assert(r==0);
r=env->close(env, 0); assert(r==0); r=env->close(env, 0); assert(r==0);
......
...@@ -180,7 +180,8 @@ static void __attribute__((unused)) ...@@ -180,7 +180,8 @@ static void __attribute__((unused))
do_hot_optimize_on_dbs(DB_ENV *UU(env), DB **dbs, int num_dbs) do_hot_optimize_on_dbs(DB_ENV *UU(env), DB **dbs, int num_dbs)
{ {
for (int i = 0; i < num_dbs; ++i) { for (int i = 0; i < num_dbs; ++i) {
int r = dbs[i]->hot_optimize(dbs[i], NULL, NULL, dummy_progress, NULL); uint64_t loops_run;
int r = dbs[i]->hot_optimize(dbs[i], NULL, NULL, dummy_progress, NULL, &loops_run);
CKERR(r); CKERR(r);
} }
} }
......
...@@ -1621,7 +1621,8 @@ static int UU() hot_op(DB_TXN *UU(txn), ARG UU(arg), void* UU(operation_extra), ...@@ -1621,7 +1621,8 @@ static int UU() hot_op(DB_TXN *UU(txn), ARG UU(arg), void* UU(operation_extra),
int r; int r;
for (int i = 0; run_test && i < arg->cli->num_DBs; i++) { for (int i = 0; run_test && i < arg->cli->num_DBs; i++) {
DB* db = arg->dbp[i]; DB* db = arg->dbp[i];
r = db->hot_optimize(db, NULL, NULL, hot_progress_callback, nullptr); uint64_t loops_run;
r = db->hot_optimize(db, NULL, NULL, hot_progress_callback, nullptr, &loops_run);
if (run_test) { if (run_test) {
CKERR(r); CKERR(r);
} }
......
...@@ -898,13 +898,13 @@ toku_db_optimize(DB *db) { ...@@ -898,13 +898,13 @@ toku_db_optimize(DB *db) {
static int static int
toku_db_hot_optimize(DB *db, DBT* left, DBT* right, toku_db_hot_optimize(DB *db, DBT* left, DBT* right,
int (*progress_callback)(void *extra, float progress), int (*progress_callback)(void *extra, float progress),
void *progress_extra) void *progress_extra, uint64_t* loops_run)
{ {
HANDLE_PANICKED_DB(db); HANDLE_PANICKED_DB(db);
int r = 0; int r = 0;
r = toku_ft_hot_optimize(db->i->ft_handle, left, right, r = toku_ft_hot_optimize(db->i->ft_handle, left, right,
progress_callback, progress_callback,
progress_extra); progress_extra, loops_run);
return r; return r;
} }
......
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