diff --git a/src/plasma/eviction_policy.c b/src/plasma/eviction_policy.c index 77ed07b71..fc2533387 100644 --- a/src/plasma/eviction_policy.c +++ b/src/plasma/eviction_policy.c @@ -168,11 +168,13 @@ void require_space(eviction_state *eviction_state, int64_t required_space = eviction_state->memory_used + size - eviction_state->memory_capacity; if (required_space > 0) { - /* Try to free up as much free space as we need right now. */ + /* Try to free up at least as much space as we need right now but ideally + * up to 20% of the total capacity. */ + int64_t space_to_free = MAX(size, eviction_state->memory_capacity / 5); LOG_DEBUG("not enough space to create this object, so evicting objects"); /* Choose some objects to evict, and update the return pointers. */ int64_t num_bytes_evicted = choose_objects_to_evict( - eviction_state, plasma_store_info, required_space, num_objects_to_evict, + eviction_state, plasma_store_info, space_to_free, num_objects_to_evict, objects_to_evict); printf("Evicted %" PRId64 " bytes.\n", num_bytes_evicted); LOG_INFO(