// Check if in other hit sets
map<time_t,HitSetRef>::iterator itor;
bool in_other_hit_sets = false;
- for (itor = agent_state->hit_set_map.begin(); itor != agent_state->hit_set_map.end(); ++itor) {
+ unsigned max_in_memory_read = pool.info.min_read_recency_for_promote > 0 ? pool.info.min_read_recency_for_promote - 1 : 0;
+ unsigned max_in_memory_write = pool.info.min_write_recency_for_promote > 0 ? pool.info.min_write_recency_for_promote - 1 : 0;
+ unsigned max_in_memory = MAX(max_in_memory_read, max_in_memory_write);
+ for (itor = agent_state->hit_set_map.begin(); itor != agent_state->hit_set_map.end() && max_in_memory--; ++itor) {
if (obc.get()) {
if (obc->obs.oi.soid != hobject_t() && itor->second->contains(obc->obs.oi.soid)) {
in_other_hit_sets = true;
if (agent_state) {
agent_state->add_hit_set(info.hit_set.current_info.begin, hit_set);
- hit_set_in_memory_trim();
+ uint32_t size = agent_state->hit_set_map.size();
+ if (size >= pool.info.hit_set_count) {
+ size = pool.info.hit_set_count > 0 ? pool.info.hit_set_count - 1: 0;
+ }
+ hit_set_in_memory_trim(size);
}
// hold a ref until it is flushed to disk
}
}
-void ReplicatedPG::hit_set_in_memory_trim()
+void ReplicatedPG::hit_set_in_memory_trim(uint32_t max_in_memory)
{
- unsigned max = pool.info.hit_set_count;
- unsigned max_in_memory_read = pool.info.min_read_recency_for_promote > 0 ? pool.info.min_read_recency_for_promote - 1 : 0;
- unsigned max_in_memory_write = pool.info.min_write_recency_for_promote > 0 ? pool.info.min_write_recency_for_promote - 1 : 0;
- unsigned max_in_memory = MAX(max_in_memory_read, max_in_memory_write);
-
- if (max_in_memory > max) {
- max_in_memory = max;
- }
while (agent_state->hit_set_map.size() > max_in_memory) {
agent_state->remove_oldest_hit_set();
}
agent_state->position = next;
// Discard old in memory HitSets
- hit_set_in_memory_trim();
+ hit_set_in_memory_trim(pool.info.hit_set_count);
if (need_delay) {
assert(agent_state->delaying == false);
void hit_set_persist(); ///< persist hit info
bool hit_set_apply_log(); ///< apply log entries to update in-memory HitSet
void hit_set_trim(RepGather *repop, unsigned max); ///< discard old HitSets
- void hit_set_in_memory_trim(); ///< discard old in memory HitSets
+ void hit_set_in_memory_trim(uint32_t max_in_memory); ///< discard old in memory HitSets
void hit_set_remove_all();
hobject_t get_hit_set_current_object(utime_t stamp);