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) {
"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 (*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 (*change_pagesize)(DB*,uint32_t)",
"int (*change_readpagesize)(DB*,uint32_t)",
......
......@@ -232,6 +232,6 @@ void toku_ft_hot_get_status(FT_HOT_STATUS);
int
toku_ft_hot_optimize(FT_HANDLE brt, DBT* left, DBT* right,
int (*progress_callback)(void *extra, float progress),
void *progress_extra);
void *progress_extra, uint64_t* loops_run);
#endif // End of header guardian.
......@@ -299,7 +299,7 @@ hot_flusher_destroy(struct hot_flusher_extra *flusher)
int
toku_ft_hot_optimize(FT_HANDLE brt, DBT* left, DBT* right,
int (*progress_callback)(void *extra, float progress),
void *progress_extra)
void *progress_extra, uint64_t* loops_run)
{
int r = 0;
struct hot_flusher_extra flusher;
......@@ -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
// infinity.
} while (!flusher.rightmost_leaf_seen);
*loops_run = loop_count;
// Cleanup.
hot_flusher_destroy(&flusher);
......
......@@ -205,7 +205,8 @@ doit (void) {
toku_fill_dbt(&left, "g", 2);
DBT right;
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);
// at this point, we have should have flushed
......
......@@ -144,7 +144,8 @@ static int
do_hot_optimize(FT_HANDLE t, CACHETABLE UU(ct), void *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) {
CKERR2(r, 1);
} else {
......
......@@ -206,7 +206,8 @@ delete_n (uint32_t ah)
static void
optimize(void) {
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);
if (verbose) printf("Filesize: end optimize dictionary\n");
}
......
......@@ -247,7 +247,8 @@ hot_test(DB* db, unsigned int size)
// Flatten the tree.
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);
verbose ? printf("HOT Finished!\n") : 0;
for (unsigned int i = 0; i < size; ++i) {
......
......@@ -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);
// 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=env->close(env, 0); assert(r==0);
......
......@@ -180,7 +180,8 @@ static void __attribute__((unused))
do_hot_optimize_on_dbs(DB_ENV *UU(env), DB **dbs, int num_dbs)
{
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);
}
}
......
......@@ -1621,7 +1621,8 @@ static int UU() hot_op(DB_TXN *UU(txn), ARG UU(arg), void* UU(operation_extra),
int r;
for (int i = 0; run_test && i < arg->cli->num_DBs; 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) {
CKERR(r);
}
......
......@@ -898,13 +898,13 @@ toku_db_optimize(DB *db) {
static int
toku_db_hot_optimize(DB *db, DBT* left, DBT* right,
int (*progress_callback)(void *extra, float progress),
void *progress_extra)
void *progress_extra, uint64_t* loops_run)
{
HANDLE_PANICKED_DB(db);
int r = 0;
r = toku_ft_hot_optimize(db->i->ft_handle, left, right,
progress_callback,
progress_extra);
progress_extra, loops_run);
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