<< BeesAddress(bhte.e_addr) << " }";
}
-#if 0
-static
-void
-dump_bucket_locked(BeesHashTable::Cell *p, BeesHashTable::Cell *q)
-{
- for (auto i = p; i < q; ++i) {
- BEESLOG("Entry " << i - p << " " << *i);
- }
-}
-#endif
-
-static const bool VERIFY_CLEARS_BUGS = false;
-
-bool
-verify_cell_range(BeesHashTable::Cell *p, BeesHashTable::Cell *q, bool clear_bugs = VERIFY_CLEARS_BUGS)
-{
- // Must be called while holding m_bucket_mutex
- bool bugs_found = false;
- set<BeesHashTable::Cell> seen_it;
- for (BeesHashTable::Cell *cell = p; cell < q; ++cell) {
- if (cell->e_addr && cell->e_addr < 0x1000) {
- BEESCOUNT(bug_hash_magic_addr);
- BEESLOGDEBUG("Bad hash table address hash " << to_hex(cell->e_hash) << " addr " << to_hex(cell->e_addr));
- if (clear_bugs) {
- cell->e_addr = 0;
- cell->e_hash = 0;
- }
- bugs_found = true;
- }
- if (cell->e_addr && !seen_it.insert(*cell).second) {
- BEESCOUNT(bug_hash_duplicate_cell);
- // BEESLOGDEBUG("Duplicate hash table entry:\nthis = " << *cell << "\nold = " << *seen_it.find(*cell));
- BEESLOGDEBUG("Duplicate hash table entry: " << *cell);
- if (clear_bugs) {
- cell->e_addr = 0;
- cell->e_hash = 0;
- }
- bugs_found = true;
- }
- }
- return bugs_found;
-}
-
pair<BeesHashTable::Cell *, BeesHashTable::Cell *>
BeesHashTable::get_cell_range(HashType hash)
{
*ip = Cell(0, 0);
set_extent_dirty_locked(hash_to_extent_index(hash));
BEESCOUNT(hash_erase);
-#if 0
- if (verify_cell_range(er.first, er.second)) {
- BEESLOGDEBUG("while erasing hash " << hash << " addr " << addr);
- }
-#endif
} else {
BEESCOUNT(hash_erase_miss);
}
if (er.first[0] != prev_front) {
set_extent_dirty_locked(hash_to_extent_index(hash));
}
-#if 0
- if (verify_cell_range(er.first, er.second)) {
- BEESLOGDEBUG("while push_fronting hash " << hash << " addr " << addr);
- }
-#endif
return found;
}
const size_t pos = m_randomize_lru ? tl_distribution(bees_generator) : 0;
- int case_cond = 0;
-#if 0
- vector<Cell> saved(er.first, er.second);
-#endif
-
if (found) {
// If hash already exists after pos, swap with pos
if (ip > er.first + pos) {
}
*dp = mv;
BEESCOUNT(hash_bump);
- case_cond = 1;
goto ret_dirty;
}
// Hash already exists before (or at) pos, leave it there
BEESCOUNT(hash_already);
- case_cond = 2;
goto ret;
}
for (ip = er.first + pos; ip < er.second; ++ip) {
if (*ip == Cell(0, 0)) {
*ip = mv;
- case_cond = 3;
goto ret_dirty;
}
}
for (ip = er.first + pos - 1; ip >= er.first; --ip) {
if (*ip == Cell(0, 0)) {
*ip = mv;
- case_cond = 4;
goto ret_dirty;
}
}
}
er.first[pos] = mv;
BEESCOUNT(hash_evict);
- case_cond = 5;
ret_dirty:
BEESCOUNT(hash_insert);
set_extent_dirty_locked(hash_to_extent_index(hash));
ret:
-#if 0
- if (verify_cell_range(er.first, er.second, false)) {
- BEESLOG("while push_randoming (case " << case_cond << ") pos " << pos
- << " ip " << (ip - er.first) << " " << mv);
- // dump_bucket_locked(saved.data(), saved.data() + saved.size());
- // dump_bucket_locked(er.first, er.second);
- }
-#else
- (void)case_cond;
-#endif
return found;
}