Commit 0c32eedb authored by Christian Rober's avatar Christian Rober Committed by Yoni Fogel

refs #5372 Added pointer to pair list. Updated associated tests and uses of...

refs #5372 Added pointer to pair list.  Updated associated tests and uses of pair list.  This removes cachetable pointer from checkpointer.

git-svn-id: file:///svn/toku/tokudb@47544 c7de825b-a66e-492c-adef-691d508d4ae1
parent 876f8760
...@@ -311,7 +311,7 @@ public: ...@@ -311,7 +311,7 @@ public:
// //
class checkpointer { class checkpointer {
public: public:
void init(CACHETABLE _ct, TOKULOGGER _logger, evictor *_ev, cachefile_list *files); void init(pair_list *_pl, TOKULOGGER _logger, evictor *_ev, cachefile_list *files);
void destroy(); void destroy();
int set_checkpoint_period(uint32_t new_period); int set_checkpoint_period(uint32_t new_period);
uint32_t get_checkpoint_period(); uint32_t get_checkpoint_period();
...@@ -331,8 +331,7 @@ private: ...@@ -331,8 +331,7 @@ private:
uint32_t m_checkpoint_num_files; // how many cachefiles are in the checkpoint uint32_t m_checkpoint_num_files; // how many cachefiles are in the checkpoint
struct minicron m_checkpointer_cron; // the periodic checkpointing thread struct minicron m_checkpointer_cron; // the periodic checkpointing thread
cachefile_list *m_cf_list; cachefile_list *m_cf_list;
// <CER> TEMP? pair_list *m_list;
CACHETABLE m_ct;
evictor *m_ev; evictor *m_ev;
// variable used by the checkpoint thread to know // variable used by the checkpoint thread to know
......
...@@ -210,7 +210,7 @@ int toku_create_cachetable(CACHETABLE *result, long size_limit, LSN UU(initial_l ...@@ -210,7 +210,7 @@ int toku_create_cachetable(CACHETABLE *result, long size_limit, LSN UU(initial_l
ct->checkpointing_kibbutz = toku_kibbutz_create(checkpointing_nworkers); ct->checkpointing_kibbutz = toku_kibbutz_create(checkpointing_nworkers);
// must be done after creating ct_kibbutz // must be done after creating ct_kibbutz
ct->ev.init(size_limit, &ct->list, ct->ct_kibbutz, EVICTION_PERIOD); ct->ev.init(size_limit, &ct->list, ct->ct_kibbutz, EVICTION_PERIOD);
ct->cp.init(ct, logger, &ct->ev, &ct->cf_list); ct->cp.init(&ct->list, logger, &ct->ev, &ct->cf_list);
ct->cl.init(1, &ct->list, ct); // by default, start with one iteration ct->cl.init(1, &ct->list, ct); // by default, start with one iteration
ct->env_dir = toku_xstrdup("."); ct->env_dir = toku_xstrdup(".");
*result = ct; *result = ct;
...@@ -4166,11 +4166,11 @@ ENSURE_POD(checkpointer); ...@@ -4166,11 +4166,11 @@ ENSURE_POD(checkpointer);
// //
// Sets the cachetable reference in this checkpointer class, this is temporary. // Sets the cachetable reference in this checkpointer class, this is temporary.
// //
void checkpointer::init(CACHETABLE _ct, void checkpointer::init(pair_list *_pl,
TOKULOGGER _logger, TOKULOGGER _logger,
evictor *_ev, evictor *_ev,
cachefile_list *files) { cachefile_list *files) {
m_ct = _ct; m_list = _pl;
m_logger = _logger; m_logger = _logger;
m_ev = _ev; m_ev = _ev;
m_cf_list = files; m_cf_list = files;
...@@ -4275,19 +4275,19 @@ int checkpointer::begin_checkpoint() { ...@@ -4275,19 +4275,19 @@ int checkpointer::begin_checkpoint() {
bjm_reset(m_checkpoint_clones_bjm); bjm_reset(m_checkpoint_clones_bjm);
m_ct->list.write_pending_exp_lock(); m_list->write_pending_exp_lock();
m_ct->list.read_list_lock(); m_list->read_list_lock();
m_cf_list->read_lock(); // needed for update_cachefiles m_cf_list->read_lock(); // needed for update_cachefiles
m_ct->list.write_pending_cheap_lock(); m_list->write_pending_cheap_lock();
// 4. Turn on all the relevant checkpoint pending bits. // 4. Turn on all the relevant checkpoint pending bits.
this->turn_on_pending_bits(); this->turn_on_pending_bits();
// 5. // 5.
this->update_cachefiles(); this->update_cachefiles();
m_ct->list.write_pending_cheap_unlock(); m_list->write_pending_cheap_unlock();
m_cf_list->read_unlock(); m_cf_list->read_unlock();
m_ct->list.read_list_unlock(); m_list->read_list_unlock();
m_ct->list.write_pending_exp_unlock(); m_list->write_pending_exp_unlock();
return r; return r;
} }
...@@ -4348,9 +4348,9 @@ void checkpointer::log_begin_checkpoint() { ...@@ -4348,9 +4348,9 @@ void checkpointer::log_begin_checkpoint() {
// both pending locks are grabbed // both pending locks are grabbed
// //
void checkpointer::turn_on_pending_bits() { void checkpointer::turn_on_pending_bits() {
for (uint32_t i = 0; i < m_ct->list.m_table_size; i++) { for (uint32_t i = 0; i < m_list->m_table_size; i++) {
PAIR p; PAIR p;
for (p = m_ct->list.m_table[i]; p; p = p->hash_chain) { for (p = m_list->m_table[i]; p; p = p->hash_chain) {
assert(!p->checkpoint_pending); assert(!p->checkpoint_pending);
//Only include pairs belonging to cachefiles in the checkpoint //Only include pairs belonging to cachefiles in the checkpoint
if (!p->cachefile->for_checkpoint) { if (!p->cachefile->for_checkpoint) {
...@@ -4366,12 +4366,12 @@ void checkpointer::turn_on_pending_bits() { ...@@ -4366,12 +4366,12 @@ void checkpointer::turn_on_pending_bits() {
// we may end up clearing the pending bit before the // we may end up clearing the pending bit before the
// current lock is ever released. // current lock is ever released.
p->checkpoint_pending = true; p->checkpoint_pending = true;
if (m_ct->list.m_pending_head) { if (m_list->m_pending_head) {
m_ct->list.m_pending_head->pending_prev = p; m_list->m_pending_head->pending_prev = p;
} }
p->pending_next = m_ct->list.m_pending_head; p->pending_next = m_list->m_pending_head;
p->pending_prev = NULL; p->pending_prev = NULL;
m_ct->list.m_pending_head = p; m_list->m_pending_head = p;
} }
} }
} }
...@@ -4420,20 +4420,20 @@ void checkpointer::fill_checkpoint_cfs(CACHEFILE* checkpoint_cfs) { ...@@ -4420,20 +4420,20 @@ void checkpointer::fill_checkpoint_cfs(CACHEFILE* checkpoint_cfs) {
void checkpointer::checkpoint_pending_pairs() { void checkpointer::checkpoint_pending_pairs() {
PAIR p; PAIR p;
m_ct->list.read_list_lock(); m_list->read_list_lock();
while ((p = m_ct->list.m_pending_head)!=0) { while ((p = m_list->m_pending_head)!=0) {
// <CER> TODO: Investigate why we move pending head outisde of the pending_pairs_remove() call. // <CER> TODO: Investigate why we move pending head outisde of the pending_pairs_remove() call.
m_ct->list.m_pending_head = m_ct->list.m_pending_head->pending_next; m_list->m_pending_head = m_list->m_pending_head->pending_next;
m_ct->list.pending_pairs_remove(p); m_list->pending_pairs_remove(p);
// if still pending, clear the pending bit and write out the node // if still pending, clear the pending bit and write out the node
pair_lock(p); pair_lock(p);
m_ct->list.read_list_unlock(); m_list->read_list_unlock();
write_pair_for_checkpoint_thread(m_ev, p); write_pair_for_checkpoint_thread(m_ev, p);
pair_unlock(p); pair_unlock(p);
m_ct->list.read_list_lock(); m_list->read_list_lock();
} }
assert(!m_ct->list.m_pending_head); assert(!m_list->m_pending_head);
m_ct->list.read_list_unlock(); m_list->read_list_unlock();
bjm_wait_for_jobs_to_finish(m_checkpoint_clones_bjm); bjm_wait_for_jobs_to_finish(m_checkpoint_clones_bjm);
} }
......
...@@ -82,7 +82,7 @@ void checkpointer_test::test_begin_checkpoint() { ...@@ -82,7 +82,7 @@ void checkpointer_test::test_begin_checkpoint() {
cachetable ctbl; cachetable ctbl;
ctbl.list.init(); ctbl.list.init();
m_cp.init(&ctbl, NULL, &ctbl.ev, &cfl); m_cp.init(&ctbl.list, NULL, &ctbl.ev, &cfl);
// 1. Call checkpoint with NO cachefiles. // 1. Call checkpoint with NO cachefiles.
r = m_cp.begin_checkpoint(); r = m_cp.begin_checkpoint();
...@@ -136,7 +136,6 @@ void checkpointer_test::test_pending_bits() { ...@@ -136,7 +136,6 @@ void checkpointer_test::test_pending_bits() {
cachetable ctbl; cachetable ctbl;
ctbl.list.init(); ctbl.list.init();
m_cp.m_ct = &ctbl;
// //
// 1. Empty hash chain. // 1. Empty hash chain.
...@@ -179,11 +178,11 @@ void checkpointer_test::test_pending_bits() { ...@@ -179,11 +178,11 @@ void checkpointer_test::test_pending_bits() {
NULL, NULL,
&ctbl.list); &ctbl.list);
m_cp.m_ct->list.put(&p); m_cp.m_list->put(&p);
m_cp.turn_on_pending_bits(); m_cp.turn_on_pending_bits();
assert(p.checkpoint_pending); assert(p.checkpoint_pending);
m_cp.m_ct->list.evict(&p); m_cp.m_list->evict(&p);
// //
// 3. Many hash chain entries. // 3. Many hash chain entries.
...@@ -201,9 +200,9 @@ void checkpointer_test::test_pending_bits() { ...@@ -201,9 +200,9 @@ void checkpointer_test::test_pending_bits() {
CACHEKEY key; CACHEKEY key;
key.b = i; key.b = i;
uint32_t full_hash = toku_cachetable_hash(&cf, key); uint32_t full_hash = toku_cachetable_hash(&cf, key);
PAIR pp = m_cp.m_ct->list.find_pair(&cf, key, full_hash); PAIR pp = m_cp.m_list->find_pair(&cf, key, full_hash);
assert(pp); assert(pp);
m_cp.m_ct->list.evict(pp); m_cp.m_list->evict(pp);
} }
int r = ctbl.list.destroy(); int r = ctbl.list.destroy();
...@@ -242,9 +241,9 @@ void checkpointer_test::add_pairs(struct cachefile *cf, ...@@ -242,9 +241,9 @@ void checkpointer_test::add_pairs(struct cachefile *cf,
full_hash, full_hash,
cb, cb,
NULL, NULL,
&m_cp.m_ct->list); m_cp.m_list);
m_cp.m_ct->list.put(&pairs[i]); m_cp.m_list->put(&pairs[i]);
} }
} }
...@@ -278,7 +277,6 @@ void checkpointer_test::test_end_checkpoint() { ...@@ -278,7 +277,6 @@ void checkpointer_test::test_end_checkpoint() {
// 1. Init test. // 1. Init test.
cachetable ctbl; cachetable ctbl;
ctbl.list.init(); ctbl.list.init();
m_cp.m_ct = &ctbl;
cachefile_list cfl; cachefile_list cfl;
cfl.init(); cfl.init();
...@@ -289,14 +287,14 @@ void checkpointer_test::test_end_checkpoint() { ...@@ -289,14 +287,14 @@ void checkpointer_test::test_end_checkpoint() {
cf.for_checkpoint = true; cf.for_checkpoint = true;
create_dummy_functions(&cf); create_dummy_functions(&cf);
m_cp.init(&ctbl, NULL, &ctbl.ev, &cfl); m_cp.init(&ctbl.list, NULL, &ctbl.ev, &cfl);
m_cp.m_cf_list->m_head = &cf; m_cp.m_cf_list->m_head = &cf;
// 2. Add data before running checkpoint. // 2. Add data before running checkpoint.
const uint32_t count = 6; const uint32_t count = 6;
ctpair pairs[count]; ctpair pairs[count];
add_pairs(&cf, pairs, count / 2, 0); add_pairs(&cf, pairs, count / 2, 0);
assert(m_cp.m_ct->list.m_n_in_table == count / 2); assert(m_cp.m_list->m_n_in_table == count / 2);
// 3. Call begin checkpoint. // 3. Call begin checkpoint.
m_cp.begin_checkpoint(); m_cp.begin_checkpoint();
...@@ -308,20 +306,20 @@ void checkpointer_test::test_end_checkpoint() { ...@@ -308,20 +306,20 @@ void checkpointer_test::test_end_checkpoint() {
// 4. Add new data between starting and stopping checkpoint. // 4. Add new data between starting and stopping checkpoint.
add_pairs(&cf, pairs, count / 2, count / 2); add_pairs(&cf, pairs, count / 2, count / 2);
assert(m_cp.m_ct->list.m_n_in_table == count); assert(m_cp.m_list->m_n_in_table == count);
for (uint32_t i = count / 2; i < count / 2; ++i) for (uint32_t i = count / 2; i < count / 2; ++i)
{ {
assert(!pairs[i].checkpoint_pending); assert(!pairs[i].checkpoint_pending);
} }
uint32_t pending_pairs = 0; uint32_t pending_pairs = 0;
pending_pairs = get_number_pending_pairs(&m_cp.m_ct->list); pending_pairs = get_number_pending_pairs(m_cp.m_list);
assert(pending_pairs == count / 2); assert(pending_pairs == count / 2);
// 5. Call end checkpoint // 5. Call end checkpoint
m_cp.end_checkpoint(NULL, NULL); m_cp.end_checkpoint(NULL, NULL);
pending_pairs = get_number_pending_pairs(&m_cp.m_ct->list); pending_pairs = get_number_pending_pairs(m_cp.m_list);
assert(pending_pairs == 0); assert(pending_pairs == 0);
// Verify that none of the pairs are pending a checkpoint. // Verify that none of the pairs are pending a checkpoint.
...@@ -335,9 +333,9 @@ void checkpointer_test::test_end_checkpoint() { ...@@ -335,9 +333,9 @@ void checkpointer_test::test_end_checkpoint() {
CACHEKEY key; CACHEKEY key;
key.b = i; key.b = i;
uint32_t full_hash = toku_cachetable_hash(&cf, key); uint32_t full_hash = toku_cachetable_hash(&cf, key);
PAIR pp = m_cp.m_ct->list.find_pair(&cf, key, full_hash); PAIR pp = m_cp.m_list->find_pair(&cf, key, full_hash);
assert(pp); assert(pp);
m_cp.m_ct->list.evict(pp); m_cp.m_list->evict(pp);
} }
m_cp.destroy(); m_cp.destroy();
int r = ctbl.list.destroy(); int r = ctbl.list.destroy();
......
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